initialize objects with context in InstanceFault 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: Ia6be84d85e1e2a394a88c8f16d92af8dc90d7c4e
This commit is contained in:
melanie witt
2014-12-17 00:15:01 +00:00
parent 74e17a0590
commit 93b2278f62

View File

@@ -77,13 +77,13 @@ class _TestInstanceFault(object):
@mock.patch('nova.db.instance_fault_create')
def _test_create(self, update_cells, mock_create, cells_fault_create):
mock_create.return_value = fake_faults['fake-uuid'][1]
fault = instance_fault.InstanceFault()
fault = instance_fault.InstanceFault(context=self.context)
fault.instance_uuid = 'fake-uuid'
fault.code = 456
fault.message = 'foo'
fault.details = 'you screwed up'
fault.host = 'myhost'
fault.create(self.context)
fault.create()
self.assertEqual(2, fault.id)
mock_create.assert_called_once_with(self.context,
{'instance_uuid': 'fake-uuid',