Files
slack-sieve/tests/test_auto_cherry_pick_main.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

50 lines
1.6 KiB
Python

"""Integration test for auto-cherry-pick main() on mini-export."""
from __future__ import annotations
import json
import sys
from pathlib import Path
import pytest
REPO = Path(__file__).resolve().parents[1]
@pytest.fixture
def cherry_pick_module():
import importlib.util
path = REPO / "scripts" / "auto-cherry-pick.py"
spec = importlib.util.spec_from_file_location("auto_cherry_pick_main", path)
mod = importlib.util.module_from_spec(spec)
assert spec.loader
spec.loader.exec_module(mod)
return mod
def test_main_dry_run_on_fixture(cherry_pick_module, fixture_export_path, tmp_path, monkeypatch):
manifest = tmp_path / "manifest.json"
monkeypatch.setattr(cherry_pick_module, "MANIFEST_PATH", manifest)
monkeypatch.setattr(cherry_pick_module, "DEFAULT_EXPORT", fixture_export_path)
monkeypatch.setattr(sys, "argv", ["auto-cherry-pick.py", "--dry-run"])
assert cherry_pick_module.main() == 0
def test_main_writes_pick_manifest(cherry_pick_module, fixture_export_path, tmp_path, monkeypatch):
manifest = tmp_path / "manifest.json"
monkeypatch.setattr(cherry_pick_module, "MANIFEST_PATH", manifest)
monkeypatch.setattr(cherry_pick_module, "DEFAULT_EXPORT", fixture_export_path)
monkeypatch.setattr(sys, "argv", ["auto-cherry-pick.py"])
assert cherry_pick_module.main() == 0
data = json.loads(manifest.read_text())
picks = sum(
1
for ch in data["channels"].values()
for m in ch.get("messages", {}).values()
if m.get("action") == "import"
)
assert picks > 0
assert "medical" in data["channels"]
assert data["channels"]["medical"]["import_mode"] == "pick"