From 465937e82ec638f75ecb3420129df1f056e15365 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 1 Aug 2016 11:46:59 -0700 Subject: [PATCH] Address feedback on cell-aggregate-api-db patches This fixes up just a few minor things pointed out in the review of the prevous set of patches. Change-Id: If19f36c3bdf1393e07a74c627d4b7054d16fbcbb --- nova/objects/aggregate.py | 1 - nova/tests/functional/db/test_aggregate.py | 2 +- nova/tests/unit/objects/test_aggregate.py | 5 ++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nova/objects/aggregate.py b/nova/objects/aggregate.py index 94ae25cd7..66d08e435 100644 --- a/nova/objects/aggregate.py +++ b/nova/objects/aggregate.py @@ -386,7 +386,6 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject): "updateprop.start", payload) updates.pop('id', None) - db_aggregate = None try: db_aggregate = _aggregate_update_to_db(self._context, self.id, updates) diff --git a/nova/tests/functional/db/test_aggregate.py b/nova/tests/functional/db/test_aggregate.py index 13e34558c..74a713e55 100644 --- a/nova/tests/functional/db/test_aggregate.py +++ b/nova/tests/functional/db/test_aggregate.py @@ -270,7 +270,7 @@ class AggregateObjectDbTestCase(test.NoDBTestCase): metadata={'availability_zone': 'fake_avail_zone'}) result = aggregate_obj._aggregate_get_from_db(self.context, created['id']) - self.assertEqual(result['availability_zone'], 'fake_avail_zone') + self.assertEqual('fake_avail_zone', result['availability_zone']) new_values = deepcopy(_get_fake_aggregate(1, result=False)) new_values['availability_zone'] = 'different_avail_zone' updated = aggregate_obj._aggregate_update_to_db(self.context, diff --git a/nova/tests/unit/objects/test_aggregate.py b/nova/tests/unit/objects/test_aggregate.py index 57efacf23..ebcd1e903 100644 --- a/nova/tests/unit/objects/test_aggregate.py +++ b/nova/tests/unit/objects/test_aggregate.py @@ -167,7 +167,7 @@ class _TestAggregateObject(object): @mock.patch('nova.objects.aggregate._aggregate_update_to_db') @mock.patch('nova.db.aggregate_update') - def test_save(self, update_mock, api_update_mock): + def test_save_to_cell(self, update_mock, api_update_mock): api_update_mock.side_effect = exception.AggregateNotFound( aggregate_id='foo') update_mock.return_value = fake_aggregate @@ -181,10 +181,9 @@ class _TestAggregateObject(object): {'name': 'fake-aggregate'}) self.assertTrue(api_update_mock.called) - @mock.patch('nova.objects.Aggregate.in_api', return_value=True) @mock.patch('nova.objects.aggregate._aggregate_update_to_db') @mock.patch('nova.db.aggregate_update') - def test_save_to_api(self, update_mock, api_update_mock, in_api_mock): + def test_save_to_api(self, update_mock, api_update_mock): api_update_mock.return_value = fake_aggregate agg = aggregate.Aggregate(context=self.context) agg.id = 123