56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
def test_sync_endpoint_and_status(client):
|
|
sync_resp = client.post("/sync", json={"branch": "main", "require_latest": True})
|
|
assert sync_resp.status_code == 200
|
|
sync_payload = sync_resp.json()
|
|
assert sync_payload["ok"] is True
|
|
assert sync_payload["branch"] == "main"
|
|
assert sync_payload["commit_hash"]
|
|
assert sync_payload["synced_at"]
|
|
|
|
status_resp = client.get("/status")
|
|
assert status_resp.status_code == 200
|
|
status_payload = status_resp.json()
|
|
assert status_payload["ok"] is True
|
|
assert any(item["branch"] == "main" for item in status_payload["workspaces"])
|
|
|
|
|
|
def test_concurrent_branch_queries(client):
|
|
def run(body: dict):
|
|
return client.post("/query", json=body)
|
|
|
|
with ThreadPoolExecutor(max_workers=2) as pool:
|
|
fut_main = pool.submit(
|
|
run,
|
|
{"branch": "main", "query_type": "search", "query": "main-exclusive-signal", "require_latest": True},
|
|
)
|
|
fut_month = pool.submit(
|
|
run,
|
|
{
|
|
"branch": "memory/2026-03",
|
|
"query_type": "search",
|
|
"query": "monthly-exclusive-signal",
|
|
"require_latest": True,
|
|
},
|
|
)
|
|
|
|
resp_main = fut_main.result()
|
|
resp_month = fut_month.result()
|
|
|
|
assert resp_main.status_code == 200
|
|
assert resp_month.status_code == 200
|
|
|
|
payload_main = resp_main.json()
|
|
payload_month = resp_month.json()
|
|
|
|
assert payload_main["branch"] == "main"
|
|
assert payload_month["branch"] == "memory/2026-03"
|
|
assert payload_main["resolved_workspace"] != payload_month["resolved_workspace"]
|
|
|
|
assert payload_main["results"]
|
|
assert payload_month["results"]
|