confluence_web/backend/dev/fake_confluence.py
Artur Mukhamadiev e65fbf4b67 backend: FastAPI backend track handoff (contract revision 1)
FastAPI app, upstream Confluence/model adapters, authoritative history,
rootless container lifecycle, artifact storage and downloads, fake peers
under backend/dev, tests under tests/backend. Root pytest.ini deselects
the live marker by default; requirements gain the backend dependencies.
2026-09-14 21:57:54 +03:00

19 lines
1.1 KiB
Python

"""Explicit network-free Confluence substitute for development mode."""
import httpx
from backend.confluence import ConfluenceClient
def create_client(**kwargs):
async def respond(request):
if request.headers.get("authorization") != "Bearer dev-pat":
return httpx.Response(401)
path = request.url.path
if path.endswith("/rest/api/space"):
return httpx.Response(200, json={"results": [{"key": "OPS", "name": "Operations"}], "totalSize": 1})
if path.endswith("/rest/api/content/search"):
return httpx.Response(200, json={"results": [{"id": "847291", "title": "Deployment Guide", "space": {"key": "OPS"}, "excerpt": "Deployment steps"}], "totalSize": 1})
if path.endswith("/rest/api/content/847291"):
return httpx.Response(200, json={"id": "847291", "title": "Deployment Guide", "space": {"key": "OPS"}, "body": {"storage": {"value": "<p>Deploy service X using the release checklist.</p>"}}})
return httpx.Response(404)
return ConfluenceClient(**kwargs, transport=httpx.MockTransport(respond))