summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-28 14:59:32 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-28 14:59:32 -0700
commitc4df3d63c83c073664a9ed0abaefe2adbe4cd061 (patch)
treec0fb71ce540b49508d362fdea3cbf8229c1d4633
parentc80c0786baadf521c86ceff21288e3760aaea5bd (diff)
downloadnova-c4df3d63c83c073664a9ed0abaefe2adbe4cd061.tar.gz
nova-c4df3d63c83c073664a9ed0abaefe2adbe4cd061.tar.xz
nova-c4df3d63c83c073664a9ed0abaefe2adbe4cd061.zip
fix test for editable image
-rw-r--r--nova/tests/cloud_unittest.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py
index 8db4aeb77..cce4a5568 100644
--- a/nova/tests/cloud_unittest.py
+++ b/nova/tests/cloud_unittest.py
@@ -202,18 +202,37 @@ class CloudTestCase(test.BaseTestCase):
# data = self.cloud.get_metadata(instance(i)['private_dns_name'])
# self.assert_(data['meta-data']['ami-id'] == 'ami-%s' % i)
+ @staticmethod
+ def _fake_set_image_description(ctxt, image_id, description):
+ from nova.objectstore import handler
+ class req:
+ pass
+ request = req()
+ request.context = ctxt
+ request.args = {'image_id': [image_id],
+ 'description': [description]}
+
+ resource = handler.ImagesResource()
+ resource.render_POST(request)
+
def test_user_editable_image_endpoint(self):
pathdir = os.path.join(FLAGS.images_path, 'ami-testing')
os.mkdir(pathdir)
- info = {}
+ info = {'isPublic': False}
with open(os.path.join(pathdir, 'info.json'), 'w') as f:
json.dump(info, f)
- yield self.cloud.set_image_description(self.context, 'ami-testing',
- 'Foo Img')
img = image.Image('ami-testing')
- self.assertEqual('Foo Img', img.metadata['displayDescription'])
- self.cloud.set_image_description(self.context, 'ami-testing', '')
- self.assert_(not 'displayDescription' in img.metadata)
+ # self.cloud.set_image_description(self.context, 'ami-testing',
+ # 'Foo Img')
+ # NOTE(vish): Above won't work unless we start objectstore or create
+ # a fake version of api/ec2/images.py conn that can
+ # call methods directly instead of going through boto.
+ # for now, just cheat and call the method directly
+ self._fake_set_image_description(self.context, 'ami-testing',
+ 'Foo Img')
+ self.assertEqual('Foo Img', img.metadata['description'])
+ self._fake_set_image_description(self.context, 'ami-testing', '')
+ self.assertEqual('', img.metadata['description'])
def test_update_of_instance_display_fields(self):
inst = db.instance_create({}, {})