Skip to content

Commit 1dd6de3

Browse files
committed
test: cover Agent Ready discovery contracts
1 parent 979ec6e commit 1dd6de3

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

examples/safe-agent-api/tests/test_api.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,29 @@ def test_playground_is_public_and_self_contained() -> None:
1010
assert response.status_code == 200
1111
assert "Safe Agent Playground" in response.text
1212
assert "/v1/run-demo" in response.text
13+
assert "Why this demo exists" in response.text
1314
assert 'rel="canonical"' in response.text
1415
assert 'rel="describedby" href="/llms.txt"' in response.text
16+
assert 'property="og:title"' in response.text
1517
assert 'type="application/ld+json"' in response.text
1618
assert response.headers["x-content-type-options"] == "nosniff"
1719
assert "connect-src 'self'" in response.headers["content-security-policy"]
20+
assert response.headers["x-robots-tag"].startswith("index, follow")
21+
22+
23+
def test_head_root_is_supported() -> None:
24+
response = client.head("/")
25+
assert response.status_code == 200
26+
assert response.headers["content-type"].startswith("text/html")
27+
28+
29+
def test_root_supports_markdown_content_negotiation() -> None:
30+
response = client.get("/", headers={"Accept": "text/markdown"})
31+
assert response.status_code == 200
32+
assert response.headers["content-type"].startswith("text/markdown")
33+
assert "# Safe Agent Playground" in response.text
34+
assert "## Sitemap" in response.text
35+
assert 'rel="canonical"' in response.headers["link"]
1836

1937

2038
def test_health() -> None:
@@ -23,7 +41,7 @@ def test_health() -> None:
2341
assert response.json() == {
2442
"status": "ok",
2543
"service": "safe-agent-api",
26-
"version": "0.5.0",
44+
"version": "0.6.0",
2745
}
2846

2947

@@ -33,6 +51,7 @@ def test_discovery_documents_are_public() -> None:
3351
assert llms.headers["content-type"].startswith("text/plain")
3452
assert "# Safe Agent Playground" in llms.text
3553
assert "/openapi.json" in llms.text
54+
assert "/index.md" in llms.text
3655

3756
full = client.get("/llms-full.txt")
3857
assert full.status_code == 200
@@ -47,6 +66,9 @@ def test_discovery_documents_are_public() -> None:
4766
assert sitemap_xml.status_code == 200
4867
assert sitemap_xml.headers["content-type"].startswith("application/xml")
4968
assert "<urlset" in sitemap_xml.text
69+
assert "<lastmod>2026-09-07</lastmod>" in sitemap_xml.text
70+
assert "<loc>https://safe-agent-playground.onrender.com/</loc>" in sitemap_xml.text
71+
assert "playground.md" not in sitemap_xml.text
5072

5173
sitemap_md = client.get("/sitemap.md")
5274
assert sitemap_md.status_code == 200
@@ -55,11 +77,19 @@ def test_discovery_documents_are_public() -> None:
5577
agents = client.get("/AGENTS.md")
5678
assert agents.status_code == 200
5779
assert "Model suggestion is not authorization" in agents.text
80+
assert "## Installation" in agents.text
81+
assert "## Configuration" in agents.text
82+
assert "## Usage" in agents.text
83+
assert "## Examples" in agents.text
5884

59-
markdown = client.get("/playground.md")
85+
markdown = client.get("/index.md")
6086
assert markdown.status_code == 200
6187
assert markdown.headers["content-type"].startswith("text/markdown")
88+
assert markdown.text.startswith("---\n")
89+
assert "canonical: https://safe-agent-playground.onrender.com/" in markdown.text
90+
assert "last_modified: 2026-09-07" in markdown.text
6291
assert "## Scenarios" in markdown.text
92+
assert "## Sitemap" in markdown.text
6393

6494

6595
def test_read_is_allowed_in_same_tenant() -> None:

0 commit comments

Comments
 (0)