From: Yeray Diaz Diaz Date: Sat, 11 May 2019 13:56:08 +0000 (+0100) Subject: Additional tests for SyncClient X-Git-Tag: 0.3.0~17^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4ab7bb619d89a93d0483c60196393414b61d04f;p=thirdparty%2Fhttpx.git Additional tests for SyncClient --- diff --git a/tests/client/test_client.py b/tests/client/test_client.py index 12fc4a42..29587b4b 100644 --- a/tests/client/test_client.py +++ b/tests/client/test_client.py @@ -30,6 +30,9 @@ def test_get(server): assert response.status_code == 200 assert response.content == b"Hello, world!" assert response.text == "Hello, world!" + assert response.protocol == "HTTP/1.1" + assert response.headers + assert repr(response) == "" @threadpool @@ -69,3 +72,46 @@ def test_raw_iterator(server): for chunk in response.raw(): body += chunk assert body == b"Hello, world!" + response.close() # TODO: should Response be available as context managers? + + +@threadpool +def test_options(server): + with httpcore.SyncClient() as http: + response = http.options("http://127.0.0.1:8000/") + + assert response.status_code == 200 + assert response.reason_phrase == "OK" + + +@threadpool +def test_head(server): + with httpcore.SyncClient() as http: + response = http.head("http://127.0.0.1:8000/") + + assert response.status_code == 200 + assert response.reason_phrase == "OK" + + +@threadpool +def test_put(server): + with httpcore.SyncClient() as http: + response = http.put("http://127.0.0.1:8000/", data=b"Hello, world!") + assert response.status_code == 200 + assert response.reason_phrase == "OK" + + +@threadpool +def test_patch(server): + with httpcore.SyncClient() as http: + response = http.patch("http://127.0.0.1:8000/", data=b"Hello, world!") + assert response.status_code == 200 + assert response.reason_phrase == "OK" + + +@threadpool +def test_delete(server): + with httpcore.SyncClient() as http: + response = http.delete("http://127.0.0.1:8000/") + assert response.status_code == 200 + assert response.reason_phrase == "OK"