Пример #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."