diff options
author | Takashi NATSUME <natsume.takashi@lab.ntt.co.jp> | 2019-09-19 11:13:46 +0900 |
---|---|---|
committer | Takashi NATSUME <natsume.takashi@lab.ntt.co.jp> | 2019-10-16 22:05:45 +0000 |
commit | 6725da92bda4a0b37673336821ccdbd194634dc9 (patch) | |
tree | 0ec3955ee78f0e3ab01fc27571882c97f6206ccf /nova/tests/unit/objects/test_request_spec.py | |
parent | 1a226aaa9e8c969ddfdfe198c36f7966b1f692f3 (diff) | |
download | nova-6725da92bda4a0b37673336821ccdbd194634dc9.tar.gz |
Move Destination object tests to their own test class
The TestDestinationObject class has been added
since Ic2bcee40b41c97170a8603b27b935113f0633de7.
The following test methods in the _TestRequestSpecObject class are for
the Destination object.
- test_destination_aggregates_default
- test_destination_require_aggregates
- test_destination_obj_make_compatible
- test_destination_forbidden_aggregates_default
- test_destination_append_forbidden_aggregates
- test_destination_delete_forbidden_aggregates
They should be moved to their own test class,
so move them to the test class.
In addition, some methods are merged into one test method.
Change-Id: I0bd9d44a61f16a703cd9c850d13d1f8f35e81ad7
Diffstat (limited to 'nova/tests/unit/objects/test_request_spec.py')
-rw-r--r-- | nova/tests/unit/objects/test_request_spec.py | 105 |
1 files changed, 50 insertions, 55 deletions
diff --git a/nova/tests/unit/objects/test_request_spec.py b/nova/tests/unit/objects/test_request_spec.py index d8f1dba2fc..41dad2ee49 100644 --- a/nova/tests/unit/objects/test_request_spec.py +++ b/nova/tests/unit/objects/test_request_spec.py @@ -888,29 +888,6 @@ class _TestRequestSpecObject(object): objects.NetworkMetadata) self.assertIn('network_metadata', req_obj) - def test_destination_aggregates_default(self): - destination = objects.Destination() - self.assertIsNone(destination.aggregates) - - def test_destination_require_aggregates(self): - destination = objects.Destination() - destination.require_aggregates(['foo', 'bar']) - destination.require_aggregates(['baz']) - self.assertEqual(['foo,bar', 'baz'], destination.aggregates) - - def test_destination_obj_make_compatible(self): - destination = objects.Destination( - aggregates=['foo'], host='fake-host', allow_cross_cell_move=False) - primitive = destination.obj_to_primitive( - target_version='1.2')['nova_object.data'] - self.assertIn('aggregates', primitive) - self.assertNotIn('allow_cross_cell_move', primitive) - - primitive = destination.obj_to_primitive( - target_version='1.0')['nova_object.data'] - self.assertNotIn('aggregates', primitive) - self.assertEqual('fake-host', primitive['host']) - def test_create_raises_on_unchanged_object(self): ctxt = context.RequestContext(uuids.user_id, uuids.project_id) req_obj = request_spec.RequestSpec(context=ctxt) @@ -921,25 +898,6 @@ class _TestRequestSpecObject(object): req_obj.create() req_obj.save() - def test_destination_forbidden_aggregates_default(self): - destination = objects.Destination() - self.assertIsNone(destination.forbidden_aggregates) - - def test_destination_append_forbidden_aggregates(self): - destination = objects.Destination() - destination.append_forbidden_aggregates(set(['foo', 'bar'])) - self.assertEqual( - set(['foo', 'bar']), destination.forbidden_aggregates) - destination.append_forbidden_aggregates(set(['bar', 'baz'])) - self.assertEqual( - set(['foo', 'bar', 'baz']), destination.forbidden_aggregates) - - def test_destination_delete_forbidden_aggregates(self): - destination = objects.Destination() - destination.append_forbidden_aggregates(set(['foo'])) - primitive = destination.obj_to_primitive(target_version='1.0') - self.assertNotIn('forbidden_aggregates', primitive['nova_object.data']) - class TestRequestSpecObject(test_objects._LocalTest, _TestRequestSpecObject): @@ -1062,32 +1020,69 @@ class TestDestinationObject(test.NoDBTestCase): self.project_id = uuids.project_id self.context = context.RequestContext(uuids.user_id, uuids.project_id) - def test_obj_make_compatible_destination(self): - values = { - 'host': 'fake_host', - 'node': 'fake_node', - 'aggregates': ['agg1', 'agg2'], - 'forbidden_aggregates': set(['agg3', 'agg4'])} - obj = objects.Destination(self.context, **values) - data = lambda x: x['nova_object.data'] - obj_primitive = data(obj.obj_to_primitive(target_version='1.3')) - self.assertNotIn('forbidden_aggregates', obj_primitive) - self.assertIn('aggregates', obj_primitive) + def test_destination_aggregates_default(self): + destination = objects.Destination() + self.assertIsNone(destination.aggregates) - def test_obj_make_compatible_destination_with_forbidden_aggregates(self): + def test_destination_require_aggregates(self): + destination = objects.Destination() + destination.require_aggregates(['foo', 'bar']) + destination.require_aggregates(['baz']) + self.assertEqual(['foo,bar', 'baz'], destination.aggregates) + + def test_destination_forbidden_aggregates_default(self): + destination = objects.Destination() + self.assertIsNone(destination.forbidden_aggregates) + + def test_destination_append_forbidden_aggregates(self): + destination = objects.Destination() + destination.append_forbidden_aggregates(set(['foo', 'bar'])) + self.assertEqual( + set(['foo', 'bar']), destination.forbidden_aggregates) + destination.append_forbidden_aggregates(set(['bar', 'baz'])) + self.assertEqual( + set(['foo', 'bar', 'baz']), destination.forbidden_aggregates) + + def test_obj_make_compatible(self): values = { 'host': 'fake_host', 'node': 'fake_node', + 'cell': objects.CellMapping(uuid=uuids.cell1), 'aggregates': ['agg1', 'agg2'], + 'allow_cross_cell_move': False, 'forbidden_aggregates': set(['agg3', 'agg4'])} obj = objects.Destination(self.context, **values) data = lambda x: x['nova_object.data'] - obj_primitive = data(obj.obj_to_primitive(target_version='1.4')) + manifest = ovo_base.obj_tree_get_versions(obj.obj_name()) + + obj_primitive = data(obj.obj_to_primitive(target_version='1.4', + version_manifest=manifest)) self.assertIn('forbidden_aggregates', obj_primitive) self.assertItemsEqual(obj_primitive['forbidden_aggregates'], set(['agg3', 'agg4'])) self.assertIn('aggregates', obj_primitive) + obj_primitive = data(obj.obj_to_primitive(target_version='1.3', + version_manifest=manifest)) + self.assertNotIn('forbidden_aggregates', obj_primitive) + self.assertIn('allow_cross_cell_move', obj_primitive) + + obj_primitive = data(obj.obj_to_primitive(target_version='1.2', + version_manifest=manifest)) + self.assertIn('aggregates', obj_primitive) + self.assertNotIn('allow_cross_cell_move', obj_primitive) + + obj_primitive = data(obj.obj_to_primitive(target_version='1.1', + version_manifest=manifest)) + self.assertIn('cell', obj_primitive) + self.assertNotIn('aggregates', obj_primitive) + + obj_primitive = data(obj.obj_to_primitive(target_version='1.0', + version_manifest=manifest)) + self.assertNotIn('forbidden_aggregates', obj_primitive) + self.assertNotIn('cell', obj_primitive) + self.assertEqual('fake_host', obj_primitive['host']) + class TestMappingRequestGroupsToProviders(test.NoDBTestCase): def setUp(self): |