summaryrefslogtreecommitdiff
path: root/glance/tests/unit/v2/test_images_resource.py
diff options
context:
space:
mode:
Diffstat (limited to 'glance/tests/unit/v2/test_images_resource.py')
-rw-r--r--glance/tests/unit/v2/test_images_resource.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/glance/tests/unit/v2/test_images_resource.py b/glance/tests/unit/v2/test_images_resource.py
index 1786be2..83e2caf 100644
--- a/glance/tests/unit/v2/test_images_resource.py
+++ b/glance/tests/unit/v2/test_images_resource.py
@@ -1973,8 +1973,8 @@ class TestImagesController(base.IsolatedUnitTest):
1973 as long as the image has fewer than the limited number of image 1973 as long as the image has fewer than the limited number of image
1974 locations after the transaction. 1974 locations after the transaction.
1975 """ 1975 """
1976 self.stubs.Set(store, 'get_size_from_backend', 1976 self.mock_object(store, 'get_size_from_backend',
1977 unit_test_utils.fake_get_size_from_backend) 1977 unit_test_utils.fake_get_size_from_backend)
1978 self.config(show_multiple_locations=True) 1978 self.config(show_multiple_locations=True)
1979 request = unit_test_utils.get_fake_request() 1979 request = unit_test_utils.get_fake_request()
1980 1980
@@ -2039,8 +2039,8 @@ class TestImagesController(base.IsolatedUnitTest):
2039 2039
2040 def test_update_remove_location(self): 2040 def test_update_remove_location(self):
2041 self.config(show_multiple_locations=True) 2041 self.config(show_multiple_locations=True)
2042 self.stubs.Set(store, 'get_size_from_backend', 2042 self.mock_object(store, 'get_size_from_backend',
2043 unit_test_utils.fake_get_size_from_backend) 2043 unit_test_utils.fake_get_size_from_backend)
2044 2044
2045 request = unit_test_utils.get_fake_request() 2045 request = unit_test_utils.get_fake_request()
2046 new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}} 2046 new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}}
@@ -2080,8 +2080,9 @@ class TestImagesController(base.IsolatedUnitTest):
2080 def fake_delete_image_location_from_backend(self, *args, **kwargs): 2080 def fake_delete_image_location_from_backend(self, *args, **kwargs):
2081 raise Exception('fake_backend_exception') 2081 raise Exception('fake_backend_exception')
2082 2082
2083 self.stubs.Set(self.store_utils, 'delete_image_location_from_backend', 2083 self.mock_object(self.store_utils,
2084 fake_delete_image_location_from_backend) 2084 'delete_image_location_from_backend',
2085 fake_delete_image_location_from_backend)
2085 2086
2086 request = unit_test_utils.get_fake_request() 2087 request = unit_test_utils.get_fake_request()
2087 changes = [ 2088 changes = [
@@ -2288,8 +2289,8 @@ class TestImagesController(base.IsolatedUnitTest):
2288 def test_delete_in_use(self): 2289 def test_delete_in_use(self):
2289 def fake_safe_delete_from_backend(self, *args, **kwargs): 2290 def fake_safe_delete_from_backend(self, *args, **kwargs):
2290 raise store.exceptions.InUseByStore() 2291 raise store.exceptions.InUseByStore()
2291 self.stubs.Set(self.store_utils, 'safe_delete_from_backend', 2292 self.mock_object(self.store_utils, 'safe_delete_from_backend',
2292 fake_safe_delete_from_backend) 2293 fake_safe_delete_from_backend)
2293 request = unit_test_utils.get_fake_request() 2294 request = unit_test_utils.get_fake_request()
2294 self.assertRaises(webob.exc.HTTPConflict, self.controller.delete, 2295 self.assertRaises(webob.exc.HTTPConflict, self.controller.delete,
2295 request, UUID1) 2296 request, UUID1)
@@ -2297,8 +2298,8 @@ class TestImagesController(base.IsolatedUnitTest):
2297 def test_delete_has_snapshot(self): 2298 def test_delete_has_snapshot(self):
2298 def fake_safe_delete_from_backend(self, *args, **kwargs): 2299 def fake_safe_delete_from_backend(self, *args, **kwargs):
2299 raise store.exceptions.HasSnapshot() 2300 raise store.exceptions.HasSnapshot()
2300 self.stubs.Set(self.store_utils, 'safe_delete_from_backend', 2301 self.mock_object(self.store_utils, 'safe_delete_from_backend',
2301 fake_safe_delete_from_backend) 2302 fake_safe_delete_from_backend)
2302 request = unit_test_utils.get_fake_request() 2303 request = unit_test_utils.get_fake_request()
2303 self.assertRaises(webob.exc.HTTPConflict, self.controller.delete, 2304 self.assertRaises(webob.exc.HTTPConflict, self.controller.delete,
2304 request, UUID1) 2305 request, UUID1)
@@ -3584,6 +3585,7 @@ class TestImagesSerializer(test_utils.BaseTestCase):
3584 3585
3585 """ 3586 """
3586 class ImageLocations(object): 3587 class ImageLocations(object):
3588
3587 def __len__(self): 3589 def __len__(self):
3588 raise exception.Forbidden() 3590 raise exception.Forbidden()
3589 3591
@@ -4140,6 +4142,7 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
4140 4142
4141 4143
4142class TestImagesSerializerDirectUrl(test_utils.BaseTestCase): 4144class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
4145
4143 def setUp(self): 4146 def setUp(self):
4144 super(TestImagesSerializerDirectUrl, self).setUp() 4147 super(TestImagesSerializerDirectUrl, self).setUp()
4145 self.serializer = glance.api.v2.images.ResponseSerializer() 4148 self.serializer = glance.api.v2.images.ResponseSerializer()
@@ -4225,6 +4228,7 @@ class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
4225 4228
4226 4229
4227class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase): 4230class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
4231
4228 def test_default_disk_formats(self): 4232 def test_default_disk_formats(self):
4229 schema = glance.api.v2.images.get_schema() 4233 schema = glance.api.v2.images.get_schema()
4230 expected = [None, 'ami', 'ari', 'aki', 'vhd', 'vhdx', 'vmdk', 4234 expected = [None, 'ami', 'ari', 'aki', 'vhd', 'vhdx', 'vmdk',
@@ -4254,6 +4258,7 @@ class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
4254 4258
4255 4259
4256class TestImageSchemaDeterminePropertyBasis(test_utils.BaseTestCase): 4260class TestImageSchemaDeterminePropertyBasis(test_utils.BaseTestCase):
4261
4257 def test_custom_property_marked_as_non_base(self): 4262 def test_custom_property_marked_as_non_base(self):
4258 self.config(allow_additional_image_properties=False) 4263 self.config(allow_additional_image_properties=False)
4259 custom_image_properties = { 4264 custom_image_properties = {