Files
slack-sieve/tests/test_cherry_pick_extended.py
T
ilia 4b034d19f6
CI / skip-ci-check (push) Successful in 4s
CI / secret-scan (push) Failing after 2s
CI / python-ci (push) Successful in 25s
Add triage tests, prepare-export, and UI fixes for Levkin migration.
Cherry-pick heuristics, manifest merge, global file search, scrollbar styling, and pytest/Playwright coverage unblock review and filtered export for mmetl.
2026-06-03 15:42:48 -04:00

64 lines
2.2 KiB
Python

"""Additional auto-cherry-pick heuristic coverage."""
from __future__ import annotations
def test_informative_image_casual_name(cherry_pick):
f = {"name": "MVIMG_20190105.jpg", "mimetype": "image/jpeg"}
assert not cherry_pick.informative_image(f, "nice photo")
assert cherry_pick.informative_image(
f, "Invoice total $1,200 due 416-555-0100"
)
def test_informative_filename(cherry_pick):
assert cherry_pick.informative_filename("lease_agreement.pdf")
assert not cherry_pick.informative_filename("IMG_0001.jpg")
def test_msg_selection_skips_old_draft(cherry_pick):
msg = {
"id": "ch:1",
"files": [
{"id": "D1", "name": "draft_v1.docx"},
{"id": "D2", "name": "photo.jpg", "mimetype": "image/jpeg"},
],
}
sel = cherry_pick.msg_selection(msg, latest_draft_files={"D1"})
assert sel["files"].get("D1") is True
assert "D2" not in sel["files"] or sel["files"].get("D2") is True # image w/ name
def test_draft_group_key_strips_draft_prefix(cherry_pick):
key = cherry_pick.draft_group_key("draft_-_hot_plate_v2.docx")
assert "draft" not in key.split()[0] or "hot" in key
assert "hot" in key.replace("_", " ")
def test_text_is_factual_requires_signals(cherry_pick):
assert not cherry_pick.text_is_factual("sounds good thanks")
assert cherry_pick.text_is_factual("Pay $1,500 to TD account 12345")
def test_is_doc_and_image(cherry_pick):
assert cherry_pick.is_doc({"name": "x.pdf"})
assert cherry_pick.is_image({"name": "x.jpg", "mimetype": "image/jpeg"})
def test_channel_entry_skip_shape(cherry_pick):
entry = cherry_pick.channel_entry_skip("note")
assert entry["status"] == "skip"
assert entry["messages"] == {}
def test_reset_only_writes(empty_manifest, cherry_pick, tmp_path, monkeypatch):
path, _manifest = empty_manifest
path.write_text(__import__("json").dumps(_manifest, indent=2) + "\n", encoding="utf-8")
monkeypatch.setattr(cherry_pick, "MANIFEST_PATH", path)
import sys
monkeypatch.setattr(sys, "argv", ["auto-cherry-pick.py", "--reset"])
assert cherry_pick.main() == 0
saved = __import__("json").loads(path.read_text())
assert saved["channels"] == {}