"""The --selftest switch must check the build without touching Chrome or Waystar.""" import ChargeBilledAutomation as bot def test_selftest_without_pdfs_passes_and_says_so(capsys): assert bot.self_test([]) == 0 assert "SELFTEST OK" in capsys.readouterr().out def test_selftest_fails_for_unreadable_pdf(capsys, tmp_path): assert bot.self_test([str(tmp_path / "missing.pdf")]) == 1 assert "SELFTEST FAILED" in capsys.readouterr().out def test_selftest_never_starts_chrome(monkeypatch): monkeypatch.setattr(bot, "kill_all_chrome", lambda: (_ for _ in ()).throw(AssertionError("Chrome touched"))) monkeypatch.setattr(bot, "start_chrome_debug", lambda *a: (_ for _ in ()).throw(AssertionError("Chrome touched"))) assert bot.self_test([]) == 0