Esempio n. 1
0
    def test_process_serialize_object_inside_objects(self):

        import decimal

        router = Router()
        request = request_generator('/test')

        class FakeData(object):
            data = 'hdsihas8h9277t27gsj'
            pepe = decimal.Decimal('10.0')

        class FakeResult(object):
            name = 'Test'
            data = FakeData()

        resp = router._process(FakeResult(), request)
        self.assertIsInstance(resp, response.Ok)
        self.assertEqual(
            resp.subject, {
                'data': {
                    'pepe': '10.0',
                    'data': 'hdsihas8h9277t27gsj'
                },
                'name': 'Test'
            })
Esempio n. 2
0
    def test_process_return_objects_json_converted(self):

        router = Router()
        request = request_generator('/test')

        class FakeResult(object):
            name = 'Test'
            type = 'JSON'

        resp = router._process(FakeResult(), request)
        self.assertIsInstance(resp, response.Ok)
        self.assertEqual(resp.subject, {'name': 'Test', 'type': 'JSON'})
Esempio n. 3
0
    def test_process_return_objects_json_converted(self):

        router = Router()
        request = request_generator('/test')

        class FakeResult(object):
            name = 'Test'
            type = 'JSON'

        resp = router._process(FakeResult(), request)
        self.assertIsInstance(resp, response.Ok)
        self.assertEqual(resp.subject, {'name': 'Test', 'type': 'JSON'})
Esempio n. 4
0
    def test_process_serialize_object_inside_objects(self):

        import decimal

        router = Router()
        request = request_generator('/test')

        class FakeData(object):
            data = 'hdsihas8h9277t27gsj'
            pepe = decimal.Decimal('10.0')

        class FakeResult(object):
            name = 'Test'
            data = FakeData()

        resp = router._process(FakeResult(), request)
        self.assertIsInstance(resp, response.Ok)
        self.assertEqual(resp.subject, {
            'data': {'pepe': '10.0', 'data': 'hdsihas8h9277t27gsj'},
            'name': 'Test'
        })
Esempio n. 5
0
    def test_process_return_unknown_on_none_result(self):

        router = Router()
        self.assertIsInstance(router._process(None, None), response.Unknown)
Esempio n. 6
0
    def test_process_return_unknown_on_none_result(self):

        router = Router()
        self.assertIsInstance(router._process(None, None), response.Unknown)