"""Explicitly selected E2E files must keep all their scenarios. A daemon scenario cannot detect that the local gate omitted it. """ from pathlib import Path import sys import unittest from unittest.mock import patch sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "e2e")) import e2e_select # noqa: E402 class E2ESelectionTests(unittest.TestCase): def test_every_smoke_method_exists(self): # A renamed or moved scenario left in SMOKE fails only the default # local gate, which --full and CI never run. for target in e2e_select.SMOKE: with self.subTest(target=target): path, _, name = target.partition(":") source = (e2e_select.E2E / path).read_text() cls, _, method = name.partition(".") self.assertRegex(source, rf"(?m)^class {cls}\b") self.assertRegex(source, rf"(?m)^ def {method}\(") def test_changed_file_supersedes_its_smoke_method_at_any_budget(self): module = "daemon_test.py" smoke = next(name for name in e2e_select.SMOKE if name.startswith(module + ":")) for duration in (1, 120): with ( self.subTest(duration=duration), patch.object(e2e_select, "durations", return_value={module: duration}), ): selected, _ = e2e_select.select(["e2e/daemon_test.py"]) self.assertIn(module, selected) self.assertNotIn(smoke, selected) def test_smoke_method_charges_only_its_own_duration(self): module = "daemon_test.py" smoke = next(name for name in e2e_select.SMOKE if name.startswith(module + ":")) optional = "schedule_test.py" with patch.object( e2e_select, "durations", return_value={module: 200, smoke: 2, optional: 5} ): selected, _ = e2e_select.select(["misc/schedule.gleam"]) self.assertIn(smoke, selected) self.assertIn(optional, selected) def test_deleted_test_file_is_not_requested_from_runner(self): selected, _ = e2e_select.select(["e2e/retired_scenario_test.py"]) self.assertNotIn("retired_scenario_test.py", selected)