Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 5
0
 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())
Exemplo n.º 6
0
 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())
Exemplo n.º 7
0
 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 10
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception()
     self.assertEquals(99, wrapped(good_function)())
Exemplo n.º 11
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception('foo', 'bar')
     self.assertEquals(99, wrapped(good_function)(1, 2))
Exemplo n.º 12
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(test.TestingException,
                       wrapped(bad_function_exception))
Exemplo n.º 13
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception()
     self.assertEquals(99, wrapped(good_function)())
Exemplo n.º 14
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(test.TestingException,
                       wrapped(bad_function_exception), 1, 2, 3)
Exemplo n.º 15
0
 def test_wrap_exception_throws_exception(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(Exception, wrapped(bad_function_exception))
Exemplo n.º 16
0
 def test_wrap_exception_throws_error(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(exception.Error, wrapped(bad_function_error))
Exemplo n.º 17
0
 def test_wrap_exception_throws_error(self):
     wrapped = exception.wrap_exception()
     self.assertRaises(exception.Error, wrapped(bad_function_error))
Exemplo n.º 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))
Exemplo n.º 19
0
 def test_wrap_exception_good_return(self):
     wrapped = exception.wrap_exception("foo")
     self.assertEqual(99, wrapped(good_function)(1, 2))