Exemplo n.º 1
0
    def test_unicode_path(self):
        request = Mock()
        request.GET = {"member": ["1"]}
        request.method = "GET"
        request.path = "/api/0/organizations/üuuuu/"
        endpoint = Endpoint()
        result = endpoint.build_cursor_link(request, "next",
                                            "1492107369532:0:0")

        assert result == (
            "<http://testserver/api/0/organizations/%C3%BCuuuu/?member=%5B%271%27%5D&cursor=1492107369532:0:0>;"
            ' rel="next"; results="true"; cursor="1492107369532:0:0"')
Exemplo n.º 2
0
    def test_simple(self):
        request = Mock()
        request.GET = QueryDict("member=1&cursor=foo")
        request.method = "GET"
        request.path = "/api/0/organizations/"
        endpoint = Endpoint()
        result = endpoint.build_cursor_link(request, "next",
                                            "1492107369532:0:0")

        assert result == (
            "<http://testserver/api/0/organizations/?member=1&cursor=1492107369532:0:0>;"
            ' rel="next"; results="true"; cursor="1492107369532:0:0"')
Exemplo n.º 3
0
    def test_unicode_path(self):
        request = Mock()
        request.GET = {u'member': [u'1']}
        request.method = 'GET'
        request.path = '/api/0/organizations/üuuuu/'
        endpoint = Endpoint()
        result = endpoint.build_cursor_link(request, 'next',
                                            '1492107369532:0:0')

        assert result == (
            '<http://testserver/api/0/organizations/%C3%BCuuuu/?'
            'member=%5Bu%271%27%5D&cursor=1492107369532:0:0>;'
            ' rel="next"; results="true"; cursor="1492107369532:0:0\"')
Exemplo n.º 4
0
    def test_unicode_path(self):
        request = Mock()
        request.GET = {u'member': [u'1']}
        request.method = 'GET'
        request.path = '/api/0/organizations/üuuuu/'
        endpoint = Endpoint()
        result = endpoint.build_cursor_link(request, 'next', '1492107369532:0:0')

        assert result == (
            '<http://testserver/api/0/organizations/%C3%BCuuuu/?'
            'member=%5Bu%271%27%5D&cursor=1492107369532:0:0>;'
            ' rel="next"; results="true"; cursor="1492107369532:0:0\"'
        )
Exemplo n.º 5
0
    def test_non_json_content_type(self):
        self.request.META["CONTENT_TYPE"] = "text/plain"

        Endpoint().load_json_body(self.request)

        assert not self.request.json_body
Exemplo n.º 6
0
    def test_empty_request_body(self):
        self.request._body = ""

        Endpoint().load_json_body(self.request)

        assert not self.request.json_body
Exemplo n.º 7
0
    def test_invalid_json(self):
        self.request._body = "hello"

        Endpoint().load_json_body(self.request)

        assert not self.request.json_body
Exemplo n.º 8
0
    def test_json(self):
        self.request._body = '{"foo":"bar"}'

        Endpoint().load_json_body(self.request)

        assert self.request.json_body == {"foo": "bar"}