datasette/tests/test_cli_serve_server.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
838 B
Python
Raw Permalink Normal View History

import socket
2026-08-13 16:22:30 -07:00
import httpx2
import pytest
@pytest.mark.serial
def test_serve_localhost_http(ds_localhost_http_server):
2026-08-13 16:22:30 -07:00
response = httpx2.get("http://localhost:8041/_memory.json")
assert {
"database": "_memory",
"path": "/_memory",
"tables": [],
}.items() <= response.json().items()
@pytest.mark.serial
2021-07-10 16:46:49 -07:00
@pytest.mark.skipif(
not hasattr(socket, "AF_UNIX"), reason="Requires socket.AF_UNIX support"
)
def test_serve_unix_domain_socket(ds_unix_domain_socket_server):
_, uds = ds_unix_domain_socket_server
2026-08-13 16:22:30 -07:00
transport = httpx2.HTTPTransport(uds=uds)
client = httpx2.Client(transport=transport)
response = client.get("http://localhost/_memory.json")
assert {
"database": "_memory",
"path": "/_memory",
"tables": [],
}.items() <= response.json().items()