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

1from httpx import HTTPConnection234async def test_get(server, backend):5    async with HTTPConnection(origin=server.url, backend=backend) as conn:6        response = await conn.request("GET", server.url)7        await response.read()8        assert response.status_code == 2009        assert response.content == b"Hello, world!"101112async def test_post(server, backend):13    async with HTTPConnection(origin=server.url, backend=backend) as conn:14        response = await conn.request("GET", server.url, data=b"Hello, world!")15        assert response.status_code == 200161718async def test_https_get_with_ssl_defaults(https_server, backend):19    """20    An HTTPS request, with default SSL configuration set on the client.21    """22    async with HTTPConnection(23        origin=https_server.url, verify=False, backend=backend24    ) as conn:25        response = await conn.request("GET", https_server.url)26        await response.read()27        assert response.status_code == 20028        assert response.content == b"Hello, world!"293031async def test_https_get_with_sll_overrides(https_server, backend):32    """33    An HTTPS request, with SSL configuration set on the request.34    """35    async with HTTPConnection(origin=https_server.url, backend=backend) as conn:36        response = await conn.request("GET", https_server.url, verify=False)37        await response.read()38        assert response.status_code == 20039        assert response.content == b"Hello, world!"