Пример #1
0
    def test_to_dict(self):
        test_exception = exceptions.PulpException("foo_msg")
        test_exception.error_data = {"foo": "bar"}

        result = test_exception.to_dict()

        compare_dict(
            result, {
                'code': test_exception.error_code.code,
                'description': str(test_exception),
                'data': {
                    "foo": "bar"
                },
                'sub_errors': []
            })
Пример #2
0
    def test_to_dict_nested_pulp_exception(self):
        test_exception = exceptions.PulpException("foo_msg")
        test_exception.error_data = {"foo": "bar"}

        test_exception.add_child_exception(
            exceptions.PulpCodedException(error_codes.PLP0001))

        result = test_exception.to_dict()
        child_exception = result['sub_errors'][0]
        compare_dict(
            child_exception, {
                'code': error_codes.PLP0001.code,
                'description': error_codes.PLP0001.message,
                'data': {},
                'sub_errors': []
            })
Пример #3
0
    def test_to_dict_nested_general_exception(self):
        test_exception = exceptions.PulpException("foo_msg")
        test_exception.error_data = {"foo": "bar"}

        test_exception.add_child_exception(Exception("Foo Message"))
        test_exception.add_child_exception(Exception("Bar Message"))

        result = test_exception.to_dict()
        child_exception = result['sub_errors'][0]
        compare_dict(
            child_exception, {
                'code': error_codes.PLP0000.code,
                'description': "Foo Message",
                'data': {},
                'sub_errors': []
            })
        child_exception = result['sub_errors'][1]
        compare_dict(
            child_exception, {
                'code': error_codes.PLP0000.code,
                'description': "Bar Message",
                'data': {},
                'sub_errors': []
            })
Пример #4
0
 def test_custom_message(self):
     test_exception = exceptions.PulpException("foo_msg")
     self.assertEquals(str(test_exception), "foo_msg")