示例#1
0
    def test_valid(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({"QUERY_STRING": ":action=browse", "PATH_INFO": "/pypi"})
        resp = tween(request)

        assert resp is response
示例#2
0
    def test_invalid_path(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({"PATH_INFO": "/projects/abouÅt"})
        resp = tween(request)

        assert resp is not response
        assert resp.status_code == 400
        assert resp.detail == "Invalid bytes in URL."
示例#3
0
    def test_invalid_qsl(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({"QUERY_STRING": "%Aaction=browse"})
        resp = tween(request)

        assert resp is not response
        assert resp.status_code == 400
        assert resp.detail == "Invalid bytes in query string."
示例#4
0
    def test_invalid_qsl(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({"QUERY_STRING": "%Aaction=browse"})
        resp = tween(request)

        assert resp is not response
        assert resp.status_code == 400
        assert resp.detail == "Invalid bytes in query string."
示例#5
0
    def test_valid(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({
            "QUERY_STRING": ":action=browse",
            "PATH_INFO": "/pypi",
        })
        resp = tween(request)

        assert resp is response
示例#6
0
    def test_invalid_path(self):
        response = pretend.stub()
        handler = pretend.call_recorder(lambda request: response)

        tween = config.junk_encoding_tween_factory(handler, pretend.stub())

        request = Request({
            "PATH_INFO": "/projects/abouÅt",
        })
        resp = tween(request)

        assert resp is not response
        assert resp.status_code == 400
        assert resp.detail == "Invalid bytes in URL."