Skip to content
Myr

test_connections.py

This file

Path

tests/dispatch/test_connections.py

39 lines · 1.4 KiB · Python

Last changed by

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

History of this file

Take it

The walk stopped after 200 commits: lines older than e1ecb36 point at it.

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 1why, one step back
1from httpx import HTTPConnection

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 2–3why, one step back
2
3

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 4why, one step back
4async def test_get(server, backend):

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

lines 5–6why, one step back
5 async with HTTPConnection(origin=server.url, backend=backend) as conn:
6 response = await conn.request("GET", server.url)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 7–9why, one step back
7 await response.read()
8 assert response.status_code == 2009 assert response.content == b"Hello, world!"

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

lines 10–11why, one step back
10
11

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 12why, one step back
12async def test_post(server, backend):

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

lines 13–14why, one step back
13 async with HTTPConnection(origin=server.url, backend=backend) as conn:
14 response = await conn.request("GET", server.url, data=b"Hello, world!")

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

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

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

lines 16–17why, one step back
16
17

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 18why, one step back
18async def test_https_get_with_ssl_defaults(https_server, backend):

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

lines 19–21why, one step back
19 """
20 An HTTPS request, with default SSL configuration set on the client.21 """

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

line 22why, one step back
22 async with HTTPConnection(

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 23why, one step back
23 origin=https_server.url, verify=False, backend=backend

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

line 24why, one step back
24 ) as conn:

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 25why, one step back
25 response = await conn.request("GET", https_server.url)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 26–28why, one step back
26 await response.read()
27 assert response.status_code == 20028 assert response.content == b"Hello, world!"

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 29–30why, one step back
29
30

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 31why, one step back
31async def test_https_get_with_sll_overrides(https_server, backend):

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

lines 32–34why, one step back
32 """
33 An HTTPS request, with SSL configuration set on the request.34 """

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

lines 35–36why, one step back
35 async with HTTPConnection(origin=https_server.url, backend=backend) as conn:
36 response = await conn.request("GET", https_server.url, verify=False)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 37–39why, one step back
37 await response.read()
38 assert response.status_code == 20039 assert response.content == b"Hello, world!"