summaryrefslogtreecommitdiff
path: root/nova/tests/unit/objects/test_instance_group.py
diff options
context:
space:
mode:
authormelanie witt <melwitt@yahoo-inc.com>2014-12-17 00:15:46 +0000
committermelanie witt <melwitt@yahoo-inc.com>2015-01-08 06:50:05 +0000
commit62c2f1143f5422bc4e56830f338ddc35eb9ed0b9 (patch)
tree90a00e8688ece0bc53234377a72ce5c3119d65ae /nova/tests/unit/objects/test_instance_group.py
parent93b2278f6205889a2c85c2f61096be0734eeb97c (diff)
downloadnova-62c2f1143f5422bc4e56830f338ddc35eb9ed0b9.tar.gz
initialize objects with context in InstanceGroup object tests
These changes aim to clean up the pattern of passing a context in object member functions create/destroy/refresh/save and instead initialize the object with the context when it's constructed. Related to blueprint kilo-objects Change-Id: I43e012be4cb32dfebc4fbe77f1b09837611febf1
Diffstat (limited to 'nova/tests/unit/objects/test_instance_group.py')
-rw-r--r--nova/tests/unit/objects/test_instance_group.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/nova/tests/unit/objects/test_instance_group.py b/nova/tests/unit/objects/test_instance_group.py
index 0e20f54145..a157151e08 100644
--- a/nova/tests/unit/objects/test_instance_group.py
+++ b/nova/tests/unit/objects/test_instance_group.py
@@ -118,11 +118,11 @@ class _TestInstanceGroupObjects(object):
self.assertEqual(result['members'], members)
def test_create(self):
- group1 = instance_group.InstanceGroup()
+ group1 = instance_group.InstanceGroup(context=self.context)
group1.uuid = 'fake-uuid'
group1.name = 'fake-name'
fake_notifier.NOTIFICATIONS = []
- group1.create(self.context)
+ group1.create()
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
msg = fake_notifier.NOTIFICATIONS[0]
self.assertEqual(group1.name, msg.payload['name'])
@@ -139,37 +139,37 @@ class _TestInstanceGroupObjects(object):
self.assertEqual(group1.name, result.name)
def test_create_with_policies(self):
- group1 = instance_group.InstanceGroup()
+ group1 = instance_group.InstanceGroup(context=self.context)
group1.policies = ['policy1', 'policy2']
- group1.create(self.context)
+ group1.create()
group2 = instance_group.InstanceGroup.get_by_uuid(self.context,
group1.uuid)
self.assertEqual(group1.id, group2.id)
self.assertEqual(group1.policies, group2.policies)
def test_create_with_members(self):
- group1 = instance_group.InstanceGroup()
+ group1 = instance_group.InstanceGroup(context=self.context)
group1.members = ['instance1', 'instance2']
- group1.create(self.context)
+ group1.create()
group2 = instance_group.InstanceGroup.get_by_uuid(self.context,
group1.uuid)
self.assertEqual(group1.id, group2.id)
self.assertEqual(group1.members, group2.members)
def test_recreate_fails(self):
- group = instance_group.InstanceGroup()
- group.create(self.context)
+ group = instance_group.InstanceGroup(context=self.context)
+ group.create()
self.assertRaises(exception.ObjectActionError, group.create,
self.context)
def test_destroy(self):
values = self._get_default_values()
result = self._create_instance_group(self.context, values)
- group = instance_group.InstanceGroup()
+ group = instance_group.InstanceGroup(context=self.context)
group.id = result.id
group.uuid = result.uuid
fake_notifier.NOTIFICATIONS = []
- group.destroy(self.context)
+ group.destroy()
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
msg = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('servergroup.delete', msg.event_type)
@@ -303,9 +303,10 @@ class _TestInstanceGroupObjects(object):
self.assertIn('hostB', hosts)
def test_obj_make_compatible(self):
- group = instance_group.InstanceGroup(uuid='fake-uuid',
+ group = instance_group.InstanceGroup(context=self.context,
+ uuid='fake-uuid',
name='fake-name')
- group.create(self.context)
+ group.create()
group_primitive = group.obj_to_primitive()
group.obj_make_compatible(group_primitive, '1.6')
self.assertEqual({}, group_primitive['metadetails'])