Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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())
Example #4
0
 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())
Example #8
0
 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())
Example #9
0
 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())
Example #10
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception()
     self.assertEquals(99, wrapped(good_function)())
Example #11
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception('foo', 'bar')
     self.assertEquals(99, wrapped(good_function)(1, 2))
Example #12
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(test.TestingException,
                       wrapped(bad_function_exception))
Example #13
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception()
     self.assertEquals(99, wrapped(good_function)())
Example #14
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(test.TestingException,
                       wrapped(bad_function_exception), 1, 2, 3)
Example #15
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(Exception, wrapped(bad_function_exception))
Example #16
0
 def test_wrap_exception_throws_error(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(exception.Error, wrapped(bad_function_error))
Example #17
0
 def test_wrap_exception_throws_error(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(exception.Error, wrapped(bad_function_error))
Example #18
0
 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))