From fbfbd68cefb57da8e71cc8c385e3dda3e15d63c5 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Mon, 4 May 2015 07:44:01 -0600 Subject: [PATCH] Basic object store container functional tests Basic object store container functional tests along with some changes so that setUp and tearDown can create and destroy the test object. The group_regex gets each class to run on one process. Change-Id: Ibffb3cd61976e7db3c4199c627b30af2fa15f652 --- .testr.conf | 3 +- openstack/tests/functional/base.py | 16 ++++++-- openstack/tests/functional/object/__init__.py | 0 .../tests/functional/object/v1/__init__.py | 0 .../functional/object/v1/test_container.py | 39 +++++++++++++++++++ 5 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 openstack/tests/functional/object/__init__.py create mode 100644 openstack/tests/functional/object/v1/__init__.py create mode 100644 openstack/tests/functional/object/v1/test_container.py diff --git a/.testr.conf b/.testr.conf index 4ae1e204a..499b7a370 100644 --- a/.testr.conf +++ b/.testr.conf @@ -4,4 +4,5 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./openstack/tests/unit} $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE -test_list_option=--list \ No newline at end of file +test_list_option=--list +group_regex=([^\.]+\.)+ diff --git a/openstack/tests/functional/base.py b/openstack/tests/functional/base.py index 314c85abc..37c904d21 100644 --- a/openstack/tests/functional/base.py +++ b/openstack/tests/functional/base.py @@ -16,16 +16,24 @@ import os_client_config from openstack import connection from openstack import user_preference +from openstack import utils class BaseFunctionalTest(unittest.TestCase): - def setUp(self): + @classmethod + def setUpClass(cls): test_cloud = os_client_config.OpenStackConfig().get_one_cloud( 'test_cloud') pref = user_preference.UserPreference() pref.set_region(pref.ALL, test_cloud.region) + if test_cloud.debug: + utils.enable_logging(True) - self.conn = connection.Connection( - preference=pref, - **test_cloud.config['auth']) + auth = test_cloud.config['auth'] + cls.conn = connection.Connection(preference=pref, **auth) + + @classmethod + def assertIs(cls, expected, actual): + if expected != actual: + raise Exception(expected + ' != ' + actual) diff --git a/openstack/tests/functional/object/__init__.py b/openstack/tests/functional/object/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/tests/functional/object/v1/__init__.py b/openstack/tests/functional/object/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/tests/functional/object/v1/test_container.py b/openstack/tests/functional/object/v1/test_container.py new file mode 100644 index 000000000..7d66e2319 --- /dev/null +++ b/openstack/tests/functional/object/v1/test_container.py @@ -0,0 +1,39 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import uuid + +from openstack.object_store.v1 import container +from openstack.tests.functional import base + + +class TestContainer(base.BaseFunctionalTest): + + NAME = uuid.uuid4().hex + + @classmethod + def setUpClass(cls): + super(TestContainer, cls).setUpClass() + tainer = cls.conn.object_store.create_container(name=cls.NAME) + assert isinstance(tainer, container.Container) + cls.assertIs(cls.NAME, tainer.name) + + @classmethod + def tearDownClass(cls): + pass + # TODO(thowe): uncomment this when bug/1451211 fixed + # tainer = cls.conn.object_store.delete_container(cls.NAME) + # cls.assertIs(None, tainer) + + def test_list(self): + names = [o.name for o in self.conn.object_store.containers()] + self.assertIn(self.NAME, names)