Exemplo n.º 1
0
 def test_renderer_has_bytes_adapter_by_default(self):
     renderer = CorniceRenderer()
     self.assertEqual(
         renderer.components.adapters.lookup((providedBy(bytes()), ),
                                             IJSONAdapter),
         bytes_adapter,
     )
Exemplo n.º 2
0
    def test_renderer_render_errors(self):
        renderer = CorniceRenderer()
        request = mock.MagicMock()

        class FakeErrors(object):
            status = 418

            def __json__(self, request):
                return ["error_1", "error_2"]

        request.errors = FakeErrors()

        result = renderer.render_errors(request)
        self.assertIsInstance(result, JSONError)
        self.assertEqual(result.status_int, 418)
        self.assertEqual(result.json_body, {
            "status": "error",
            "errors": ["error_1", "error_2"]
        })
Exemplo n.º 3
0
 def test_renderer_calls_render_method(self):
     renderer = CorniceRenderer()
     self.assertEqual(renderer(info=None), renderer.render)
Exemplo n.º 4
0
 def test_renderer_is_pyramid_renderer_subclass(self):
     self.assertIsInstance(CorniceRenderer(), JSON)