mattrguerra/meridian-skillsmainPrivate on GitHub, published here in full

test_offline_checks.py

Language Python1.8 KB52 lines

tests/test_offline_checks.py

  1. """The offline checks: the production-speed-csv fixture and both Bitrix --mock runs.
  2. None of these touch the network or need credentials. The Bitrix scripts read
  3. config.json when one exists, so run these on a checkout without a local config.
  4. """
  5. import subprocess
  6. import sys
  7. from pathlib import Path
  8. ROOT = Path(__file__).resolve().parent.parent
  9. SKILLS = ROOT / "skills"
  10. def run(args, cwd=ROOT):
  11. return subprocess.run(
  12. [sys.executable, *args], cwd=cwd, capture_output=True, text=True, timeout=120
  13. )
  14. def test_speed_csv_matches_expected_fixture(tmp_path):
  15. scripts = SKILLS / "production-speed-csv" / "scripts"
  16. out = tmp_path / "speeds.csv"
  17. result = run(
  18. ["build_speed_csv.py", "fixtures/category-10x10-booths.html", str(out)],
  19. cwd=scripts,
  20. )
  21. assert result.returncode == 0, result.stderr
  22. assert out.read_bytes() == (scripts / "fixtures" / "expected.csv").read_bytes()
  23. def test_task_router_mock_dry_run():
  24. result = run([str(SKILLS / "bitrix-task-router" / "scripts" / "bitrix_router.py"), "--mock"])
  25. assert result.returncode == 0, result.stderr
  26. for task_id in ("1001", "1002", "1003", "1004", "1005"):
  27. assert task_id in result.stdout
  28. assert "RUSH + even -> hazel" in result.stdout
  29. assert "odd -> rafael" in result.stdout
  30. assert "Dry run." in result.stdout
  31. def test_tracker_mock_digest():
  32. result = run([str(SKILLS / "bitrix-tracker" / "scripts" / "bitrix_tracker.py"), "--mock"])
  33. assert result.returncode == 0, result.stderr
  34. # The sample tasks are dated well in the past, so these counts hold on any later day.
  35. for bucket in (
  36. "OVERDUE: 2",
  37. "UNASSIGNED: 1",
  38. "STALE (no movement): 4",
  39. "CHANGED IN LAST 24H: 0",
  40. ):
  41. assert bucket in result.stdout