def test_wrap_exception_with_notifier_defaults(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier) self.assertRaises(Exception, wrapped(bad_function_exception)) self.assertEquals(notifier.provided_publisher, None) self.assertEquals(notifier.provided_event, "bad_function_exception") self.assertEquals(notifier.provided_priority, notifier.ERROR)
def test_wrap_exception_with_notifier_defaults(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier) self.assertRaises(test.TestingException, wrapped(bad_function_exception)) self.assertEquals(notifier.provided_publisher, None) self.assertEquals(notifier.provided_event, "bad_function_exception") self.assertEquals(notifier.provided_priority, notifier.ERROR)
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier, "publisher", "event", "level") self.assertRaises(test.TestingException, wrapped(bad_function_exception)) self.assertEquals(notifier.provided_publisher, "publisher") self.assertEquals(notifier.provided_event, "event") self.assertEquals(notifier.provided_priority, "level") for key in ["exception", "args"]: self.assertTrue(key in notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier, "publisher", "event", "level") self.assertRaises(Exception, wrapped(bad_function_exception)) self.assertEquals(notifier.provided_publisher, "publisher") self.assertEquals(notifier.provided_event, "event") self.assertEquals(notifier.provided_priority, "level") for key in ['exception', 'args']: self.assertTrue(key in notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier) ctxt = context.get_admin_context() self.assertRaises(test.TestingException, wrapped(bad_function_exception), 1, ctxt, 3, zoo=3) self.assertEqual(notifier.provided_event, "bad_function_exception") self.assertEqual(notifier.provided_context, ctxt) self.assertEqual(notifier.provided_payload["args"]["extra"], 3) for key in ["exception", "args"]: self.assertIn(key, notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier) ctxt = context.get_admin_context() self.assertRaises(test.TestingException, wrapped(bad_function_exception), 1, ctxt, 3, zoo=3) self.assertEquals(notifier.provided_event, "bad_function_exception") self.assertEquals(notifier.provided_context, ctxt) for key in ['exception', 'args']: self.assertTrue(key in notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier) ctxt = context.get_admin_context() self.assertRaises(test.TestingException, wrapped(bad_function_exception), 1, ctxt, 3, zoo=3) self.assertEqual(notifier.provided_event, "bad_function_exception") self.assertEqual(notifier.provided_context, ctxt) self.assertEqual(notifier.provided_payload['args']['extra'], 3) for key in ['exception', 'args']: self.assertIn(key, notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier, "publisher") ctxt = context.get_admin_context() self.assertRaises(test.TestingException, wrapped(bad_function_exception), 1, ctxt, 3, zoo=3) self.assertEquals(notifier.provided_publisher, "publisher") self.assertEquals(notifier.provided_event, "bad_function_exception") self.assertEquals(notifier.provided_priority, notifier.ERROR) self.assertEquals(notifier.provided_context, ctxt) for key in ['exception', 'args']: self.assertTrue(key in notifier.provided_payload.keys())
def test_wrap_exception_with_notifier(self): notifier = FakeNotifier() wrapped = exception.wrap_exception(notifier, "publisher", "event", "level") ctxt = context.get_admin_context() self.assertRaises(test.TestingException, wrapped(bad_function_exception), context=ctxt) self.assertEquals(notifier.provided_publisher, "publisher") self.assertEquals(notifier.provided_event, "event") self.assertEquals(notifier.provided_priority, "level") self.assertEquals(notifier.provided_context, ctxt) for key in ['exception', 'args']: self.assertTrue(key in notifier.provided_payload.keys())
def test_wrap_exception_good_return(self): wrapped = exception.wrap_exception() self.assertEquals(99, wrapped(good_function)())
def test_wrap_exception_good_return(self): wrapped = exception.wrap_exception('foo', 'bar') self.assertEquals(99, wrapped(good_function)(1, 2))
def test_wrap_exception_throws_exception(self): wrapped = exception.wrap_exception() self.assertRaises(test.TestingException, wrapped(bad_function_exception))
def test_wrap_exception_throws_exception(self): wrapped = exception.wrap_exception() self.assertRaises(test.TestingException, wrapped(bad_function_exception), 1, 2, 3)
def test_wrap_exception_throws_exception(self): wrapped = exception.wrap_exception() self.assertRaises(Exception, wrapped(bad_function_exception))
def test_wrap_exception_throws_error(self): wrapped = exception.wrap_exception() self.assertRaises(exception.Error, wrapped(bad_function_error))
def test_wrap_exception_throws_exception(self): wrapped = exception.wrap_exception() # Note that Exception is converted to Error ... self.assertRaises(exception.Error, wrapped(bad_function_exception))
def test_wrap_exception_good_return(self): wrapped = exception.wrap_exception("foo") self.assertEqual(99, wrapped(good_function)(1, 2))