test_connections.py
This file
Path
tests/dispatch/test_connections.py
30 lines · 982 bytes · Python
Last changed by
Merge pull request #57 from yeraydiazdiaz/test-httpsTom Christiebefore adoptionc27c635
History of this fileTake it
Rejig test and tighten up models APITom Christiebefore adoptiondea4d42
lines 1–2why, one step back1import pytest2Merge pull request #57 from yeraydiazdiaz/test-httpsTom Christiebefore adoptionc27c635
line 3why, one step back3from httpcore import HTTPConnection, Request, SSLConfigRejig test and tighten up models APITom Christiebefore adoptiondea4d42
lines 4–7why, one step back456@pytest.mark.asyncio7async def test_get(server):Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
lines 8–11why, one step back8 conn = HTTPConnection(origin="http://127.0.0.1:8000/")9 request = Request("GET", "http://127.0.0.1:8000/")10 request.prepare()11 response = await conn.send(request)Merge pull request #57 from yeraydiazdiaz/test-httpsTom Christiebefore adoptionc27c635
lines 12–19why, one step back12 assert response.status_code == 20013 assert response.content == b"Hello, world!"141516@pytest.mark.asyncio17async def test_https_get(https_server):18 http = HTTPConnection(origin="https://127.0.0.1:8001/", ssl=SSLConfig(verify=False))19 response = await http.request("GET", "https://127.0.0.1:8001/")Rejig test and tighten up models APITom Christiebefore adoptiondea4d42
line 20why, one step back20 assert response.status_code == 200Response.contentTom Christiebefore adoption4c55113
line 21why, one step back21 assert response.content == b"Hello, world!"Rejig test and tighten up models APITom Christiebefore adoptiondea4d42
lines 22–25why, one step back222324@pytest.mark.asyncio25async def test_post(server):Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144
lines 26–29why, one step back26 conn = HTTPConnection(origin="http://127.0.0.1:8000/")27 request = Request("GET", "http://127.0.0.1:8000/", data=b"Hello, world!")28 request.prepare()29 response = await conn.send(request)Rejig test and tighten up models APITom Christiebefore adoptiondea4d42
line 30why, one step back30 assert response.status_code == 200