def test_index_glance_error(self): self.mox.StubOutWithMock(api, 'snapshot_list_detailed') exception = glance_exception.Error('glanceError') api.snapshot_list_detailed(IsA(http.HttpRequest)).AndRaise(exception) self.mox.StubOutWithMock(messages, 'error') messages.error(IsA(http.HttpRequest), IsA(str)) self.mox.ReplayAll() res = self.client.get(reverse('dash_snapshots', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'dash_snapshots.html') self.mox.VerifyAll()
def test_index_glance_error(self): self.mox.StubOutWithMock(api, 'snapshot_list_detailed') exception = glance_exception.Error('glanceError') api.snapshot_list_detailed(IsA(http.HttpRequest)).AndRaise(exception) self.mox.StubOutWithMock(messages, 'error') messages.error(IsA(http.HttpRequest), IsA(str)) self.mox.ReplayAll() res = self.client.get( reverse('dash_snapshots', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'django_openstack/dash/snapshots/index.html') self.mox.VerifyAll()
def test_index_client_conn_error(self): self.mox.StubOutWithMock(api, 'snapshot_list_detailed') exception = glance_exception.ClientConnectionError('clientConnError') api.snapshot_list_detailed(IsA(http.HttpRequest)).AndRaise(exception) self.mox.StubOutWithMock(messages, 'error') messages.error(IsA(http.HttpRequest), IsA(basestring)) self.mox.ReplayAll() res = self.client.get(reverse('dash_snapshots', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'django_openstack/dash/snapshots/index.html') self.mox.VerifyAll()
def test_index(self): self.mox.StubOutWithMock(api, 'snapshot_list_detailed') api.snapshot_list_detailed(IsA(http.HttpRequest)).\ AndReturn(self.images) self.mox.ReplayAll() res = self.client.get(reverse('dash_snapshots', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'dash_snapshots.html') self.assertIn('images', res.context) images = res.context['images'] self.assertEqual(len(images), 1) self.mox.VerifyAll()
def index(request, tenant_id): images = [] try: images = api.snapshot_list_detailed(request) except glance_exception.ClientConnectionError, e: msg = 'Error connecting to glance: %s' % str(e) LOG.error(msg, exc_info=True) messages.error(request, msg)
def index(request, tenant_id): images = [] try: images = api.snapshot_list_detailed(request) except glance_exception.ClientConnectionError, e: msg = _('Error connecting to glance: %s') % str(e) LOG.exception(msg) messages.error(request, msg)
def test_index(self): self.mox.StubOutWithMock(api, 'snapshot_list_detailed') api.snapshot_list_detailed(IsA(http.HttpRequest)).\ AndReturn(self.images) self.mox.ReplayAll() res = self.client.get( reverse('dash_snapshots', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'django_openstack/dash/snapshots/index.html') self.assertIn('images', res.context) images = res.context['images'] self.assertEqual(len(images), 1) self.mox.VerifyAll()