def test_do_not_serialize_404(self, json): req = self.factory.make_req() resp = self.factory.make_resp() resp.status = falcon.HTTP_NOT_FOUND resource = mock.Mock() middleware = JSONSerializerMiddleware() middleware.process_response(req, resp, resource) self.assertFalse(json.dumps.called)
def test_serializes_to_json(self): req = self.factory.make_req() req.context['marshalled'] = {'hello': 'world'} resp = self.factory.make_resp() resource = mock.Mock() middleware = JSONSerializerMiddleware() middleware.process_response(req, resp, resource) self.assertEqual('{"hello":"world"}', resp.body)