initialize objects with context in Aggregate 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: Ic7e6ac4d3f270e1b129cf556098e80e7c0738f39
This commit is contained in:
melanie witt 2014-12-17 00:00:29 +00:00
parent 7ed9268a1f
commit 50c9d9c4e2
1 changed files with 8 additions and 8 deletions

View File

@ -50,10 +50,10 @@ class _TestAggregateObject(object):
db.aggregate_create(self.context, {'name': 'foo'},
metadata={'one': 'two'}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate()
agg = aggregate.Aggregate(context=self.context)
agg.name = 'foo'
agg.metadata = {'one': 'two'}
agg.create(self.context)
agg.create()
self.compare_obj(agg, fake_aggregate, subs=SUBS)
def test_recreate_fails(self):
@ -61,10 +61,10 @@ class _TestAggregateObject(object):
db.aggregate_create(self.context, {'name': 'foo'},
metadata={'one': 'two'}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate()
agg = aggregate.Aggregate(context=self.context)
agg.name = 'foo'
agg.metadata = {'one': 'two'}
agg.create(self.context)
agg.create()
self.assertRaises(exception.ObjectActionError, agg.create,
self.context)
@ -73,10 +73,10 @@ class _TestAggregateObject(object):
db.aggregate_update(self.context, 123, {'name': 'baz'}).AndReturn(
fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate()
agg = aggregate.Aggregate(context=self.context)
agg.id = 123
agg.name = 'baz'
agg.save(self.context)
agg.save()
self.compare_obj(agg, fake_aggregate, subs=SUBS)
def test_save_and_create_no_hosts(self):
@ -116,9 +116,9 @@ class _TestAggregateObject(object):
self.mox.StubOutWithMock(db, 'aggregate_delete')
db.aggregate_delete(self.context, 123)
self.mox.ReplayAll()
agg = aggregate.Aggregate()
agg = aggregate.Aggregate(context=self.context)
agg.id = 123
agg.destroy(self.context)
agg.destroy()
def test_add_host(self):
self.mox.StubOutWithMock(db, 'aggregate_host_add')