test_offline_checks.py
Language Python1.8 KB52 lines
"""The offline checks: the production-speed-csv fixture and both Bitrix --mock runs.None of these touch the network or need credentials. The Bitrix scripts readconfig.json when one exists, so run these on a checkout without a local config."""import subprocessimport sysfrom pathlib import PathROOT = Path(__file__).resolve().parent.parentSKILLS = ROOT / "skills"def run(args, cwd=ROOT):return subprocess.run([sys.executable, *args], cwd=cwd, capture_output=True, text=True, timeout=120)def test_speed_csv_matches_expected_fixture(tmp_path):scripts = SKILLS / "production-speed-csv" / "scripts"out = tmp_path / "speeds.csv"result = run(["build_speed_csv.py", "fixtures/category-10x10-booths.html", str(out)],cwd=scripts,)assert result.returncode == 0, result.stderrassert out.read_bytes() == (scripts / "fixtures" / "expected.csv").read_bytes()def test_task_router_mock_dry_run():result = run([str(SKILLS / "bitrix-task-router" / "scripts" / "bitrix_router.py"), "--mock"])assert result.returncode == 0, result.stderrfor task_id in ("1001", "1002", "1003", "1004", "1005"):assert task_id in result.stdoutassert "RUSH + even -> hazel" in result.stdoutassert "odd -> rafael" in result.stdoutassert "Dry run." in result.stdoutdef test_tracker_mock_digest():result = run([str(SKILLS / "bitrix-tracker" / "scripts" / "bitrix_tracker.py"), "--mock"])assert result.returncode == 0, result.stderr# The sample tasks are dated well in the past, so these counts hold on any later day.for bucket in ("OVERDUE: 2","UNASSIGNED: 1","STALE (no movement): 4","CHANGED IN LAST 24H: 0",):assert bucket in result.stdout