Exemple #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
Exemple #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."
Exemple #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."
Exemple #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."
Exemple #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
Exemple #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."