Skip to content
Myr

test_connections.py

This file

Path

tests/dispatch/test_connections.py

45 lines · 1.4 KiB · Python

Last changed by

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

History of this file

Take it

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

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

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

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

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/")

Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7

line 10why, one step back
10 await response.read()

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

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

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

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

Status code tweaks (#77)Tom Christiebefore adoptionc12c271

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

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

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

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

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

Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7

line 31why, one step back
31 await response.read()

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

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

Response.contentTom Christiebefore adoption4c55113

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

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

lines 34–36why, one step back
34
3536@pytest.mark.asyncio

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

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

Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7

line 43why, one step back
43 await response.read()

Rejig test and tighten up models APITom Christiebefore adoptiondea4d42

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

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

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