Skip to content
Myr

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 file

Take it

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

lines 1–2why, one step back
1import pytest
2

Merge pull request #57 from yeraydiazdiaz/test-httpsTom Christiebefore adoptionc27c635

line 3why, one step back
3from httpcore import HTTPConnection, Request, SSLConfig

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

lines 4–7why, one step back
4
56@pytest.mark.asyncio7async def test_get(server):

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 8–11why, one step back
8 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 back
12 assert response.status_code == 200
13 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 back
20 assert response.status_code == 200

Response.contentTom Christiebefore adoption4c55113

line 21why, one step back
21 assert response.content == b"Hello, world!"

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

lines 22–25why, one step back
22
2324@pytest.mark.asyncio25async def test_post(server):

Merge pull request #55 from encode/drop-adaptersTom Christiebefore adoptiond72a144

lines 26–29why, one step back
26 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 back
30 assert response.status_code == 200