summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJohn Tran <jtran@attinteractive.com>2011-03-28 11:29:23 -0700
committerJohn Tran <jtran@attinteractive.com>2011-03-28 11:29:23 -0700
commit9ce24afab007a9b5144c8c8a8f2fcc4157ba34d7 (patch)
treed98c265d658272dad3b6cb6eb917cd243cde6c23 /nova/tests
parentc400024de45073ccc23a6738c78518365a511562 (diff)
when image_id provided cannot be found, returns more informative error message.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_cloud.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py
index 2f0571ca3..8043d4670 100644
--- a/nova/tests/test_cloud.py
+++ b/nova/tests/test_cloud.py
@@ -41,6 +41,7 @@ from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
from nova.image import local
from nova.objectstore import image
+from nova.exception import NotEmpty, NotFound
FLAGS = flags.FLAGS
@@ -85,8 +86,12 @@ class CloudTestCase(test.TestCase):
return [{'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1,
'type':'machine'}}]
+ def fake_delete(meh, context, id):
+ return None
+
self.stubs.Set(local.LocalImageService, 'show', fake_show)
self.stubs.Set(local.LocalImageService, 'detail', fake_detail)
+ self.stubs.Set(local.LocalImageService, 'delete', fake_delete)
self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show)
def tearDown(self):
@@ -234,6 +239,16 @@ class CloudTestCase(test.TestCase):
result = result['imagesSet'][0]
self.assertEqual(result['imageId'], 'ami-00000001')
+ def test_deregister_image(self):
+ deregister_image = self.cloud.deregister_image
+ """When provided a valid image, should be successful"""
+ result1 = deregister_image(self.context, 'ami-00000001')
+ self.assertEqual(result1['imageId'], 'ami-00000001')
+ """Invalid image should throw an NotFound exception"""
+ self.stubs.UnsetAll()
+ self.assertRaises(NotFound, deregister_image,
+ self.context, 'ami-bad001')
+
def test_console_output(self):
instance_type = FLAGS.default_instance_type
max_count = 1