feat: add operations health and domain setup polish
This commit is contained in:
@@ -18,6 +18,42 @@ def test_domains_empty(client: TestClient):
|
||||
assert data == []
|
||||
|
||||
|
||||
def test_create_domain_without_reports(authed_client: TestClient):
|
||||
"""A monitored domain can be created before its first report arrives."""
|
||||
response = authed_client.post(
|
||||
"/api/v1/domains/domains",
|
||||
json={"name": "Example.COM.", "description": "Primary mail domain"},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
assert response.json()["name"] == "example.com"
|
||||
|
||||
list_response = authed_client.get("/api/v1/domains/domains")
|
||||
assert list_response.status_code == 200
|
||||
assert list_response.json()[0]["name"] == "example.com"
|
||||
assert list_response.json()[0]["reports_count"] == 0
|
||||
|
||||
|
||||
def test_create_domain_rejects_duplicates(authed_client: TestClient):
|
||||
"""Creating the same monitored domain twice returns a conflict."""
|
||||
first = authed_client.post("/api/v1/domains/domains", json={"name": "example.com"})
|
||||
second = authed_client.post("/api/v1/domains/domains", json={"name": "EXAMPLE.com"})
|
||||
|
||||
assert first.status_code == 201
|
||||
assert second.status_code == 409
|
||||
|
||||
|
||||
def test_operations_health_endpoint(authed_client: TestClient):
|
||||
"""Detailed health includes database, scheduler, import, and report sections."""
|
||||
response = authed_client.get("/api/v1/health/operations")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["service"] == "dmarq"
|
||||
assert data["database"]["ok"] is True
|
||||
assert "scheduler" in data
|
||||
assert "imports" in data
|
||||
assert "reports" in data
|
||||
|
||||
|
||||
def test_reports_upload_invalid_extension(client: TestClient):
|
||||
"""Test that uploading a file with an unsupported extension returns 400."""
|
||||
response = client.post(
|
||||
|
||||
Reference in New Issue
Block a user