summaryrefslogtreecommitdiff
path: root/horizon/dashboards/nova/images_and_snapshots/images/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'horizon/dashboards/nova/images_and_snapshots/images/tests.py')
-rw-r--r--horizon/dashboards/nova/images_and_snapshots/images/tests.py45
1 files changed, 42 insertions, 3 deletions
diff --git a/horizon/dashboards/nova/images_and_snapshots/images/tests.py b/horizon/dashboards/nova/images_and_snapshots/images/tests.py
index c9aa1056..b93a7da1 100644
--- a/horizon/dashboards/nova/images_and_snapshots/images/tests.py
+++ b/horizon/dashboards/nova/images_and_snapshots/images/tests.py
@@ -24,16 +24,54 @@ from django.core.urlresolvers import reverse
from horizon import api
from horizon import test
-from mox import IsA
+from mox import IgnoreArg, IsA
IMAGES_INDEX_URL = reverse('horizon:nova:images_and_snapshots:index')
class ImageViewTests(test.TestCase):
+ def test_image_create_get(self):
+ url = reverse('horizon:nova:images_and_snapshots:images:create')
+ res = self.client.get(url)
+ self.assertTemplateUsed(res,
+ 'nova/images_and_snapshots/images/create.html')
+
+ @test.create_stubs({api.glance: ('image_create',)})
+ def test_image_create_post(self):
+ data = {
+ 'name': u'Ubuntu 11.10',
+ 'copy_from': u'http://cloud-images.ubuntu.com/releases/'
+ u'oneiric/release/ubuntu-11.10-server-cloudimg'
+ u'-amd64-disk1.img',
+ 'disk_format': u'qcow2',
+ 'minimum_disk': 15,
+ 'minimum_ram': 512,
+ 'is_public': 1,
+ 'method': 'CreateImageForm'
+ }
+
+ api.glance.image_create(IsA(http.HttpRequest),
+ container_format="bare",
+ copy_from=data['copy_from'],
+ disk_format=data['disk_format'],
+ is_public=True,
+ min_disk=data['minimum_disk'],
+ min_ram=data['minimum_ram'],
+ name=data['name']). \
+ AndReturn(self.images.first())
+ self.mox.ReplayAll()
+
+ url = reverse('horizon:nova:images_and_snapshots:images:create')
+ res = self.client.post(url, data)
+
+ self.assertNoFormErrors(res)
+ self.assertEqual(res.status_code, 302)
+
+ @test.create_stubs({api.glance: ('image_get',)})
def test_image_detail_get(self):
image = self.images.first()
- self.mox.StubOutWithMock(api.glance, 'image_get')
+
api.glance.image_get(IsA(http.HttpRequest), str(image.id)) \
.AndReturn(self.images.first())
self.mox.ReplayAll()
@@ -45,9 +83,10 @@ class ImageViewTests(test.TestCase):
'nova/images_and_snapshots/images/detail.html')
self.assertEqual(res.context['image'].name, image.name)
+ @test.create_stubs({api.glance: ('image_get',)})
def test_image_detail_get_with_exception(self):
image = self.images.first()
- self.mox.StubOutWithMock(api.glance, 'image_get')
+
api.glance.image_get(IsA(http.HttpRequest), str(image.id)) \
.AndRaise(self.exceptions.glance)
self.mox.ReplayAll()