initialize objects with context in VirtualInterface 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: I5c4fc7de4385261d8e782dd355f431785da2dda7
This commit is contained in:
melanie witt
2014-12-17 00:25:01 +00:00
parent 593d791704
commit 4ab259b8ce

View File

@@ -67,7 +67,7 @@ class _TestVirtualInterface(object):
self._compare(self, fake_vif, vif)
def test_create(self):
vif = vif_obj.VirtualInterface()
vif = vif_obj.VirtualInterface(context=self.context)
vif.address = '00:00:00:00:00:00'
vif.network_id = 123
vif.instance_uuid = 'fake-uuid'
@@ -75,7 +75,7 @@ class _TestVirtualInterface(object):
with mock.patch.object(db, 'virtual_interface_create') as create:
create.return_value = fake_vif
vif.create(self.context)
vif.create()
self.assertEqual(self.context, vif._context)
vif._context = None