Ensuring the exception handler for the image detail page works.
Change-Id: Ia39f1c48f89a0798e832f267dd35103c77f707c7
This commit is contained in:
parent
5c7ea2254b
commit
e206ba6a4c
@ -20,12 +20,16 @@
|
||||
|
||||
from django import http
|
||||
from django.core.urlresolvers import reverse
|
||||
from keystoneclient import exceptions as keystone_exceptions
|
||||
from mox import IgnoreArg, IsA
|
||||
|
||||
from glance.common import exception as glance_exception
|
||||
|
||||
from horizon import api
|
||||
from horizon import test
|
||||
|
||||
from keystoneclient import exceptions as keystone_exceptions
|
||||
|
||||
from mox import IgnoreArg, IsA
|
||||
|
||||
|
||||
IMAGES_INDEX_URL = reverse('horizon:nova:images_and_snapshots:index')
|
||||
|
||||
@ -219,8 +223,20 @@ class ImageViewTests(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:nova:images_and_snapshots:images:detail',
|
||||
reverse('horizon:nova:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
self.assertTemplateUsed(res,
|
||||
'nova/images_and_snapshots/images/detail.html')
|
||||
self.assertEqual(res.context['image'].name, image.name)
|
||||
|
||||
def test_image_detail_get_with_exception(self):
|
||||
image = self.images.first()
|
||||
self.mox.StubOutWithMock(api.glance, 'image_get_meta')
|
||||
api.glance.image_get_meta(IsA(http.HttpRequest), str(image.id)) \
|
||||
.AndRaise(glance_exception.NotFound)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:nova:images_and_snapshots:images:detail',
|
||||
args=[image.id]))
|
||||
self.assertRedirectsNoFollow(res, IMAGES_INDEX_URL)
|
||||
|
@ -23,8 +23,6 @@ Views for managing Nova images.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from django import shortcuts
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@ -180,8 +178,8 @@ class DetailView(views.APIView):
|
||||
try:
|
||||
image = api.glance.image_get_meta(self.request, kwargs['image_id'])
|
||||
except:
|
||||
redirect = reverse('horizon:nova:images_and_snapshots:index')
|
||||
exceptions.handle(request, _('Unable to retrieve details for '
|
||||
'instance "%s".') % image_id,
|
||||
redirect=redirect)
|
||||
shortcuts.redirect('horizon:nova:images_and_snapshots:index')
|
||||
return {'image': image}
|
||||
|
Loading…
Reference in New Issue
Block a user