Ejemplo n.º 1
0
    def test_GET(self):
        client = HTTPClient(url="http://httpbin.org/get",
                            requests=webtest.TestApp(Application()))

        response = client.GET()

        assert '"Host": "httpbin.org"' in response
        assert '"args": {}' in response
    def test_GET(self):
        client = HTTPClient(url="http://httpbin.org/get")
        
        with requests_mock.Mocker() as m:
            m.get(client._url, text='{"Host": "httpbin.org", "args": {}}')
            response = client.GET()

        assert '"Host": "httpbin.org"' in response
        assert '"args": {}' in response
Ejemplo n.º 3
0
    def test_GET_params(self):
        client = HTTPClient(url="http://httpbin.org/get?alpha=1",
                            requests=webtest.TestApp(Application()))

        response = client.GET()
        response = json.loads(response)

        assert response["headers"]["Host"] == "httpbin.org"
        assert response["args"] == {"alpha": "1"}
    def test_GET_params(self):
        client = HTTPClient(url="http://httpbin.org/get?alpha=1")
        
        with requests_mock.Mocker() as m:
            m.get(client._url, text='''{"headers": {"Host": "httpbin.org"},
                                        "args": {"alpha": "1"}}''')
            response = client.GET()

        response = json.loads(response)
        assert response["headers"]["Host"] == "httpbin.org"
        assert response["args"] == {"alpha": "1"}