2021-02-11 16:53:20 -08:00
|
|
|
import httpx
|
2021-04-02 20:42:28 -07:00
|
|
|
import pytest
|
2021-07-10 16:37:30 -07:00
|
|
|
import socket
|
2021-02-11 16:53:20 -08:00
|
|
|
|
|
|
|
|
|
2021-04-02 20:42:28 -07:00
|
|
|
@pytest.mark.serial
|
2021-02-11 16:53:20 -08:00
|
|
|
def test_serve_localhost_http(ds_localhost_http_server):
|
2025-12-13 12:16:57 -08:00
|
|
|
with httpx.Client() as client:
|
|
|
|
|
response = client.get("http://localhost:8041/_memory.json")
|
|
|
|
|
assert {
|
|
|
|
|
"database": "_memory",
|
|
|
|
|
"path": "/_memory",
|
|
|
|
|
"tables": [],
|
|
|
|
|
}.items() <= response.json().items()
|
2021-02-11 16:53:20 -08:00
|
|
|
|
|
|
|
|
|
2021-07-10 16:37:30 -07:00
|
|
|
@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"
|
|
|
|
|
)
|
2021-07-10 16:37:30 -07:00
|
|
|
def test_serve_unix_domain_socket(ds_unix_domain_socket_server):
|
|
|
|
|
_, uds = ds_unix_domain_socket_server
|
|
|
|
|
transport = httpx.HTTPTransport(uds=uds)
|
2025-12-13 12:16:57 -08:00
|
|
|
try:
|
|
|
|
|
with httpx.Client(transport=transport) as client:
|
|
|
|
|
response = client.get("http://localhost/_memory.json")
|
|
|
|
|
assert {
|
|
|
|
|
"database": "_memory",
|
|
|
|
|
"path": "/_memory",
|
|
|
|
|
"tables": [],
|
|
|
|
|
}.items() <= response.json().items()
|
|
|
|
|
finally:
|
|
|
|
|
transport.close()
|