Cherry-pick heuristics, manifest merge, global file search, scrollbar styling, and pytest/Playwright coverage unblock review and filtered export for mmetl.
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""Unit tests for slack_export.py (mini-export fixture)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_fixture_has_expected_channels(export):
|
|
names = {c["name"] for c in export.build_summary()["channels"]}
|
|
assert names >= {"medical", "zoey", "153niagara"}
|
|
|
|
|
|
def test_normalize_message_shape(export):
|
|
msgs = export.iter_channel_messages("medical")
|
|
msg = msgs[0]
|
|
assert "id" in msg
|
|
assert "channel" in msg
|
|
assert msg["channel"] == "medical"
|
|
assert "user_name" in msg
|
|
assert "text" in msg
|
|
|
|
|
|
def test_classify_file_types(export):
|
|
assert export.classify_file({"name": "lease.pdf", "mimetype": "application/pdf"}) == "pdf"
|
|
assert export.classify_file({"name": "photo.jpg", "mimetype": "image/jpeg"}) == "image"
|
|
assert export.classify_file({"name": "data.xlsx", "mimetype": ""}) == "spreadsheet"
|
|
|
|
|
|
def test_search_channels(export):
|
|
hits = export.search_channels("med")
|
|
assert any(c["name"] == "medical" for c in hits)
|
|
assert not any(c["name"] == "zoey" for c in hits)
|
|
|
|
|
|
def test_search_global_text(export):
|
|
result = export.search_global("doctor", limit=20)
|
|
assert result["query"] == "doctor"
|
|
assert isinstance(result["messages"], list)
|
|
|
|
|
|
def test_search_files_global_images(export):
|
|
result = export.search_files_global("", file_type="image", limit=30)
|
|
assert result["file_type"] == "image"
|
|
for hit in result["hits"]:
|
|
kinds = set(hit.get("file_kinds") or [])
|
|
assert "image" in kinds
|
|
|
|
|
|
def test_channel_messages_all_sorted(export):
|
|
data = export.channel_messages_all("zoey")
|
|
assert data["channel"] == "zoey"
|
|
assert data["total"] == len(data["messages"])
|
|
times = [m.get("time") or "" for m in data["messages"]]
|
|
assert times == sorted(times)
|
|
|
|
|
|
def test_upload_path_safe(export):
|
|
rel = export.upload_relpath("F123", "my file.pdf")
|
|
assert rel == "__uploads/F123/my file.pdf"
|
|
assert ".." not in rel
|