def test_nested_future_error_node(self):
        j = JsonBuilder()
        f1 = Future()
        f2 = Future()

        f1.set_result({'nested': f2})
        j.put(f1)

        self.assertEqual(j.to_string(), """{"nested": null}""")
        result = RequestResult()
        result.set_exception(
            FailedRequestException(reason='error', code='code'))

        f2.set_result({'a': result})

        self.assertEqual(
            j.to_dict(),
            {'nested': {
                'a': {
                    'error': {
                        'reason': 'error',
                        'code': 'code'
                    }
                }
            }})
Beispiel #2
0
    def test_failed_future(self):
        j = JsonBuilder()
        f = Future()
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))
        f.set_result(result)
        j.put(f)

        self.assertEqual(j.to_string(), """{"error": {"reason": "error", "code": "code"}}""")
    def test_failed_future(self):
        j = JsonBuilder()
        f = Future()
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))
        f.set_result(result)
        j.put(f)

        self.assertJsonEqual(j.to_dict(), {'error': {'reason': 'error', 'code': 'code'}})
Beispiel #4
0
    def test_failed_future(self):
        d = Doc('a')
        f = Future()
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))
        f.set_result(result)
        d.put(f)

        self.assertXmlEqual(
            d.to_etree_element(), u"""<?xml version='1.0'?>\n<a><error reason="error" code="code"/></a>"""
        )
Beispiel #5
0
    def test_failed_future(self):
        d = Doc('a')
        f = Future()
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))
        f.set_result(result)
        d.put(f)

        self.assertXmlAlmostEqual(
            d.to_etree_element(),
            """<?xml version='1.0' encoding='utf-8'?>\n<a><error reason="error" code="code"/></a>"""
        )
    def test_failed_future(self):
        j = JsonBuilder()
        f = Future()
        result = RequestResult()
        result.set_exception(
            FailedRequestException(reason='error', code='code'))
        f.set_result(result)
        j.put(f)

        self.assertEqual(j.to_dict(),
                         {'error': {
                             'reason': 'error',
                             'code': 'code'
                         }})
    def test_nested_future_error_node(self):
        j = JsonBuilder()
        f1 = Future()
        f2 = Future()

        f1.set_result({'nested': f2})
        j.put(f1)

        self.assertEqual(j.to_string(), """{"nested": null}""")
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))

        f2.set_result(
            {'a': result}
        )

        self.assertJsonEqual(
            j.to_dict(), {'nested': {'a': {'error': {'reason': 'error', 'code': 'code'}}}}
        )
Beispiel #8
0
    def test_nested_future_error_node(self):
        j = JsonBuilder()
        f1 = Future()
        f2 = Future()

        f1.set_result({'nested': f2})
        j.put(f1)

        self.assertEqual(j.to_string(), """{"nested": null}""")
        result = RequestResult()
        result.set_exception(FailedRequestException(reason='error', code='code'))

        f2.set_result(
            {'a': result}
        )

        self.assertEqual(
            j.to_string(), """{"nested": {"a": {"error": {"reason": "error", "code": "code"}}}}"""
        )
Beispiel #9
0
    def get_test_request_result():
        class FakeRequest:
            name = 'name'

        return RequestResult(FakeRequest(), None, False, False)