Merge "Compare API call body in assertions with respect to values"

This commit is contained in:
Zuul
2017-11-25 09:21:18 +00:00
committed by Gerrit Code Review
2 changed files with 6 additions and 28 deletions

View File

@@ -50,14 +50,7 @@ class FakeClient(object):
if body is not None: if body is not None:
actual = self.client.callstack[pos][2] actual = self.client.callstack[pos][2]
assert actual == body, "Expected %s; got %s" % (body, actual)
if isinstance(actual, dict) and isinstance(body, dict):
assert sorted(list(actual)) == sorted(list(body))
else:
assert actual == body, "Expected %(b)s; got %(a)s" % {
'b': body,
'a': actual
}
def assert_called_anytime(self, method, url, body=None, def assert_called_anytime(self, method, url, body=None,
clear_callstack=True): clear_callstack=True):

View File

@@ -520,10 +520,6 @@ class ShellTest(test_utils.TestCase):
'name': 'test-type-3', 'name': 'test-type-3',
'extra_specs': { 'extra_specs': {
'driver_handles_share_servers': False, 'driver_handles_share_servers': False,
'snapshot_support': True,
'create_share_from_snapshot_support': True,
'revert_to_snapshot_support': False,
'mount_snapshot_support': False,
}, },
'share_type_access:is_public': public 'share_type_access:is_public': public
} }
@@ -934,10 +930,6 @@ class ShellTest(test_utils.TestCase):
"share_type_access:is_public": True, "share_type_access:is_public": True,
"extra_specs": { "extra_specs": {
"driver_handles_share_servers": expected_bool, "driver_handles_share_servers": expected_bool,
"snapshot_support": True,
"create_share_from_snapshot_support": True,
"revert_to_snapshot_support": False,
"mount_snapshot_support": False,
} }
} }
} }
@@ -984,9 +976,6 @@ class ShellTest(test_utils.TestCase):
"extra_specs": { "extra_specs": {
"driver_handles_share_servers": False, "driver_handles_share_servers": False,
"snapshot_support": expected_bool, "snapshot_support": expected_bool,
"create_share_from_snapshot_support": True,
"revert_to_snapshot_support": False,
"mount_snapshot_support": False,
"replication_type": replication_type, "replication_type": replication_type,
} }
} }
@@ -1015,8 +1004,6 @@ class ShellTest(test_utils.TestCase):
"driver_handles_share_servers": False, "driver_handles_share_servers": False,
"snapshot_support": True, "snapshot_support": True,
"create_share_from_snapshot_support": expected_bool, "create_share_from_snapshot_support": expected_bool,
"revert_to_snapshot_support": False,
"mount_snapshot_support": False,
} }
} }
} }
@@ -1058,7 +1045,6 @@ class ShellTest(test_utils.TestCase):
"extra_specs": { "extra_specs": {
"driver_handles_share_servers": False, "driver_handles_share_servers": False,
"snapshot_support": True, "snapshot_support": True,
"create_share_from_snapshot_support": True,
"revert_to_snapshot_support": expected_bool, "revert_to_snapshot_support": expected_bool,
} }
} }
@@ -1093,7 +1079,6 @@ class ShellTest(test_utils.TestCase):
"extra_specs": { "extra_specs": {
"driver_handles_share_servers": False, "driver_handles_share_servers": False,
"snapshot_support": True, "snapshot_support": True,
"create_share_from_snapshot_support": True,
"revert_to_snapshot_support": False, "revert_to_snapshot_support": False,
"mount_snapshot_support": expected_bool, "mount_snapshot_support": expected_bool,
} }
@@ -1950,7 +1935,7 @@ class ShellTest(test_utils.TestCase):
def test_quota_update(self, cmd, expected_body): def test_quota_update(self, cmd, expected_body):
self.run_command('quota-update 1234 %s' % cmd) self.run_command('quota-update 1234 %s' % cmd)
expected = {'quota_set': expected_body} expected = {'quota_set': dict(expected_body, tenant_id='1234')}
self.assert_called('PUT', '/quota-sets/1234', body=expected) self.assert_called('PUT', '/quota-sets/1234', body=expected)
@ddt.data( @ddt.data(
@@ -2095,7 +2080,7 @@ class ShellTest(test_utils.TestCase):
expected = { expected = {
'share_group': { 'share_group': {
'name': 'fake_sg', 'name': 'fake_sg',
'description': 'my_sg', 'description': 'my_group',
'availability_zone': 'fake_az', 'availability_zone': 'fake_az',
'share_group_type_id': '2345', 'share_group_type_id': '2345',
'share_network_id': '3456', 'share_network_id': '3456',
@@ -2707,12 +2692,12 @@ class ShellTest(test_utils.TestCase):
expected = {'migration_start': { expected = {'migration_start': {
'host': 'host@backend#pool', 'host': 'host@backend#pool',
'force_host_assisted_migration': 'True', 'force_host_assisted_migration': 'True',
'preserve-metadata': 'False', 'preserve_metadata': 'False',
'writable': 'False', 'writable': 'False',
'nondisruptive': 'True', 'nondisruptive': 'True',
'preserve_snapshots': 'True', 'preserve_snapshots': 'True',
'new_share_network_id': '1111', 'new_share_network_id': 1111,
'new_share_type_id': '1' 'new_share_type_id': 1,
}} }}
self.assert_called('POST', '/shares/1234/action', body=expected) self.assert_called('POST', '/shares/1234/action', body=expected)