| 1 | import importlib.util |
| 2 | import unittest |
| 3 | from pathlib import Path |
| 4 | from unittest import mock |
| 5 | |
| 6 | |
| 7 | def load_verify_module(): |
| 8 | path = Path(__file__).resolve().parents[1] / "skills" / "last30days" / "scripts" / "verify_v3.py" |
| 9 | spec = importlib.util.spec_from_file_location("verify_v3_module", path) |
| 10 | module = importlib.util.module_from_spec(spec) |
| 11 | assert spec and spec.loader |
| 12 | spec.loader.exec_module(module) |
| 13 | return module |
| 14 | |
| 15 | |
| 16 | class VerifyV3Tests(unittest.TestCase): |
| 17 | def test_parser_defaults(self): |
| 18 | module = load_verify_module() |
| 19 | parser = module.build_parser() |
| 20 | args = parser.parse_args([]) |
| 21 | self.assertEqual(args.baseline, "HEAD~1") |
| 22 | self.assertEqual(args.candidate, "WORKTREE") |
| 23 | self.assertFalse(args.skip_eval) |
| 24 | self.assertFalse(args.skip_latency) |
| 25 | |
| 26 | def test_smoke_and_latency_request_raw_json_profile(self): |
| 27 | module = load_verify_module() |
| 28 | completed = mock.Mock(stdout='{"clusters": [], "ranked_candidates": []}') |
| 29 | with mock.patch.object(module, "run_command", return_value=completed) as run: |
| 30 | module.SMOKE_CASES = [("auto", ["--quick"])] |
| 31 | module.LATENCY_PROFILES = [("quick", ["--quick"])] |
| 32 | module.LATENCY_TOPICS = ["topic"] |
| 33 | module.verify_smoke() |
| 34 | module.verify_latency() |
| 35 | |
| 36 | commands = [call.args[0] for call in run.call_args_list] |
| 37 | self.assertTrue(all("--json-profile=raw" in command for command in commands)) |
| 38 | |
| 39 | |
| 40 | if __name__ == "__main__": |
| 41 | unittest.main() |
| 42 |