def _get_fake_response(self, raw_response=None, exc=False): if exc: return messaging.Response(self.ctxt, 'fake', test.TestingException(), True) if raw_response is None: raw_response = 'fake-response' return messaging.Response(self.ctxt, 'fake', raw_response, False)
def fake_get_flavor_by_flavor_id(flavorid, ctxt=None, read_deleted='yes'): if flavorid == 'failtest': raise exception.FlavorNotFound(flavor_id=flavorid) elif not str(flavorid) == '1234': raise Exception("This test expects flavorid 1234, not %s" % flavorid) if read_deleted != 'no': raise test.TestingException("Should not be reading deleted") return fake_db_flavor(flavorid=flavorid)
def _abort(self): claim = None try: with self._claim(memory_mb=4096) as claim: raise test.TestingException("abort") except test.TestingException: pass return claim
def test_send_api_fault(self): self.flags(notify_api_faults=True) exception = None try: # Get a real exception with a call stack. raise test.TestingException("junk") except test.TestingException as e: exception = e notifications.send_api_fault("http://example.com/foo", 500, exception) self.assertEqual(1, len(fake_notifier.NOTIFICATIONS)) n = fake_notifier.NOTIFICATIONS[0] self.assertEqual(n.priority, 'ERROR') self.assertEqual(n.event_type, 'api.fault') self.assertEqual(n.payload['url'], 'http://example.com/foo') self.assertEqual(n.payload['status'], 500) self.assertIsNotNone(n.payload['exception'])
def get_metric_names(self): raise test.TestingException()
def get_metrics(self, **kwargs): raise test.TestingException()
def no_mtu(*args, **kwargs): if 'mtu' in kwargs: raise test.TestingException("mtu should not pass through") return [{}]
def error_apply(): raise test.TestingException()
def async_wrapper(): raise test.TestingException()
def _fake_exit(error): raise test.TestingException()
def _test(self, *args): raise test.TestingException("shouldn't be called")
def fake_grab_target_cells(filter_properties): call_info['num_tries'] += 1 raise test.TestingException()
def bad_function_exception(self, context, extra, blah="a", boo="b", zoo=None): raise test.TestingException()
def test_get_image_meta_unexpected_exception(self): error = test.TestingException() with testtools.ExpectedException(test.TestingException): self._test_get_image_meta_exception(error)
def bad_fetcher(image_id): raise test.TestingException("just plain bad.")