From 6076325a39e0d387afcc2d25e61efad1e058427a Mon Sep 17 00:00:00 2001 From: Eiichi Aikawa Date: Fri, 26 Sep 2014 15:37:31 +0900 Subject: [PATCH] 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 --- cinder/tests/api/v1/test_volume_metadata.py | 6 ++++-- cinder/tests/api/v2/test_volume_metadata.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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' -- 2.45.2