From 89d814f64c7bfac556b49c24a51a87ae22959485 Mon Sep 17 00:00:00 2001 From: melanie witt Date: Wed, 17 Dec 2014 00:00:29 +0000 Subject: [PATCH] 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 --- nova/tests/unit/objects/test_aggregate.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nova/tests/unit/objects/test_aggregate.py b/nova/tests/unit/objects/test_aggregate.py index 67ea514bc..f930b4481 100644 --- a/nova/tests/unit/objects/test_aggregate.py +++ b/nova/tests/unit/objects/test_aggregate.py @@ -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')