Fix argument order for assertEqual to (expected, observed)
assertEqual expects that the arguments provided to it should be (expected, observed). If a particluar order is kept as a convention, then it helps to provide a cleaner message to the developer if Unit Tests fail. The following patch fixes this issue. TrivialFix Change-Id: I07b78383ef38731140143c91ae3a902bea55eebb Closes-Bug: #1259292
This commit is contained in:
parent
a678c26dee
commit
fd1e846a60
|
@ -213,7 +213,7 @@ class TestCinderStore(base.StoreBaseTest,
|
|||
|
||||
@contextlib.contextmanager
|
||||
def fake_open(client, volume, mode):
|
||||
self.assertEqual(mode, 'rb')
|
||||
self.assertEqual('rb', mode)
|
||||
yield volume_file
|
||||
|
||||
with mock.patch.object(cinder, 'get_cinderclient') as mock_cc, \
|
||||
|
@ -249,7 +249,7 @@ class TestCinderStore(base.StoreBaseTest,
|
|||
uri = 'cinder://%s' % fake_volume_uuid
|
||||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
image_size = self.store.get_size(loc, context=self.context)
|
||||
self.assertEqual(image_size, fake_volume.size * units.Gi)
|
||||
self.assertEqual(fake_volume.size * units.Gi, image_size)
|
||||
|
||||
def _test_cinder_add(self, fake_volume, volume_file, size_kb=5,
|
||||
verifier=None):
|
||||
|
@ -265,7 +265,7 @@ class TestCinderStore(base.StoreBaseTest,
|
|||
|
||||
@contextlib.contextmanager
|
||||
def fake_open(client, volume, mode):
|
||||
self.assertEqual(mode, 'wb')
|
||||
self.assertEqual('wb', mode)
|
||||
yield volume_file
|
||||
|
||||
with mock.patch.object(cinder, 'get_cinderclient') as mock_cc, \
|
||||
|
|
|
@ -127,7 +127,7 @@ class TestStore(base.StoreBaseTest,
|
|||
for chunk in image_file:
|
||||
data += chunk
|
||||
|
||||
self.assertEqual(data, file_contents)
|
||||
self.assertEqual(file_contents, data)
|
||||
|
||||
data = b""
|
||||
chunk_size = 5
|
||||
|
@ -137,8 +137,8 @@ class TestStore(base.StoreBaseTest,
|
|||
for chunk in image_file:
|
||||
data += chunk
|
||||
|
||||
self.assertEqual(data, b'00000')
|
||||
self.assertEqual(image_size, chunk_size)
|
||||
self.assertEqual(b'00000', data)
|
||||
self.assertEqual(chunk_size, image_size)
|
||||
|
||||
def test_get_non_existing(self):
|
||||
"""
|
||||
|
@ -402,8 +402,8 @@ class TestStore(base.StoreBaseTest,
|
|||
|
||||
expected_priority_map = {100: [store_map[0]], 200: [store_map[1]]}
|
||||
expected_priority_list = [200, 100]
|
||||
self.assertEqual(self.store.priority_data_map, expected_priority_map)
|
||||
self.assertEqual(self.store.priority_list, expected_priority_list)
|
||||
self.assertEqual(expected_priority_map, self.store.priority_data_map)
|
||||
self.assertEqual(expected_priority_list, self.store.priority_list)
|
||||
|
||||
def test_configure_add_with_metadata_file_success(self):
|
||||
metadata = {'id': 'asdf1234',
|
||||
|
|
|
@ -54,7 +54,7 @@ class TestHttpStore(base.StoreBaseTest,
|
|||
'ho', 'rt', ' a', 'nd', ' s', 'to', 'ut', '\n']
|
||||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
(image_file, image_size) = self.store.get(loc)
|
||||
self.assertEqual(image_size, 31)
|
||||
self.assertEqual(31, image_size)
|
||||
chunks = [c for c in image_file]
|
||||
self.assertEqual(expected_returns, chunks)
|
||||
|
||||
|
@ -86,10 +86,10 @@ class TestHttpStore(base.StoreBaseTest,
|
|||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
(image_file, image_size) = self.store.get(loc)
|
||||
self.assertEqual(0, len(responses))
|
||||
self.assertEqual(image_size, 31)
|
||||
self.assertEqual(31, image_size)
|
||||
|
||||
chunks = [c for c in image_file]
|
||||
self.assertEqual(chunks, expected_returns)
|
||||
self.assertEqual(expected_returns, chunks)
|
||||
|
||||
def test_http_get_max_redirects(self):
|
||||
self._mock_requests()
|
||||
|
|
|
@ -371,6 +371,6 @@ class TestStore(base.StoreBaseTest,
|
|||
old_format=False, features=3)
|
||||
|
||||
def tearDown(self):
|
||||
self.assertEqual(self.called_commands_actual,
|
||||
self.called_commands_expected)
|
||||
self.assertEqual(self.called_commands_expected,
|
||||
self.called_commands_actual)
|
||||
super(TestStore, self).tearDown()
|
||||
|
|
|
@ -297,7 +297,7 @@ class TestStore(base.StoreBaseTest,
|
|||
conf=self.conf)
|
||||
(image_s3, image_size) = self.store.get(loc)
|
||||
|
||||
self.assertEqual(image_size, FIVE_KB)
|
||||
self.assertEqual(FIVE_KB, image_size)
|
||||
|
||||
expected_data = b"*" * FIVE_KB
|
||||
data = b""
|
||||
|
|
|
@ -144,7 +144,7 @@ class TestSheepdogStore(base.StoreBaseTest,
|
|||
sheepdog.StoreLocation,
|
||||
self.conf, store_specs=self.store_specs)
|
||||
ret = self.store.get(loc)
|
||||
self.assertEqual(ret[1], 1000)
|
||||
self.assertEqual(1000, ret[1])
|
||||
|
||||
def test_partial_get(self):
|
||||
loc = location.Location('test_sheepdog_store', sheepdog.StoreLocation,
|
||||
|
@ -163,7 +163,7 @@ class TestSheepdogStore(base.StoreBaseTest,
|
|||
sheepdog.StoreLocation,
|
||||
self.conf, store_specs=self.store_specs)
|
||||
ret = self.store.get_size(loc)
|
||||
self.assertEqual(ret, 1000)
|
||||
self.assertEqual(1000, ret)
|
||||
|
||||
def test_delete(self):
|
||||
called_commands = []
|
||||
|
@ -179,7 +179,7 @@ class TestSheepdogStore(base.StoreBaseTest,
|
|||
sheepdog.StoreLocation,
|
||||
self.conf, store_specs=self.store_specs)
|
||||
self.store.delete(loc)
|
||||
self.assertEqual(called_commands, ['list -r', 'delete'])
|
||||
self.assertEqual(['list -r', 'delete'], called_commands)
|
||||
|
||||
def test_add_with_verifier(self):
|
||||
"""Test that 'verifier.update' is called when verifier is provided."""
|
||||
|
|
|
@ -252,7 +252,7 @@ class SwiftTests(object):
|
|||
self.swift_store_user, FAKE_UUID)
|
||||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
image_size = self.store.get_size(loc)
|
||||
self.assertEqual(image_size, 5120)
|
||||
self.assertEqual(5120, image_size)
|
||||
|
||||
def test_get_size_with_multi_tenant_on(self):
|
||||
"""Test that single tenant uris work with multi tenant on."""
|
||||
|
@ -262,7 +262,7 @@ class SwiftTests(object):
|
|||
# NOTE(markwash): ensure the image is found
|
||||
ctxt = mock.MagicMock()
|
||||
size = backend.get_size_from_backend(uri, context=ctxt)
|
||||
self.assertEqual(size, 5120)
|
||||
self.assertEqual(5120, size)
|
||||
|
||||
def test_get(self):
|
||||
"""Test a "normal" retrieval of an image in chunks."""
|
||||
|
@ -270,7 +270,7 @@ class SwiftTests(object):
|
|||
self.swift_store_user, FAKE_UUID)
|
||||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
(image_swift, image_size) = self.store.get(loc)
|
||||
self.assertEqual(image_size, 5120)
|
||||
self.assertEqual(5120, image_size)
|
||||
|
||||
expected_data = b"*" * FIVE_KB
|
||||
data = b""
|
||||
|
@ -299,7 +299,7 @@ class SwiftTests(object):
|
|||
self.store,
|
||||
loc.store_location,
|
||||
manager)
|
||||
self.assertEqual(image_size, 5120)
|
||||
self.assertEqual(5120, image_size)
|
||||
|
||||
expected_data = b"*" * FIVE_KB
|
||||
data = b""
|
||||
|
@ -320,7 +320,7 @@ class SwiftTests(object):
|
|||
|
||||
ctxt = mock.MagicMock()
|
||||
(image_swift, image_size) = self.store.get(loc, context=ctxt)
|
||||
self.assertEqual(image_size, 5120)
|
||||
self.assertEqual(5120, image_size)
|
||||
|
||||
expected_data = b"*" * FIVE_KB
|
||||
data = b""
|
||||
|
@ -369,7 +369,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_swift_size, size)
|
||||
self.assertEqual(expected_checksum, checksum)
|
||||
# Expecting a single object to be created on Swift i.e. no chunking.
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 1)
|
||||
self.assertEqual(1, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location, conf=self.conf)
|
||||
(new_image_swift, new_image_size) = self.store.get(loc)
|
||||
|
@ -445,7 +445,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_location, loc)
|
||||
self.assertEqual(expected_swift_size, size)
|
||||
self.assertEqual(expected_checksum, checksum)
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 1)
|
||||
self.assertEqual(1, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location,
|
||||
conf=self.conf)
|
||||
|
@ -488,7 +488,7 @@ class SwiftTests(object):
|
|||
self.assertIn("container noexist does not exist in Swift",
|
||||
encodeutils.exception_to_unicode(e))
|
||||
self.assertTrue(exception_caught)
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 0)
|
||||
self.assertEqual(0, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
@mock.patch('glance_store._drivers.swift.utils'
|
||||
'.is_multiple_swift_store_accounts_enabled',
|
||||
|
@ -524,7 +524,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_location, loc)
|
||||
self.assertEqual(expected_swift_size, size)
|
||||
self.assertEqual(expected_checksum, checksum)
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 1)
|
||||
self.assertEqual(1, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location, conf=self.conf)
|
||||
(new_image_swift, new_image_size) = self.store.get(loc)
|
||||
|
@ -571,7 +571,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_location, loc)
|
||||
self.assertEqual(expected_swift_size, size)
|
||||
self.assertEqual(expected_checksum, checksum)
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 1)
|
||||
self.assertEqual(1, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location, conf=self.conf)
|
||||
(new_image_swift, new_image_size) = self.store.get(loc)
|
||||
|
@ -621,7 +621,7 @@ class SwiftTests(object):
|
|||
expected_msg = expected_msg % expected_container
|
||||
self.assertIn(expected_msg, encodeutils.exception_to_unicode(e))
|
||||
self.assertTrue(exception_caught)
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 0)
|
||||
self.assertEqual(0, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
@mock.patch('glance_store._drivers.swift.utils'
|
||||
'.is_multiple_swift_store_accounts_enabled',
|
||||
|
@ -651,8 +651,8 @@ class SwiftTests(object):
|
|||
self.store.large_object_size = orig_max_size
|
||||
|
||||
# Confirm verifier update called expected number of times
|
||||
self.assertEqual(verifier.update.call_count,
|
||||
2 * swift_size / custom_size)
|
||||
self.assertEqual(2 * swift_size / custom_size,
|
||||
verifier.update.call_count)
|
||||
|
||||
# define one chunk of the contents
|
||||
swift_contents_piece = base_byte * (custom_size // 8)
|
||||
|
@ -698,7 +698,7 @@ class SwiftTests(object):
|
|||
self.store.large_object_size = orig_max_size
|
||||
|
||||
# Confirm verifier update called expected number of times
|
||||
self.assertEqual(verifier.update.call_count, 2)
|
||||
self.assertEqual(2, verifier.update.call_count)
|
||||
|
||||
# define one chunk of the contents
|
||||
swift_contents_piece = base_byte * (swift_size // 8)
|
||||
|
@ -791,7 +791,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_checksum, checksum)
|
||||
# Expecting 6 objects to be created on Swift -- 5 chunks and 1
|
||||
# manifest.
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 6)
|
||||
self.assertEqual(6, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location, conf=self.conf)
|
||||
(new_image_swift, new_image_size) = self.store.get(loc)
|
||||
|
@ -848,7 +848,7 @@ class SwiftTests(object):
|
|||
self.assertEqual(expected_swift_size, size)
|
||||
self.assertEqual(expected_checksum, checksum)
|
||||
# Expecting 6 calls to put_object -- 5 chunks, and the manifest.
|
||||
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 6)
|
||||
self.assertEqual(6, SWIFT_PUT_OBJECT_CALLS)
|
||||
|
||||
loc = location.get_location_from_uri(expected_location, conf=self.conf)
|
||||
(new_image_swift, new_image_size) = self.store.get(loc)
|
||||
|
@ -1048,7 +1048,7 @@ class SwiftTests(object):
|
|||
|
||||
self.store.delete(loc, connection=conn)
|
||||
# Expecting 6 delete calls, 5 for the segments and 1 for the manifest
|
||||
self.assertEqual(SWIFT_DELETE_OBJECT_CALLS, 6)
|
||||
self.assertEqual(6, SWIFT_DELETE_OBJECT_CALLS)
|
||||
|
||||
def test_read_acl_public(self):
|
||||
"""
|
||||
|
@ -1063,8 +1063,7 @@ class SwiftTests(object):
|
|||
store.set_acls(loc, public=True, context=ctxt)
|
||||
container_headers = swiftclient.client.head_container('x', 'y',
|
||||
'glance')
|
||||
self.assertEqual(container_headers['X-Container-Read'],
|
||||
"*:*")
|
||||
self.assertEqual("*:*", container_headers['X-Container-Read'])
|
||||
|
||||
def test_read_acl_tenants(self):
|
||||
"""
|
||||
|
@ -1080,8 +1079,8 @@ class SwiftTests(object):
|
|||
store.set_acls(loc, read_tenants=read_tenants, context=ctxt)
|
||||
container_headers = swiftclient.client.head_container('x', 'y',
|
||||
'glance')
|
||||
self.assertEqual(container_headers['X-Container-Read'],
|
||||
'matt:*,mark:*')
|
||||
self.assertEqual('matt:*,mark:*', container_headers[
|
||||
'X-Container-Read'])
|
||||
|
||||
def test_write_acls(self):
|
||||
"""
|
||||
|
@ -1097,8 +1096,8 @@ class SwiftTests(object):
|
|||
store.set_acls(loc, write_tenants=read_tenants, context=ctxt)
|
||||
container_headers = swiftclient.client.head_container('x', 'y',
|
||||
'glance')
|
||||
self.assertEqual(container_headers['X-Container-Write'],
|
||||
'frank:*,jim:*')
|
||||
self.assertEqual('frank:*,jim:*', container_headers[
|
||||
'X-Container-Write'])
|
||||
|
||||
@mock.patch("glance_store._drivers.swift."
|
||||
"connection_manager.MultiTenantConnectionManager")
|
||||
|
@ -1338,52 +1337,52 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest):
|
|||
|
||||
def test_basic_connection(self):
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.authurl, 'https://example.com/v2/')
|
||||
self.assertEqual(connection.auth_version, '2')
|
||||
self.assertEqual(connection.user, 'user1')
|
||||
self.assertEqual(connection.tenant_name, 'tenant')
|
||||
self.assertEqual(connection.key, 'key1')
|
||||
self.assertEqual('https://example.com/v2/', connection.authurl)
|
||||
self.assertEqual('2', connection.auth_version)
|
||||
self.assertEqual('user1', connection.user)
|
||||
self.assertEqual('tenant', connection.tenant_name)
|
||||
self.assertEqual('key1', connection.key)
|
||||
self.assertIsNone(connection.preauthurl)
|
||||
self.assertFalse(connection.insecure)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'})
|
||||
self.assertEqual({'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_connection_with_conf_endpoint(self):
|
||||
ctx = mock.MagicMock(user='tenant:user1', tenant='tenant')
|
||||
self.config(swift_store_endpoint='https://internal.com')
|
||||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location, context=ctx)
|
||||
self.assertEqual(connection.authurl, 'https://example.com/v2/')
|
||||
self.assertEqual(connection.auth_version, '2')
|
||||
self.assertEqual(connection.user, 'user1')
|
||||
self.assertEqual(connection.tenant_name, 'tenant')
|
||||
self.assertEqual(connection.key, 'key1')
|
||||
self.assertEqual(connection.preauthurl, 'https://internal.com')
|
||||
self.assertEqual('https://example.com/v2/', connection.authurl)
|
||||
self.assertEqual('2', connection.auth_version)
|
||||
self.assertEqual('user1', connection.user)
|
||||
self.assertEqual('tenant', connection.tenant_name)
|
||||
self.assertEqual('key1', connection.key)
|
||||
self.assertEqual('https://internal.com', connection.preauthurl)
|
||||
self.assertFalse(connection.insecure)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'})
|
||||
self.assertEqual({'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_connection_with_conf_endpoint_no_context(self):
|
||||
self.config(swift_store_endpoint='https://internal.com')
|
||||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.authurl, 'https://example.com/v2/')
|
||||
self.assertEqual(connection.auth_version, '2')
|
||||
self.assertEqual(connection.user, 'user1')
|
||||
self.assertEqual(connection.tenant_name, 'tenant')
|
||||
self.assertEqual(connection.key, 'key1')
|
||||
self.assertEqual(connection.preauthurl, 'https://internal.com')
|
||||
self.assertEqual('https://example.com/v2/', connection.authurl)
|
||||
self.assertEqual('2', connection.auth_version)
|
||||
self.assertEqual('user1', connection.user)
|
||||
self.assertEqual('tenant', connection.tenant_name)
|
||||
self.assertEqual('key1', connection.key)
|
||||
self.assertEqual('https://internal.com', connection.preauthurl)
|
||||
self.assertFalse(connection.insecure)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'})
|
||||
self.assertEqual({'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_connection_with_no_trailing_slash(self):
|
||||
self.location.auth_or_store_url = 'example.com/v2'
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.authurl, 'https://example.com/v2/')
|
||||
self.assertEqual('https://example.com/v2/', connection.authurl)
|
||||
|
||||
def test_connection_insecure(self):
|
||||
self.config(swift_store_auth_insecure=True)
|
||||
|
@ -1396,8 +1395,8 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest):
|
|||
self.store.configure()
|
||||
self.location.user = 'auth_v1_user'
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.auth_version, '1')
|
||||
self.assertEqual(connection.user, 'auth_v1_user')
|
||||
self.assertEqual('1', connection.auth_version)
|
||||
self.assertEqual('auth_v1_user', connection.user)
|
||||
self.assertIsNone(connection.tenant_name)
|
||||
|
||||
def test_connection_invalid_user(self):
|
||||
|
@ -1416,26 +1415,26 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest):
|
|||
self.config(swift_store_region='Sahara')
|
||||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'region_name': 'Sahara',
|
||||
self.assertEqual({'region_name': 'Sahara',
|
||||
'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL'})
|
||||
'endpoint_type': 'publicURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_connection_with_service_type(self):
|
||||
self.config(swift_store_service_type='shoe-store')
|
||||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'shoe-store',
|
||||
'endpoint_type': 'publicURL'})
|
||||
self.assertEqual({'service_type': 'shoe-store',
|
||||
'endpoint_type': 'publicURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_connection_with_endpoint_type(self):
|
||||
self.config(swift_store_endpoint_type='internalURL')
|
||||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'object-store',
|
||||
'endpoint_type': 'internalURL'})
|
||||
self.assertEqual({'service_type': 'object-store',
|
||||
'endpoint_type': 'internalURL'},
|
||||
connection.os_options)
|
||||
|
||||
def test_bad_location_uri(self):
|
||||
self.store.configure()
|
||||
|
@ -1496,13 +1495,13 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest):
|
|||
self.store.configure()
|
||||
connection = self.store.get_connection(self.location)
|
||||
self.assertEqual('3', connection.auth_version)
|
||||
self.assertEqual(connection.os_options,
|
||||
{'service_type': 'object-store',
|
||||
self.assertEqual({'service_type': 'object-store',
|
||||
'endpoint_type': 'publicURL',
|
||||
'user_domain_id': 'default',
|
||||
'user_domain_name': 'ignored',
|
||||
'project_domain_id': 'default',
|
||||
'project_domain_name': 'ignored'})
|
||||
'project_domain_name': 'ignored'},
|
||||
connection.os_options)
|
||||
|
||||
|
||||
class TestMultiTenantStoreConnections(base.StoreBaseTest):
|
||||
|
@ -1526,13 +1525,13 @@ class TestMultiTenantStoreConnections(base.StoreBaseTest):
|
|||
connection = self.store.get_connection(self.location,
|
||||
context=self.context)
|
||||
self.assertIsNone(connection.authurl)
|
||||
self.assertEqual(connection.auth_version, '1')
|
||||
self.assertEqual('1', connection.auth_version)
|
||||
self.assertIsNone(connection.user)
|
||||
self.assertIsNone(connection.tenant_name)
|
||||
self.assertIsNone(connection.key)
|
||||
self.assertEqual(connection.preauthurl, 'https://example.com')
|
||||
self.assertEqual(connection.preauthtoken, '0123')
|
||||
self.assertEqual(connection.os_options, {})
|
||||
self.assertEqual('https://example.com', connection.preauthurl)
|
||||
self.assertEqual('0123', connection.preauthtoken)
|
||||
self.assertEqual({}, connection.os_options)
|
||||
|
||||
def test_connection_with_endpoint_from_catalog(self):
|
||||
self.store.configure()
|
||||
|
@ -1552,13 +1551,13 @@ class TestMultiTenantStoreConnections(base.StoreBaseTest):
|
|||
connection = self.store.get_connection(self.location,
|
||||
context=self.context)
|
||||
self.assertIsNone(connection.authurl)
|
||||
self.assertEqual(connection.auth_version, '1')
|
||||
self.assertEqual('1', connection.auth_version)
|
||||
self.assertIsNone(connection.user)
|
||||
self.assertIsNone(connection.tenant_name)
|
||||
self.assertIsNone(connection.key)
|
||||
self.assertEqual(connection.preauthurl, 'https://scexample.com')
|
||||
self.assertEqual(connection.preauthtoken, '0123')
|
||||
self.assertEqual(connection.os_options, {})
|
||||
self.assertEqual('https://scexample.com', connection.preauthurl)
|
||||
self.assertEqual('0123', connection.preauthtoken)
|
||||
self.assertEqual({}, connection.os_options)
|
||||
|
||||
def test_connection_with_no_endpoint_found(self):
|
||||
self.store.configure()
|
||||
|
@ -1579,13 +1578,13 @@ class TestMultiTenantStoreConnections(base.StoreBaseTest):
|
|||
connection = self.store.get_connection(self.location,
|
||||
context=self.context)
|
||||
self.assertIsNone(connection.authurl)
|
||||
self.assertEqual(connection.auth_version, '1')
|
||||
self.assertEqual('1', connection.auth_version)
|
||||
self.assertIsNone(connection.user)
|
||||
self.assertIsNone(connection.tenant_name)
|
||||
self.assertIsNone(connection.key)
|
||||
self.assertEqual(connection.preauthurl, 'https://example.com')
|
||||
self.assertEqual(connection.preauthtoken, '0123')
|
||||
self.assertEqual(connection.os_options, {})
|
||||
self.assertEqual('https://example.com', connection.preauthurl)
|
||||
self.assertEqual('0123', connection.preauthtoken)
|
||||
self.assertEqual({}, connection.os_options)
|
||||
|
||||
|
||||
class TestMultiTenantStoreContext(base.StoreBaseTest):
|
||||
|
@ -1698,12 +1697,12 @@ class TestCreatingLocations(base.StoreBaseTest):
|
|||
store = swift.SingleTenantStore(self.conf)
|
||||
store.configure()
|
||||
location = store.create_location('image-id')
|
||||
self.assertEqual(location.scheme, 'swift+https')
|
||||
self.assertEqual(location.swift_url, 'https://example.com')
|
||||
self.assertEqual(location.container, 'container')
|
||||
self.assertEqual(location.obj, 'image-id')
|
||||
self.assertEqual(location.user, 'tenant:user1')
|
||||
self.assertEqual(location.key, 'key1')
|
||||
self.assertEqual('swift+https', location.scheme)
|
||||
self.assertEqual('https://example.com', location.swift_url)
|
||||
self.assertEqual('container', location.container)
|
||||
self.assertEqual('image-id', location.obj)
|
||||
self.assertEqual('tenant:user1', location.user)
|
||||
self.assertEqual('key1', location.key)
|
||||
|
||||
def test_single_tenant_location_http(self):
|
||||
conf_file = "glance-swift.conf"
|
||||
|
@ -1716,18 +1715,18 @@ class TestCreatingLocations(base.StoreBaseTest):
|
|||
store = swift.SingleTenantStore(self.conf)
|
||||
store.configure()
|
||||
location = store.create_location('image-id')
|
||||
self.assertEqual(location.scheme, 'swift+http')
|
||||
self.assertEqual(location.swift_url, 'http://example.com')
|
||||
self.assertEqual('swift+http', location.scheme)
|
||||
self.assertEqual('http://example.com', location.swift_url)
|
||||
|
||||
def test_multi_tenant_location(self):
|
||||
self.config(swift_store_container='container')
|
||||
store = swift.MultiTenantStore(self.conf)
|
||||
store.configure()
|
||||
location = store.create_location('image-id', context=self.ctxt)
|
||||
self.assertEqual(location.scheme, 'swift+https')
|
||||
self.assertEqual(location.swift_url, 'https://some_endpoint')
|
||||
self.assertEqual(location.container, 'container_image-id')
|
||||
self.assertEqual(location.obj, 'image-id')
|
||||
self.assertEqual('swift+https', location.scheme)
|
||||
self.assertEqual('https://some_endpoint', location.swift_url)
|
||||
self.assertEqual('container_image-id', location.container)
|
||||
self.assertEqual('image-id', location.obj)
|
||||
self.assertIsNone(location.user)
|
||||
self.assertIsNone(location.key)
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class TestStore(base.StoreBaseTest,
|
|||
with mock.patch('requests.Session.request') as HttpConn:
|
||||
HttpConn.return_value = utils.fake_response()
|
||||
(image_file, image_size) = self.store.get(loc)
|
||||
self.assertEqual(image_size, expected_image_size)
|
||||
self.assertEqual(expected_image_size, image_size)
|
||||
chunks = [c for c in image_file]
|
||||
self.assertEqual(expected_returns, chunks)
|
||||
|
||||
|
@ -594,7 +594,7 @@ class TestStore(base.StoreBaseTest,
|
|||
with mock.patch('requests.Session.request') as HttpConn:
|
||||
HttpConn.side_effect = getresponse
|
||||
(image_file, image_size) = self.store.get(loc)
|
||||
self.assertEqual(image_size, expected_image_size)
|
||||
self.assertEqual(expected_image_size, image_size)
|
||||
chunks = [c for c in image_file]
|
||||
self.assertEqual(expected_returns, chunks)
|
||||
|
||||
|
|
Loading…
Reference in New Issue