Browse Source

Replace assertDictMatch with assertDictEqual method in tests

assertDictMatch was introduced for Python 2.6 only.
Python 2.7+ contains assertDictEqual.

Closes-Bug: #1646433
Change-Id: I41738cc0bd90656508fc6ff390072b55130cc6fc
changes/90/795990/11
songwenping 8 months ago
committed by archanaserver
parent
commit
8ee8ee15b1
  1. 63
      manila/test.py
  2. 6
      manila/tests/api/test_common.py
  3. 4
      manila/tests/api/v1/test_limits.py
  4. 10
      manila/tests/api/v1/test_scheduler_stats.py
  5. 2
      manila/tests/api/v2/test_messages.py
  6. 4
      manila/tests/api/v2/test_share_types.py
  7. 8
      manila/tests/api/v2/test_shares.py
  8. 96
      manila/tests/db/sqlalchemy/test_api.py
  9. 6
      manila/tests/scheduler/drivers/test_filter.py
  10. 6
      manila/tests/scheduler/test_host_manager.py
  11. 2
      manila/tests/share/drivers/container/test_driver.py
  12. 10
      manila/tests/share/drivers/container/test_storage_helper.py
  13. 4
      manila/tests/share/drivers/infortrend/test_infortrend_nas.py
  14. 6
      manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py
  15. 28
      manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py
  16. 2
      manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py
  17. 2
      manila/tests/share/test_share_types.py
  18. 1
      tools/install_venv.py
  19. 4
      tools/install_venv_common.py

63
manila/test.py

@ -247,65 +247,7 @@ class TestCase(base_test.BaseTestCase):
self.addCleanup(patcher.stop)
return new_val
# Useful assertions
def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
"""Assert two dicts are equivalent.
This is a 'deep' match in the sense that it handles nested
dictionaries appropriately.
NOTE:
If you don't care (or don't know) a given value, you can specify
the string DONTCARE as the value. This will cause that dict-item
to be skipped.
"""
def raise_assertion(msg):
d1str = str(d1)
d2str = str(d2)
base_msg = ('Dictionaries do not match. %(msg)s d1: %(d1str)s '
'd2: %(d2str)s' %
{"msg": msg, "d1str": d1str, "d2str": d2str})
raise AssertionError(base_msg)
d1keys = set(d1.keys())
d2keys = set(d2.keys())
if d1keys != d2keys:
d1only = d1keys - d2keys
d2only = d2keys - d1keys
raise_assertion('Keys in d1 and not d2: %(d1only)s. '
'Keys in d2 and not d1: %(d2only)s' %
{"d1only": d1only, "d2only": d2only})
for key in d1keys:
d1value = d1[key]
d2value = d2[key]
try:
error = abs(float(d1value) - float(d2value))
within_tolerance = error <= tolerance
except (ValueError, TypeError):
# If both values aren't convertible to float, just ignore
# ValueError if arg is a str, TypeError if it's something else
# (like None)
within_tolerance = False
if hasattr(d1value, 'keys') and hasattr(d2value, 'keys'):
self.assertDictMatch(d1value, d2value)
elif 'DONTCARE' in (d1value, d2value):
continue
elif approx_equal and within_tolerance:
continue
elif d1value != d2value:
raise_assertion("d1['%(key)s']=%(d1value)s != "
"d2['%(key)s']=%(d2value)s" %
{
"key": key,
"d1value": d1value,
"d2value": d2value
})
def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001):
def assertDictListMatch(self, L1, L2):
"""Assert a list of dicts are equivalent."""
def raise_assertion(msg):
L1str = str(L1)
@ -323,8 +265,7 @@ class TestCase(base_test.BaseTestCase):
{"L1count": L1count, "L2count": L2count})
for d1, d2 in zip(L1, L2):
self.assertDictMatch(d1, d2, approx_equal=approx_equal,
tolerance=tolerance)
self.assertDictEqual(d1, d2)
def assertSubDictMatch(self, sub_dict, super_dict):
"""Assert a sub_dict is subset of super_dict."""

6
manila/tests/api/test_common.py

@ -279,7 +279,7 @@ class MiscFunctionsTest(test.TestCase):
actual_params = common.validate_public_share_policy(
'fake_context', api_params)
self.assertDictMatch(api_params, actual_params)
self.assertDictEqual(api_params, actual_params)
policy.check_policy.assert_not_called()
@ddt.data('foo', 123, 'all', None)
@ -313,7 +313,7 @@ class MiscFunctionsTest(test.TestCase):
actual_params = common.validate_public_share_policy(
'fake_context', api_params, api='update')
self.assertDictMatch({'is_public': False, 'size': '16'}, actual_params)
self.assertDictEqual({'is_public': False, 'size': '16'}, actual_params)
policy.check_policy.assert_called_once_with(
'fake_context', 'share', 'set_public_share', do_raise=False)
@ -325,7 +325,7 @@ class MiscFunctionsTest(test.TestCase):
actual_params = common.validate_public_share_policy(
'fake_context', api_params, api='update')
self.assertDictMatch({'is_public': True, 'size': '16'}, actual_params)
self.assertDictEqual({'is_public': True, 'size': '16'}, actual_params)
policy.check_policy.assert_called_once_with(
'fake_context', 'share', 'set_public_share', do_raise=False)

4
manila/tests/api/v1/test_limits.py

@ -846,7 +846,7 @@ class LimitsViewBuilderTest(test.TestCase):
output = self.view_builder.build(request,
self.rate_limits,
self.absolute_limits)
self.assertDictMatch(expected_limits, output)
self.assertDictEqual(expected_limits, output)
def test_build_limits_empty_limits(self):
request = fakes.HTTPRequest.blank('/')
@ -856,4 +856,4 @@ class LimitsViewBuilderTest(test.TestCase):
output = self.view_builder.build(request, rate_limits, abs_limits)
self.assertDictMatch(expected_limits, output)
self.assertDictEqual(expected_limits, output)

10
manila/tests/api/v1/test_scheduler_stats.py

@ -102,7 +102,7 @@ class SchedulerStatsControllerTestCase(test.TestCase):
]
}
self.assertDictMatch(result, expected)
self.assertDictEqual(result, expected)
mock_get_pools.assert_called_once_with(self.ctxt, filters={},
cached=True)
self.mock_policy_check.assert_called_once_with(
@ -149,7 +149,7 @@ class SchedulerStatsControllerTestCase(test.TestCase):
result = self.controller._pools(req, action, False)
self.assertDictMatch(result, expected_result)
self.assertDictEqual(result, expected_result)
mock_get_pools.assert_called_once_with(self.ctxt,
filters=expected_filters,
cached=True)
@ -212,7 +212,7 @@ class SchedulerStatsControllerTestCase(test.TestCase):
result = self.controller._pools(req, action, True)
self.assertDictMatch(result, expected_result)
self.assertDictEqual(result, expected_result)
mock_get_pools.assert_called_once_with(self.ctxt,
filters=expected_filters,
cached=True)
@ -274,7 +274,7 @@ class SchedulerStatsControllerTestCase(test.TestCase):
{'capabilities': {'snapshot_support': True}})
expected_filters.pop('share_type', None)
self.assertDictMatch(result, expected)
self.assertDictEqual(result, expected)
mock_get_pools.assert_called_once_with(self.ctxt,
filters=expected_filters,
cached=True)
@ -328,7 +328,7 @@ class SchedulerStatsControllerTestCase(test.TestCase):
],
}
self.assertDictMatch(expected, result)
self.assertDictEqual(expected, result)
mock_get_pools.assert_called_once_with(self.ctxt, filters={},
cached=True)
self.mock_policy_check.assert_called_once_with(

2
manila/tests/api/v2/test_messages.py

@ -169,7 +169,7 @@ class MessageApiTest(test.TestCase):
ex1 = self._expected_message_from_controller(msg1['id'])['message']
ex2 = self._expected_message_from_controller(msg2['id'])['message']
expected = {'messages': [ex1, ex2]}
self.assertDictMatch(expected, res_dict)
self.assertDictEqual(expected, res_dict)
def test_index_with_limit_and_offset(self):
msg2 = stubs.stub_message(fakes.get_fake_uuid())

4
manila/tests/api/v2/test_share_types.py

@ -364,7 +364,7 @@ class ShareTypesAPITest(test.TestCase):
if self.is_microversion_ge(version, '2.41'):
expected_share_type['description'] = 'description_test'
self.assertDictMatch(expected_share_type, output['share_type'])
self.assertDictEqual(expected_share_type, output['share_type'])
@ddt.data(
('1.0', 'os-share-type-access', True),
@ -427,7 +427,7 @@ class ShareTypesAPITest(test.TestCase):
expected_share_type['description'] = 'description_test'
for i in range(0, 10):
expected_share_type['id'] = 42 + i
self.assertDictMatch(expected_share_type,
self.assertDictEqual(expected_share_type,
output['share_types'][i])
@ddt.data(None, True, 'true', 'false', 'all')

8
manila/tests/api/v2/test_shares.py

@ -686,7 +686,7 @@ class ShareAPITest(test.TestCase):
expected = self._get_expected_share_detailed_response(
shr, version='2.7')
self.assertDictMatch(expected, res_dict)
self.assertDictEqual(expected, res_dict)
# pylint: disable=unsubscriptable-object
self.assertEqual("fakenetid",
create_mock.call_args[1]['share_network_id'])
@ -1352,7 +1352,7 @@ class ShareAPITest(test.TestCase):
res_dict = self.controller.create(req, body)
expected = self._get_expected_share_detailed_response(
shr, version='2.7')
self.assertDictMatch(expected, res_dict)
self.assertDictEqual(expected, res_dict)
# pylint: disable=unsubscriptable-object
self.assertEqual(parent_share_net,
create_mock.call_args[1]['share_network_id'])
@ -1443,7 +1443,7 @@ class ShareAPITest(test.TestCase):
res_dict = self.controller.show(req, '1')
self.assertDictMatch(expected, res_dict)
self.assertDictEqual(expected, res_dict)
def test_share_show_with_share_group_earlier_version(self):
req = fakes.HTTPRequest.blank(
@ -1452,7 +1452,7 @@ class ShareAPITest(test.TestCase):
res_dict = self.controller.show(req, '1')
self.assertDictMatch(expected, res_dict)
self.assertDictEqual(expected, res_dict)
def test_share_show_with_share_type_name(self):
req = fakes.HTTPRequest.blank('/v2/fake/shares/1', version='2.6')

96
manila/tests/db/sqlalchemy/test_api.py

@ -1065,7 +1065,7 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
def test_share_group_get(self):
share_group = db_utils.create_share_group()
self.assertDictMatch(
self.assertDictEqual(
dict(share_group),
dict(db_api.share_group_get(self.ctxt, share_group['id'])))
@ -1096,7 +1096,7 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
share_groups = db_api.share_group_get_all(self.ctxt, detailed=True)
self.assertEqual(1, len(share_groups))
self.assertDictMatch(dict(expected_share_group), dict(share_groups[0]))
self.assertDictEqual(dict(expected_share_group), dict(share_groups[0]))
def test_share_group_get_all_by_host(self):
fake_host = 'my_fake_host'
@ -1122,7 +1122,7 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
self.assertEqual(1, len(share_groups))
share_group = share_groups[0]
self.assertDictMatch(dict(expected_share_group), dict(share_group))
self.assertDictEqual(dict(expected_share_group), dict(share_group))
self.assertEqual(fake_host, share_group['host'])
def test_share_group_get_all_by_project(self):
@ -1167,7 +1167,7 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
self.assertEqual(1, len(groups))
group = groups[0]
self.assertDictMatch(dict(expected_group), dict(group))
self.assertDictEqual(dict(expected_group), dict(group))
self.assertEqual(fake_project, group['project_id'])
@ddt.data(({'name': 'fo'}, 0), ({'description': 'd'}, 0),
@ -1191,10 +1191,10 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
self.assertEqual(group_number, len(groups))
if group_number == 1:
self.assertDictMatch(dict(expected_group1), dict(groups[0]))
self.assertDictEqual(dict(expected_group1), dict(groups[0]))
elif group_number == 2:
self.assertDictMatch(dict(expected_group1), dict(groups[1]))
self.assertDictMatch(dict(expected_group2), dict(groups[0]))
self.assertDictEqual(dict(expected_group1), dict(groups[1]))
self.assertDictEqual(dict(expected_group2), dict(groups[0]))
def test_share_group_update(self):
fake_name = "my_fake_name"
@ -1238,11 +1238,15 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
def test_share_group_snapshot_get(self):
sg = db_utils.create_share_group()
sg_snap = db_utils.create_share_group_snapshot(sg['id'])
sg_snap = dict(db_utils.create_share_group_snapshot(sg['id']))
sg_snap_source_group = sg_snap.pop('share_group', {})
get_sg_snap = dict(
db_api.share_group_snapshot_get(self.ctxt, sg_snap['id']))
get_sg_snap_source_group = get_sg_snap.pop('share_group', {})
self.assertDictMatch(
dict(sg_snap),
dict(db_api.share_group_snapshot_get(self.ctxt, sg_snap['id'])))
self.assertDictEqual(
dict(sg_snap_source_group), dict(get_sg_snap_source_group))
self.assertDictEqual(sg_snap, get_sg_snap)
def test_share_group_snapshot_get_all(self):
sg = db_utils.create_share_group()
@ -1258,13 +1262,17 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
def test_share_group_snapshot_get_all_with_detail(self):
sg = db_utils.create_share_group()
expected_sg_snap = db_utils.create_share_group_snapshot(sg['id'])
expected_sg_snap = dict(db_utils.create_share_group_snapshot(sg['id']))
sg_snap_source_group = expected_sg_snap.pop('share_group', {})
snaps = db_api.share_group_snapshot_get_all(self.ctxt, detailed=True)
self.assertEqual(1, len(snaps))
snap = snaps[0]
self.assertDictMatch(dict(expected_sg_snap), dict(snap))
actual_sg_snap = dict(snaps[0])
get_sg_snap_source = actual_sg_snap.pop('share_group', {})
self.assertDictEqual(
dict(sg_snap_source_group), dict(get_sg_snap_source))
self.assertDictEqual(expected_sg_snap, actual_sg_snap)
def test_share_group_snapshot_get_all_by_project(self):
fake_project = uuidutils.generate_uuid()
@ -1284,16 +1292,21 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
def test_share_group_snapshot_get_all_by_project_with_details(self):
fake_project = uuidutils.generate_uuid()
sg = db_utils.create_share_group()
expected_sg_snap = db_utils.create_share_group_snapshot(
sg['id'], project_id=fake_project)
expected_sg_snap = dict(db_utils.create_share_group_snapshot(
sg['id'], project_id=fake_project))
sg_snap_source_group = expected_sg_snap.pop(
'share_group', {})
snaps = db_api.share_group_snapshot_get_all_by_project(
self.ctxt, fake_project, detailed=True)
self.assertEqual(1, len(snaps))
snap = snaps[0]
self.assertDictMatch(dict(expected_sg_snap), dict(snap))
self.assertEqual(fake_project, snap['project_id'])
actual_snap = dict(snaps[0])
get_sg_snap_source = actual_snap.pop('share_group', {})
self.assertDictEqual(
dict(sg_snap_source_group), dict(get_sg_snap_source))
self.assertEqual(expected_sg_snap, actual_snap)
self.assertEqual(fake_project, actual_snap['project_id'])
def test_share_group_snapshot_update(self):
fake_name = "my_fake_name"
@ -1324,14 +1337,23 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
share = db_utils.create_share(share_group_id=sg['id'])
si = db_utils.create_share_instance(share_id=share['id'])
sg_snap = db_utils.create_share_group_snapshot(sg['id'])
expected_member = db_utils.create_share_group_snapshot_member(
sg_snap['id'], share_instance_id=si['id'])
expected_member = dict(db_utils.create_share_group_snapshot_member(
sg_snap['id'], share_instance_id=si['id']))
sg_snap_source_member = expected_member.pop(
'share_group_snapshot', {})
sg_snap_source_member = expected_member.pop('share_instance', {})
members = db_api.share_group_snapshot_members_get_all(
self.ctxt, sg_snap['id'])
self.assertEqual(1, len(members))
self.assertDictMatch(dict(expected_member), dict(members[0]))
member = dict(members[0])
get_sg_snap_source_member = member.pop(
'share_group_snapshot', {})
get_sg_snap_source_member = member.pop('share_instance', {})
self.assertDictEqual(dict(
sg_snap_source_member), dict(get_sg_snap_source_member))
self.assertDictEqual(expected_member, member)
def test_count_share_group_snapshot_members_in_share(self):
sg = db_utils.create_share_group()
@ -1355,13 +1377,19 @@ class ShareGroupDatabaseAPITestCase(test.TestCase):
share = db_utils.create_share(share_group_id=sg['id'])
si = db_utils.create_share_instance(share_id=share['id'])
sg_snap = db_utils.create_share_group_snapshot(sg['id'])
expected_member = db_utils.create_share_group_snapshot_member(
sg_snap['id'], share_instance_id=si['id'])
expected_member = dict(db_utils.create_share_group_snapshot_member(
sg_snap['id'], share_instance_id=si['id']))
sg_snap_source_member = expected_member.pop('share_group_snapshot', {})
sg_snap_source_member = expected_member.pop('share_instance', {})
member = db_api.share_group_snapshot_member_get(
self.ctxt, expected_member['id'])
member = dict(db_api.share_group_snapshot_member_get(
self.ctxt, expected_member['id']))
get_sg_snap_source_member = member.pop('share_group_snapshot', {})
get_sg_snap_source_member = member.pop('share_instance', {})
self.assertDictMatch(dict(expected_member), dict(member))
self.assertDictEqual(dict(
sg_snap_source_member), dict(get_sg_snap_source_member))
self.assertDictEqual(expected_member, member)
def test_share_group_snapshot_members_get_not_found(self):
self.assertRaises(
@ -1429,7 +1457,7 @@ class ShareGroupTypeAPITestCase(test.TestCase):
# Let's cleanup share_group_type_1 and verify it is gone
self.assertIsNone(db_api.share_group_type_destroy(
self.ctxt, share_group_type_1['id']))
self.assertDictMatch(
self.assertDictEqual(
{}, db_api.share_group_type_specs_get(
self.ctxt, share_group_type_1['id']))
self.assertRaises(exception.ShareGroupTypeNotFound,
@ -3118,7 +3146,7 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
db_api.share_server_backend_details_set(self.ctxt, server['id'],
details)
self.assertDictMatch(
self.assertDictEqual(
details,
db_api.share_server_get(self.ctxt, server['id'])['backend_details']
)
@ -3147,7 +3175,7 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
server.share_network_subnet_id)
self.assertEqual(values['host'], server.host)
self.assertEqual(values['status'], server.status)
self.assertDictMatch(server['backend_details'], details)
self.assertDictEqual(server['backend_details'], details)
self.assertIn('backend_details', server.to_dict())
def test_delete_with_details(self):
@ -3745,7 +3773,7 @@ class ShareTypeAPITestCase(test.TestCase):
self.assertIsNone(
db_api.share_type_destroy(self.ctxt, share_type_1['id']))
self.assertDictMatch(
self.assertDictEqual(
{}, db_api.share_type_extra_specs_get(
self.ctxt, share_type_1['id']))
self.assertRaises(exception.ShareTypeNotFound,
@ -3832,7 +3860,7 @@ class ShareTypeAPITestCase(test.TestCase):
'shares': 10,
'snapshots': 30,
}
self.assertDictMatch(expected_quotas, share_type_quotas)
self.assertDictEqual(expected_quotas, share_type_quotas)
db_api.share_type_destroy(self.ctxt, share_type['id'])
@ -3852,7 +3880,7 @@ class ShareTypeAPITestCase(test.TestCase):
self.ctxt, 'fake-project-id', share_type['id'])
expected_q_usages = {'project_id': 'fake-project-id',
'share_type_id': share_type['id']}
self.assertDictMatch(expected_q_usages, q_usages)
self.assertDictEqual(expected_q_usages, q_usages)
if reservations:
q_reservations = db_api._quota_reservations_query(
db_session, self.ctxt, reservation_uuids).all()
@ -4250,7 +4278,7 @@ class ShareResourcesAPITestCase(test.TestCase):
new_host)
expected_updates = {'instances': 0, 'servers': 0, 'groups': 0}
self.assertDictMatch(expected_updates, updates)
self.assertDictEqual(expected_updates, updates)
# validate that resources are unmodified:
share_instances = db_api.share_instances_get_all(
self.context, filters={'share_id': share_id})

6
manila/tests/scheduler/drivers/test_filter.py

@ -60,7 +60,7 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
retval = sched._format_filter_properties(
fake_context, {}, request_spec)
self.assertDictMatch(fake_type, retval[0]['resource_type'])
self.assertDictEqual(fake_type, retval[0]['resource_type'])
self.assertIn('replication_domain', retval[0])
# no "share_proto" was specified in the request_spec
self.assertNotIn('storage_protocol', retval[0])
@ -89,7 +89,7 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
retval = sched._format_filter_properties(
fake_context, {}, request_spec)
self.assertDictMatch(fake_type, retval[0]['resource_type'])
self.assertDictEqual(fake_type, retval[0]['resource_type'])
self.assertNotIn('share_backend_name',
retval[0]['share_type']['extra_specs'])
@ -118,7 +118,7 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
filter_spec = retval['share_type']['extra_specs']['storage_protocol']
expected_spec = 'NFS_CIFS' if spec_present else '<in> CEPHFS'
self.assertEqual(expected_spec, filter_spec)
self.assertDictMatch(fake_type, retval['resource_type'])
self.assertDictEqual(fake_type, retval['resource_type'])
def test_create_share_no_hosts(self):
# Ensure empty hosts/child_zones result in NoValidHosts exception.

6
manila/tests/scheduler/test_host_manager.py

@ -107,7 +107,7 @@ class HostManagerTestCase(test.TestCase):
def test_update_service_capabilities_for_shares(self):
service_states = self.host_manager.service_states
self.assertDictMatch(service_states, {})
self.assertDictEqual(service_states, {})
host1_share_capabs = dict(free_capacity_gb=4321, timestamp=1)
host2_share_capabs = dict(free_capacity_gb=5432, timestamp=1)
host3_share_capabs = dict(free_capacity_gb=6543, timestamp=1)
@ -135,7 +135,7 @@ class HostManagerTestCase(test.TestCase):
'host2': host2_share_capabs,
'host3': host3_share_capabs,
}
self.assertDictMatch(service_states, expected)
self.assertDictEqual(service_states, expected)
def test_get_all_host_states_share(self):
fake_context = context.RequestContext('user', 'project')
@ -1139,7 +1139,7 @@ class PoolStateTestCase(test.TestCase):
self.assertEqual('pool0', fake_pool.pool_name)
self.assertEqual(1024, fake_pool.total_capacity_gb)
self.assertEqual(512, fake_pool.free_capacity_gb)
self.assertDictMatch(share_capability, fake_pool.capabilities)
self.assertDictEqual(share_capability, dict(fake_pool.capabilities))
if 'thin_provisioning' in share_capability:
thin_provisioned = scheduler_utils.thin_provisioning(

2
manila/tests/share/drivers/container/test_driver.py

@ -592,7 +592,7 @@ class ContainerShareDriverTestCase(test.TestCase):
expected_result = {
'share_updates': share_updates,
}
self.assertDictMatch(expected_result,
self.assertDictEqual(expected_result,
self._driver.share_server_migration_complete(
self._context, source_server, dest_server,
shares_list, None, None))

10
manila/tests/share/drivers/container/test_storage_helper.py

@ -235,7 +235,7 @@ class LVMHelperTestCase(test.TestCase):
'preserve_metadata': True,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
if not compatible:
mock_exception_log.assert_called_once()
@ -252,7 +252,7 @@ class LVMHelperTestCase(test.TestCase):
expected_progress = {
'total_progress': 100,
}
self.assertDictMatch(expected_progress, progress)
self.assertDictEqual(expected_progress, progress)
@ddt.data({'source_host': 'host@back1', 'dest_host': 'host@back1',
'shares_specs': {}},
@ -279,7 +279,7 @@ class LVMHelperTestCase(test.TestCase):
self.context, source_server, dest_host, None, None,
shares_specs))
self.assertDictMatch(not_compatible, migration_compatibility)
self.assertDictEqual(not_compatible, migration_compatibility)
mock_error_log.assert_called_once()
@ddt.data({'source_host': 'host@back1', 'dest_host': 'host@back2#vg1',
@ -308,7 +308,7 @@ class LVMHelperTestCase(test.TestCase):
self.context, source_server, dest_host, None, None,
shares_specs))
self.assertDictMatch(compatible, migration_compatibility)
self.assertDictEqual(compatible, migration_compatibility)
def test_share_server_migration_continue(self):
end1Phase = self.LVMHelper.share_server_migration_continue(
@ -321,7 +321,7 @@ class LVMHelperTestCase(test.TestCase):
expected_progress = {
'total_progress': 100,
}
self.assertDictMatch(expected_progress, progress)
self.assertDictEqual(expected_progress, progress)
def test_get_share_pool_name(self):
fake_vg_name = 'fake_vg'

4
manila/tests/share/drivers/infortrend/test_infortrend_nas.py

@ -162,7 +162,7 @@ class InfortrendNASDriverTestCase(test.TestCase):
self._iftnas._check_channels_status()
self.assertDictMatch(expect_channel_dict, self._iftnas.channel_dict)
self.assertDictEqual(expect_channel_dict, self._iftnas.channel_dict)
@mock.patch.object(infortrend_nas.LOG, 'warning')
def test_channel_status_down(self, log_warning):
@ -198,7 +198,7 @@ class InfortrendNASDriverTestCase(test.TestCase):
self._iftnas._check_pools_setup()
self.assertDictMatch(expect_pool_dict, self._iftnas.pool_dict)
self.assertDictEqual(expect_pool_dict, self._iftnas.pool_dict)
def test_unknow_pools_setup(self):
self.fake_conf.set_default(

6
manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py

@ -7060,7 +7060,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
'phase': 'finishing',
}
self.assertDictMatch(expected_status_info, actual_status_info)
self.assertDictEqual(expected_status_info, actual_status_info)
self.client.send_iter_request.assert_called_once_with(
'volume-move-get-iter', expected_api_args)
@ -7153,7 +7153,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
}
self.client.send_request.assert_called_once_with(
'qos-policy-group-get-iter', qos_policy_group_get_iter_args, False)
self.assertDictMatch(fake.QOS_POLICY_GROUP, qos_info)
self.assertDictEqual(fake.QOS_POLICY_GROUP, qos_info)
@ddt.data(None, fake.QOS_MAX_THROUGHPUT)
def test_qos_policy_group_create(self, max_throughput):
@ -7522,7 +7522,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
if api_response == fake.NO_RECORDS_RESPONSE:
self.assertIsNone(result)
else:
self.assertDictMatch(fake.VSERVER_INFO, result)
self.assertDictEqual(fake.VSERVER_INFO, result)
@ddt.data({'discard_network': True, 'preserve_snapshots': False},
{'discard_network': False, 'preserve_snapshots': True})

28
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py

@ -1589,7 +1589,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.library._get_normalized_qos_specs,
extra_specs)
else:
self.assertDictMatch(
self.assertDictEqual(
{}, self.library._get_normalized_qos_specs(extra_specs))
@ddt.data({'qos': True, 'netapp:maxiops': '3000', 'netapp:maxbps': '9000'},
@ -1614,7 +1614,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
qos_specs = self.library._get_normalized_qos_specs(extra_specs)
self.assertDictMatch(expected_normalized_spec, qos_specs)
self.assertDictEqual(expected_normalized_spec, qos_specs)
self.assertEqual(1, len(qos_specs))
@ddt.data({'qos': {'maxiops': '3000'}, 'expected': '3000iops'},
@ -3276,7 +3276,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
None, [fake.SHARE], fake.SHARE, [], [],
share_server=None)
self.assertDictMatch(expected_model_update, model_update)
self.assertDictEqual(expected_model_update, model_update)
mock_dm_session.create_snapmirror.assert_called_once_with(
fake.SHARE, fake.SHARE)
data_motion.get_client_for_backend.assert_called_once_with(
@ -3303,7 +3303,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
None, [fake.SHARE], fake.SHARE, [], [],
share_server=fake.SHARE_SERVER)
self.assertDictMatch(expected_model_update, model_update)
self.assertDictEqual(expected_model_update, model_update)
mock_dm_session.create_snapmirror.assert_called_once_with(
fake.SHARE, fake.SHARE)
data_motion.get_client_for_backend.assert_called_once_with(
@ -5038,7 +5038,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_warning_log.assert_called_once()
self.assertFalse(data_motion.get_backend_configuration.called)
@ -5071,7 +5071,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
self.assertFalse(data_motion.get_backend_configuration.called)
@ -5100,7 +5100,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
def test_migration_check_compatibility_destination_not_configured(self):
@ -5139,7 +5139,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
@ -5186,7 +5186,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
@ -5228,7 +5228,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
@ -5273,7 +5273,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': False,
'preserve_snapshots': False,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
mock_exception_log.assert_called_once()
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
@ -5338,7 +5338,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': True,
'preserve_snapshots': True,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
mock_move_check.assert_called_once_with(
@ -5395,7 +5395,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'preserve_metadata': True,
'preserve_snapshots': True,
}
self.assertDictMatch(expected_compatibility, migration_compatibility)
self.assertDictEqual(expected_compatibility, migration_compatibility)
data_motion.get_backend_configuration.assert_called_once_with(
'destination_backend')
@ -5538,7 +5538,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'details': '%s:: Volume move job in progress' % phase,
'phase': phase,
}
self.assertDictMatch(expected_progress, migration_progress)
self.assertDictEqual(expected_progress, migration_progress)
mock_info_log.assert_called_once()
@ddt.data({'state': 'failed'},

2
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py

@ -1158,7 +1158,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
None, [self.fake_replica], self.fake_new_replica, [], [],
share_server=None)
self.assertDictMatch(lib_base_model_update, model_update)
self.assertDictEqual(lib_base_model_update, model_update)
self.library._get_vservers_from_replicas.assert_called_once_with(
None, [self.fake_replica], self.fake_new_replica
)

2
manila/tests/share/test_share_types.py

@ -461,7 +461,7 @@ class ShareTypesTestCase(test.TestCase):
extra_specs[constants.ExtraSpecs.AVAILABILITY_ZONES] = spec_value
expected_specs['availability_zones'] = 'az 1,az2,az 3'
self.assertDictMatch(expected_specs,
self.assertDictEqual(expected_specs,
share_types.sanitize_extra_specs(extra_specs))
def test_add_access(self):

1
tools/install_venv.py

@ -61,7 +61,6 @@ def main(argv):
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
py_version, project)
options = install.parse_args(argv)
install.check_python_version()
install.check_dependencies()
install.create_virtualenv(no_site_packages=options.no_site_packages)
install.install_dependencies()

4
tools/install_venv_common.py

@ -44,10 +44,6 @@ class InstallVenv(object):
print(message % args, file=sys.stderr)
sys.exit(1)
def check_python_version(self):
if sys.version_info < (2, 6):
self.die("Need Python Version >= 2.6")
def run_command_with_code(self, cmd, redirect_output=True,
check_exit_code=True):
"""Runs a command in an out-of-process shell.

Loading…
Cancel
Save