From: Jenkins Date: Fri, 14 Aug 2015 22:55:39 +0000 (+0000) Subject: Merge "Don't use context.elevated to get volume" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4bba79d2f2f30404e7b7f77e34a223f0940a3448;p=openstack-build%2Fcinder-build.git Merge "Don't use context.elevated to get volume" --- 4bba79d2f2f30404e7b7f77e34a223f0940a3448 diff --cc cinder/tests/unit/api/v1/test_volumes.py index 40b051aa7,74c097cb7..934add1f7 --- a/cinder/tests/unit/api/v1/test_volumes.py +++ b/cinder/tests/unit/api/v1/test_volumes.py @@@ -263,13 -266,17 +266,17 @@@ class VolumeApiTest(test.TestCase) 'id': '1', 'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1), 'size': 1}} - self.assertEqual(res_dict, expected) - self.assertEqual(len(self.notifier.notifications), 2) + self.assertEqual(expected, res_dict) + self.assertEqual(2, len(self.notifier.notifications)) - def test_volume_update_metadata(self): - self.stubs.Set(db, 'volume_get', stubs.stub_volume_get_db) - self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update) - + @mock.patch.object(db, 'volume_admin_metadata_get', + return_value={"qos_max_iops": 2000, + "readonly": "False", + "attached_mode": "rw"}) + @mock.patch.object(db, 'volume_get', side_effect=stubs.stub_volume_get_db) + @mock.patch.object(volume_api.API, 'update', + side_effect=stubs.stub_volume_update) + def test_volume_update_metadata(self, *args): updates = { "metadata": {"qos_max_iops": 2000} } @@@ -296,10 -303,15 +303,15 @@@ 'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1), 'size': 1 }} - self.assertEqual(res_dict, expected) - self.assertEqual(len(self.notifier.notifications), 2) + self.assertEqual(expected, res_dict) + self.assertEqual(2, len(self.notifier.notifications)) def test_volume_update_with_admin_metadata(self): + def stubs_volume_admin_metadata_get(context, volume_id): + return {'key': 'value', + 'readonly': 'True'} + self.stubs.Set(db, 'volume_admin_metadata_get', + stubs_volume_admin_metadata_get) self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update) volume = stubs.stub_volume("1") @@@ -522,11 -539,13 +539,13 @@@ 'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1), 'size': 1}]} - self.assertEqual(res_dict, expected) + self.assertEqual(expected, res_dict) - def test_volume_show(self): - self.stubs.Set(db, 'volume_get', stubs.stub_volume_get_db) - + @mock.patch.object(db, 'volume_admin_metadata_get', + return_value={'attached_mode': 'rw', + 'readonly': 'False'}) + @mock.patch.object(db, 'volume_get', side_effect=stubs.stub_volume_get_db) + def test_volume_show(self, *args): req = fakes.HTTPRequest.blank('/v1/volumes/1') res_dict = self.controller.show(req, '1') expected = {'volume': {'status': 'fakestatus',