Skip to content
Myr

test_connections.py

This file

Path

tests/dispatch/test_connections.py

42 lines · 1.3 KiB · Python

Last changed by

Status code tweaks (#77)Tom Christiebefore adoptionc12c271

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

line 8why, one step back
8 conn = HTTPConnection(origin="http://127.0.0.1:8000/")

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

line 9why, one step back
9 response = await conn.request("GET", "http://127.0.0.1:8000/")

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

lines 10–14why, one step back
10 assert response.status_code == 200
11 assert response.content == b"Hello, world!"121314@pytest.mark.asyncio

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 15–16why, one step back
15async def test_post(server):
16 conn = HTTPConnection(origin="http://127.0.0.1:8000/")

Status code tweaks (#77)Tom Christiebefore adoptionc12c271

lines 17–19why, one step back
17 response = await conn.request(
18 "GET", "http://127.0.0.1:8000/", data=b"Hello, world!"19 )

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

line 20why, one step back
20 assert response.status_code == 200

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 21–30why, one step back
21
2223@pytest.mark.asyncio24async def test_https_get_with_ssl_defaults(https_server):25 """26 An HTTPS request, with default SSL configuration set on the client.27 """28 conn = HTTPConnection(origin="https://127.0.0.1:8001/", verify=False)29 response = await conn.request("GET", "https://127.0.0.1:8001/")30 assert response.status_code == 200

Response.contentTom Christiebefore adoption4c55113

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

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

lines 32–34why, one step back
32
3334@pytest.mark.asyncio

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 35–40why, one step back
35async def test_https_get_with_sll_overrides(https_server):
36 """37 An HTTPS request, with SSL configuration set on the request.38 """39 conn = HTTPConnection(origin="https://127.0.0.1:8001/")40 response = await conn.request("GET", "https://127.0.0.1:8001/", verify=False)

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

line 41why, one step back
41 assert response.status_code == 200

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

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