示例#1
0
    def test_POST(self):
        client = HTTPClient(url="http://httpbin.org/post?alpha=1",
                            requests=webtest.TestApp(Application()))

        response = client.POST(beta=2)
        response = json.loads(response)

        assert response["headers"]["Host"] == "httpbin.org"
        assert response["args"] == {"alpha": "1"}
        assert response["form"] == {"beta": "2"}
    def test_POST(self):
        client = HTTPClient(url="http://httpbin.org/post?alpha=1")
        
        with requests_mock.Mocker() as m:
            m.post(client._url, json={"headers": {"Host": "httpbin.org"},
                                      "args": {"alpha": "1"},
                                      "form": {"beta": "2"}})
            response = client.POST(beta=2)

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