From e904cb6f4bc418c99366814eee68a4183a045c39 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Thu, 13 Dec 2018 22:04:38 +0100 Subject: [PATCH] Drop self.conn from base.TestCase It's the same variable as self.cloud so just use that one in all tests. Change-Id: Ie2a526c420e7156888931832b55c5b1619d20452 --- openstack/tests/unit/base.py | 3 +-- .../tests/unit/object_store/v1/test_container.py | 8 ++++---- openstack/tests/unit/object_store/v1/test_obj.py | 4 ++-- openstack/tests/unit/object_store/v1/test_proxy.py | 4 ++-- openstack/tests/unit/test_connection.py | 12 ++++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/openstack/tests/unit/base.py b/openstack/tests/unit/base.py index 365f883fd..4ef8693e9 100644 --- a/openstack/tests/unit/base.py +++ b/openstack/tests/unit/base.py @@ -436,9 +436,8 @@ class TestCase(base.TestCase): test_cloud = os.environ.get('OPENSTACKSDK_OS_CLOUD', cloud_name) self.cloud_config = self.config.get_one( cloud=test_cloud, validate=True, **kwargs) - self.conn = openstack.connection.Connection( + self.cloud = openstack.connection.Connection( config=self.cloud_config, strict=self.strict_cloud) - self.cloud = self.conn self.addCleanup(self.cloud.task_manager.stop) def get_glance_discovery_mock_dict( diff --git a/openstack/tests/unit/object_store/v1/test_container.py b/openstack/tests/unit/object_store/v1/test_container.py index 5d53e6532..1821160bc 100644 --- a/openstack/tests/unit/object_store/v1/test_container.py +++ b/openstack/tests/unit/object_store/v1/test_container.py @@ -21,7 +21,7 @@ class TestContainer(base.TestCase): def setUp(self): super(TestContainer, self).setUp() self.container = self.getUniqueString() - self.endpoint = self.conn.object_store.get_endpoint() + '/' + self.endpoint = self.cloud.object_store.get_endpoint() + '/' self.container_endpoint = '{endpoint}{container}'.format( endpoint=self.endpoint, container=self.container) @@ -118,7 +118,7 @@ class TestContainer(base.TestCase): json=containers) ]) - response = container.Container.list(self.conn.object_store) + response = container.Container.list(self.cloud.object_store) self.assertEqual(len(containers), len(list(response))) for index, item in enumerate(response): @@ -143,7 +143,7 @@ class TestContainer(base.TestCase): json=self.body, validate=dict(headers=headers)), ]) - sot_call(self.conn.object_store) + sot_call(self.cloud.object_store) self.assert_calls() @@ -199,7 +199,7 @@ class TestContainer(base.TestCase): headers=headers, json=data)) ]) - sot_call(self.conn.object_store) + sot_call(self.cloud.object_store) def test_create_no_headers(self): sot = container.Container.new(name=self.container) diff --git a/openstack/tests/unit/object_store/v1/test_obj.py b/openstack/tests/unit/object_store/v1/test_obj.py index f417bf7ce..5b5c58b49 100644 --- a/openstack/tests/unit/object_store/v1/test_obj.py +++ b/openstack/tests/unit/object_store/v1/test_obj.py @@ -121,7 +121,7 @@ class TestObject(base_test_object.BaseTestObject): # the up-conversion works properly. sot.if_match = self.headers['Etag'] - rv = sot.download(self.conn.object_store) + rv = sot.download(self.cloud.object_store) self.assertEqual(self.the_data, rv) @@ -139,7 +139,7 @@ class TestObject(base_test_object.BaseTestObject): headers=sent_headers)) ]) - rv = sot.create(self.conn.object_store) + rv = sot.create(self.cloud.object_store) self.assertEqual(rv.etag, self.headers['Etag']) self.assert_calls() diff --git a/openstack/tests/unit/object_store/v1/test_proxy.py b/openstack/tests/unit/object_store/v1/test_proxy.py index f6634046a..8c56328ec 100644 --- a/openstack/tests/unit/object_store/v1/test_proxy.py +++ b/openstack/tests/unit/object_store/v1/test_proxy.py @@ -280,7 +280,7 @@ class Test_download_object(base_test_object.BaseTestObject): content=self.the_data)]) def test_download(self): - data = self.conn.object_store.download_object( + data = self.cloud.object_store.download_object( self.object, container=self.container) self.assertEqual(data, self.the_data) @@ -288,7 +288,7 @@ class Test_download_object(base_test_object.BaseTestObject): def test_stream(self): chunk_size = 2 - for index, chunk in enumerate(self.conn.object_store.stream_object( + for index, chunk in enumerate(self.cloud.object_store.stream_object( self.object, container=self.container, chunk_size=chunk_size)): chunk_len = len(chunk) diff --git a/openstack/tests/unit/test_connection.py b/openstack/tests/unit/test_connection.py index 10904a5a1..f27ce67b9 100644 --- a/openstack/tests/unit/test_connection.py +++ b/openstack/tests/unit/test_connection.py @@ -235,11 +235,11 @@ class TestNetworkConnection(base.TestCase): self.use_keystone_v3(catalog='catalog-v3-suffix.json') self.assertEqual( 'openstack.network.v2._proxy', - self.conn.network.__class__.__module__) + self.cloud.network.__class__.__module__) self.assert_calls() self.assertEqual( "https://network.example.com/v2.0", - self.conn.network.get_endpoint()) + self.cloud.network.get_endpoint()) class TestNetworkConnectionSuffix(base.TestCase): @@ -249,21 +249,21 @@ class TestNetworkConnectionSuffix(base.TestCase): def test_network_proxy(self): self.assertEqual( 'openstack.network.v2._proxy', - self.conn.network.__class__.__module__) + self.cloud.network.__class__.__module__) self.assert_calls() self.assertEqual( "https://network.example.com/v2.0", - self.conn.network.get_endpoint()) + self.cloud.network.get_endpoint()) class TestAuthorize(base.TestCase): def test_authorize_works(self): - res = self.conn.authorize() + res = self.cloud.authorize() self.assertEqual('KeystoneToken-1', res) def test_authorize_failure(self): self.use_broken_keystone() self.assertRaises(openstack.exceptions.HttpException, - self.conn.authorize) + self.cloud.authorize)