Fix pool tests in py3
This fixes an assertion which was trying to sort dictionaries: it works around it by comparing items instead. Change-Id: Iaa9764102a18d4b4cd6c2042791991ae1ab114e3
This commit is contained in:
parent
ff32da0bcc
commit
e0a670a030
@ -74,10 +74,10 @@ def deep_sort_lists(obj):
|
||||
"""Sort lists nested in dictionaries
|
||||
"""
|
||||
if isinstance(obj, dict):
|
||||
return {k: deep_sort_lists(obj[k]) for k in obj}
|
||||
return sorted((k, deep_sort_lists(obj[k])) for k in obj)
|
||||
|
||||
if isinstance(obj, list):
|
||||
return [deep_sort_lists(v) for v in sorted(obj)]
|
||||
return sorted(deep_sort_lists(v) for v in obj)
|
||||
|
||||
return obj
|
||||
|
||||
@ -87,25 +87,26 @@ class poolTest(oslotest.base.BaseTestCase):
|
||||
def test_init_from_config(self):
|
||||
pool = objects.Pool.from_config(mock_conf,
|
||||
'769ca3fc-5924-4a44-8c1f-7efbe52fbd59')
|
||||
expected = {'also_notifies': [{'host': '1.0.0.0', 'port': 1},
|
||||
{'host': '2.0.0.0', 'port': 2}],
|
||||
'description': 'Pool built from configuration on foohost',
|
||||
'id': '769ca3fc-5924-4a44-8c1f-7efbe52fbd59',
|
||||
'nameservers': [{'host': 'pool_host_1',
|
||||
'id': '169ca3fc-5924-4a44-8c1f-7efbe52fbd59', # noqa
|
||||
'port': 123},
|
||||
{'host': 'pool_host_2',
|
||||
'id': '269ca3fc-5924-4a44-8c1f-7efbe52fbd59', # noqa
|
||||
'port': 456}],
|
||||
'targets': [{'id': '1588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'masters': [],
|
||||
'options': [{'key': 'a', 'value': '1'},
|
||||
{'key': 'b', 'value': '2'}],
|
||||
'type': 't1'},
|
||||
{'id': '2588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'masters': [{'host': '1.1.1.1', 'port': 11}],
|
||||
'options': [],
|
||||
'type': 't2'}]}
|
||||
expected = [('also_notifies', [[('host', '1.0.0.0'), ('port', 1)],
|
||||
[('host', '2.0.0.0'), ('port', 2)]]),
|
||||
('description', 'Pool built from configuration on foohost'), # noqa
|
||||
('id', '769ca3fc-5924-4a44-8c1f-7efbe52fbd59'),
|
||||
('nameservers', [[('host', 'pool_host_1'),
|
||||
('id', '169ca3fc-5924-4a44-8c1f-7efbe52fbd59'), # noqa
|
||||
('port', 123)],
|
||||
[('host', 'pool_host_2'),
|
||||
('id', '269ca3fc-5924-4a44-8c1f-7efbe52fbd59'), # noqa
|
||||
('port', 456)]]),
|
||||
('targets', [[('id', '1588652b-50e7-46b9-b688-a9bad40a873e'), # noqa
|
||||
('masters', []),
|
||||
('options', [[('key', 'a'), ('value', '1')],
|
||||
[('key', 'b'), ('value', '2')]]),
|
||||
('type', 't1')],
|
||||
[('id', '2588652b-50e7-46b9-b688-a9bad40a873e'), # noqa
|
||||
('masters', [[('host', '1.1.1.1'),
|
||||
('port', 11)]]),
|
||||
('options', []),
|
||||
('type', 't2')]])]
|
||||
|
||||
actual = deep_sort_lists(pool.to_dict())
|
||||
self.assertEqual(actual, expected)
|
||||
|
@ -1,3 +1,2 @@
|
||||
# Blacklist of tests failing on Python 3
|
||||
designate.tests.unit.test_pool
|
||||
designate.tests.unit.test_producer.test_tasks
|
||||
|
Loading…
Reference in New Issue
Block a user