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

1import pytest23from httpx import HTTPConnection456@pytest.mark.asyncio7async def test_get(server):8    conn = HTTPConnection(origin="http://127.0.0.1:8000/")9    response = await conn.request("GET", "http://127.0.0.1:8000/")10    await response.read()11    assert response.status_code == 20012    assert response.content == b"Hello, world!"131415@pytest.mark.asyncio16async def test_post(server):17    conn = HTTPConnection(origin="http://127.0.0.1:8000/")18    response = await conn.request(19        "GET", "http://127.0.0.1:8000/", data=b"Hello, world!"20    )21    assert response.status_code == 200222324@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/")31    await response.read()32    assert response.status_code == 20033    assert response.content == b"Hello, world!"343536@pytest.mark.asyncio37async 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)43    await response.read()44    assert response.status_code == 20045    assert response.content == b"Hello, world!"