コード例 #1
0
ファイル: test_exception.py プロジェクト: sidx64/magnum
    def test_wrap_exception_with_notifier(self):
        test_exc = TestMagnumException(name="NAME")

        def bad_function(self, context, extra, blah="a", boo="b", zoo=None):
            raise test_exc

        expected_context = 'context'
        expected_event_type = 'bad_function'
        expected_payload = {
            'exception': test_exc,
            'private': {
                'args': {
                    'self': None,
                    'context': expected_context,
                    'extra': 1,
                    'blah': 'a',
                    'boo': 'b',
                    'zoo': 3
                }
            }
        }

        notifier = mock.MagicMock()
        wrapped = exception.wrap_exception(notifier)

        self.assertRaises(TestMagnumException,
                          wrapped(bad_function),
                          None,
                          expected_context,
                          1,
                          zoo=3)

        notifier.error.assert_called_once_with(expected_context,
                                               expected_event_type,
                                               expected_payload)
コード例 #2
0
ファイル: test_exception.py プロジェクト: Gobella/magnum
    def test_wrap_exception_with_notifier(self):
        test_exc = TestMagnumException(name="NAME")

        def bad_function(self, context, extra, blah="a", boo="b", zoo=None):
            raise test_exc

        expected_context = "context"
        expected_event_type = "bad_function"
        expected_payload = {
            "exception": test_exc,
            "private": {
                "args": {"self": None, "context": expected_context, "extra": 1, "blah": "a", "boo": "b", "zoo": 3}
            },
        }

        notifier = mock.MagicMock()
        wrapped = exception.wrap_exception(notifier)

        self.assertRaises(TestMagnumException, wrapped(bad_function), None, expected_context, 1, zoo=3)

        notifier.error.assert_called_once_with(expected_context, expected_event_type, expected_payload)
コード例 #3
0
ファイル: test_exception.py プロジェクト: yanjianwei/magnum
    def test_wrap_exception_with_notifier(self):
        test_exc = TestMagnumException(name="NAME")

        def bad_function(self, context, extra, blah="a", boo="b", zoo=None):
            raise test_exc

        expected_context = 'context'
        expected_event_type = 'bad_function'
        expected_payload = {
            'exception': test_exc, 'private': {'args': {
                'self': None, 'context': expected_context, 'extra': 1,
                'blah': 'a', 'boo': 'b', 'zoo': 3}}}

        notifier = mock.MagicMock()
        wrapped = exception.wrap_exception(notifier)

        self.assertRaises(
            TestMagnumException, wrapped(bad_function), None,
            expected_context, 1, zoo=3)

        notifier.error.assert_called_once_with(
            expected_context, expected_event_type, expected_payload)
コード例 #4
0
ファイル: test_exception.py プロジェクト: sidx64/magnum
    def test_wrap_exception_good_return(self):
        def good_function(self, context):
            return 99

        wrapped = exception.wrap_exception()
        self.assertEqual(99, wrapped(good_function)(1, 2))
コード例 #5
0
ファイル: test_exception.py プロジェクト: yanjianwei/magnum
    def test_wrap_exception_good_return(self):
        def good_function(self, context):
            return 99

        wrapped = exception.wrap_exception()
        self.assertEqual(99, wrapped(good_function)(1, 2))