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(basestring)) self.mox.ReplayAll() res = self.client.get(reverse('horizon:nova:snapshots:index')) self.assertTemplateUsed(res, 'nova/snapshots/index.html')
def test_index_glance_error(self): self.mox.StubOutWithMock(api, 'image_list_detailed') exception = glance_exception.Error('glanceError') api.image_list_detailed(IsA(http.HttpRequest)).AndRaise(exception) self.mox.StubOutWithMock(api, 'tenant_quota_get') api.tenant_quota_get(IsA(http.HttpRequest), self.TEST_TENANT) \ .AndReturn({}) self.mox.StubOutWithMock(messages, 'error') messages.error(IsA(http.HttpRequest), IsA(basestring)) self.mox.ReplayAll() res = self.client.get(IMAGES_INDEX_URL) self.assertTemplateUsed(res, 'nova/images/index.html')
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 __get_backend(self): if not self.__backend: backend_name = self.__pivot.value if backend_name not in self.__backends: raise exception.Error('Invalid backend: %s' % backend_name) backend = self.__backends[backend_name] if type(backend) == type(tuple()): name = backend[0] fromlist = backend[1] else: name = backend fromlist = backend self.__backend = __import__(name, None, None, fromlist) logging.info('backend %s', self.__backend) return self.__backend
def test_index_glance_error(self): self.mox.StubOutWithMock(api, 'token_get_tenant') api.token_get_tenant(IsA(http.HttpRequest), self.TEST_TENANT) self.mox.StubOutWithMock(api, 'image_list_detailed') exception = glance_exception.Error('glanceError') api.image_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_images', args=[self.TEST_TENANT])) self.assertTemplateUsed(res, 'django_openstack/dash/images/index.html') self.mox.VerifyAll()
def test_download_metadata_glance_error(self): IMAGE_ID = '1' self.mox.StubOutWithMock(api, 'image_get_meta') exception = glance_exception.Error('glanceError') api.image_get_meta(IsA(http.HttpRequest), IMAGE_ID).AndRaise(exception) self.mox.StubOutWithMock(messages, 'error') messages.error(IsA(http.HttpRequest), IsA(str)) self.mox.ReplayAll() res = self.client.get( reverse('dash_metadata_download', args=[self.TEST_TENANT, IMAGE_ID])) self.assertRedirectsNoFollow( res, reverse('dash_images_metadata', args=[self.TEST_TENANT])) self.mox.VerifyAll()