""" Regression test: `trim --episode N` without having run `detect` first used to silently do nothing at all -- no output, no error, exit code 0. An explicit --episode with no ledger entry is a real mistake, not a normal part of batch trimming, and should say so plainly. """ import os import subprocess import sys import tempfile import unittest class TestTrimWithoutDetect(unittest.TestCase): def test_explicit_episode_with_no_ledger_entry_errors_clearly(self): with tempfile.TemporaryDirectory() as cache_dir: # No detect has ever been run, so there is no ledger.db at # all yet -- this must still produce a clear, actionable # error rather than crashing on a missing file or silently # exiting 0. result = subprocess.run( [sys.executable, "-m", "hpr_stripper.cli", "--cache-dir", cache_dir, "trim", "--episode", "999999"], cwd=os.path.dirname(os.path.dirname(os.path.abspath(__file__))), capture_output=True, text=True, ) self.assertNotEqual(result.returncode, 0) self.assertIn("detect --episode 999999", result.stdout + result.stderr) if __name__ == "__main__": unittest.main()