From: Eiichi Aikawa Date: Fri, 26 Sep 2014 06:37:31 +0000 (+0900) Subject: Fix exception handling on test_delete_nonexistent_volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6076325a39e0d387afcc2d25e61efad1e058427a;p=openstack-build%2Fcinder-build.git Fix exception handling on test_delete_nonexistent_volume test_delete_nonexistent_volume wants to check the exception would be received when nonexistent volume was specified. But currently, this test case checks the exception would be received when nonexistent metadata was specified. Change-Id: Ia110618d5c658551a1826d495656954be02f4326 --- diff --git a/cinder/tests/api/v1/test_volume_metadata.py b/cinder/tests/api/v1/test_volume_metadata.py index af6c3fe2f..e6fe56fd5 100644 --- a/cinder/tests/api/v1/test_volume_metadata.py +++ b/cinder/tests/api/v1/test_volume_metadata.py @@ -110,7 +110,7 @@ def return_volume(context, volume_id): 'project_id': context.project_id} -def return_volume_nonexistent(context, volume_id): +def return_volume_nonexistent(*args, **kwargs): raise exception.VolumeNotFound('bogus test message') @@ -208,7 +208,9 @@ class volumeMetaDataTest(test.TestCase): self.assertEqual(200, res.status_int) def test_delete_nonexistent_volume(self): - self.stubs.Set(cinder.db, 'volume_get', + self.stubs.Set(cinder.db, 'volume_metadata_get', + return_volume_metadata) + self.stubs.Set(cinder.db, 'volume_metadata_delete', return_volume_nonexistent) req = fakes.HTTPRequest.blank(self.url + '/key1') req.method = 'DELETE' diff --git a/cinder/tests/api/v2/test_volume_metadata.py b/cinder/tests/api/v2/test_volume_metadata.py index 61b169054..a5a999041 100644 --- a/cinder/tests/api/v2/test_volume_metadata.py +++ b/cinder/tests/api/v2/test_volume_metadata.py @@ -111,7 +111,7 @@ def return_volume(context, volume_id): 'project_id': context.project_id} -def return_volume_nonexistent(context, volume_id): +def return_volume_nonexistent(*args, **kwargs): raise exception.VolumeNotFound('bogus test message') @@ -209,7 +209,9 @@ class volumeMetaDataTest(test.TestCase): self.assertEqual(200, res.status_int) def test_delete_nonexistent_volume(self): - self.stubs.Set(db, 'volume_get', + self.stubs.Set(db, 'volume_metadata_get', + return_volume_metadata) + self.stubs.Set(db, 'volume_metadata_delete', return_volume_nonexistent) req = fakes.HTTPRequest.blank(self.url + '/key1') req.method = 'DELETE'