Cherry-pick heuristics, manifest merge, global file search, scrollbar styling, and pytest/Playwright coverage unblock review and filtered export for mmetl.
113 lines
3.3 KiB
Python
113 lines
3.3 KiB
Python
"""HTTP API tests against the review server (mini-export)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
|
|
def test_health(api):
|
|
data = api["get"]("/api/health")
|
|
assert data["ok"] is True
|
|
assert "mini-export" in data["export_path"]
|
|
|
|
|
|
def test_summary(api):
|
|
data = api["get"]("/api/summary")
|
|
assert data["channel_count"] >= 3
|
|
assert data["total_messages"] > 0
|
|
|
|
|
|
def test_channels_list(api):
|
|
data = api["get"]("/api/channels")
|
|
names = {c["name"] for c in data["channels"]}
|
|
assert "medical" in names
|
|
med = next(c for c in data["channels"] if c["name"] == "medical")
|
|
assert med["status"] == "partial"
|
|
assert med["import_mode"] == "pick"
|
|
|
|
|
|
def test_channel_messages_all(api):
|
|
data = api["get"]("/api/channels/medical/messages/all")
|
|
assert data["channel"] == "medical"
|
|
assert data["total"] == len(data["messages"])
|
|
assert data["total"] > 0
|
|
|
|
|
|
def test_search_messages(api):
|
|
data = api["get"]("/api/search?q=doctor&limit=10")
|
|
assert "messages" in data
|
|
|
|
|
|
def test_search_files(api):
|
|
data = api["get"]("/api/search-files?type=pdf&q=&limit=10")
|
|
assert data["file_type"] == "pdf"
|
|
assert "hits" in data
|
|
|
|
|
|
def test_manifest_roundtrip(api):
|
|
got = api["get"]("/api/manifest")
|
|
assert "channels" in got
|
|
got["global_notes"] = "pytest was here"
|
|
api["post"]("/api/manifest", {"global_notes": "pytest was here", "channels": got["channels"], "users": {}})
|
|
again = api["get"]("/api/manifest")
|
|
assert again["global_notes"] == "pytest was here"
|
|
|
|
|
|
def test_manifest_merge_preserves_other_channel_picks(api):
|
|
api["post"](
|
|
"/api/manifest",
|
|
{
|
|
"channels": {
|
|
"medical": {
|
|
"import": True,
|
|
"status": "partial",
|
|
"import_mode": "pick",
|
|
"reviewed": True,
|
|
"messages": {
|
|
"medical:test:1": {
|
|
"action": "import",
|
|
"checked": True,
|
|
"files": {},
|
|
"notes": "",
|
|
"merge_target": "",
|
|
}
|
|
},
|
|
}
|
|
}
|
|
},
|
|
)
|
|
api["post"](
|
|
"/api/manifest",
|
|
{
|
|
"channels": {
|
|
"zoey": {
|
|
"import": True,
|
|
"status": "partial",
|
|
"import_mode": "pick",
|
|
"reviewed": True,
|
|
"messages": {
|
|
"zoey:test:2": {
|
|
"action": "import",
|
|
"checked": True,
|
|
"files": {},
|
|
"notes": "",
|
|
"merge_target": "",
|
|
}
|
|
},
|
|
}
|
|
}
|
|
},
|
|
)
|
|
merged = api["get"]("/api/manifest")
|
|
assert "medical:test:1" in merged["channels"]["medical"]["messages"]
|
|
assert "zoey:test:2" in merged["channels"]["zoey"]["messages"]
|
|
|
|
|
|
def test_static_index(api):
|
|
import urllib.request
|
|
|
|
with urllib.request.urlopen(f"{api['base']}/", timeout=5) as resp:
|
|
html = resp.read().decode()
|
|
assert "Slack import review" in html
|
|
assert "filter-status" in html
|