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

1import pytest23from httpcore import HTTPConnection, Request, SSLConfig456@pytest.mark.asyncio7async def test_get(server):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)12    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/")20    assert response.status_code == 20021    assert response.content == b"Hello, world!"222324@pytest.mark.asyncio25async def test_post(server):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)30    assert response.status_code == 200