Example #1
0
    def test_no_body(self):
        request = MockRequest()
        actual = helpers.create_response(request)

        assert isinstance(actual, HttpResponse)
        assert actual.status == HTTPStatus.NO_CONTENT
        assert actual.body is None
Example #2
0
    def test_no_body_custom_status(self):
        request = MockRequest()
        actual = helpers.create_response(request, status=HTTPStatus.CREATED)

        assert isinstance(actual, HttpResponse)
        assert actual.status == HTTPStatus.CREATED
        assert actual.body is None
Example #3
0
    def test_content(self):
        request = MockRequest()

        actual = helpers.create_response(request, {"foo": "bar"})

        assert isinstance(actual, HttpResponse)
        assert actual.status == HTTPStatus.OK
        assert actual.headers['Content-Type'] == json_codec.CONTENT_TYPE
        assert json_codec.json.loads(actual.body) == {"foo": "bar"}
Example #4
0
 def start_item(self, request):
     self.calls.append('start_item')
     return create_response(request, status=202)