import importlib.util from pathlib import Path from typing import Final import pytest SCRIPT: Final = Path(__file__).resolve().parents[2] / ".circleci/scripts/run_migration_tests.py" SPEC: Final = importlib.util.spec_from_file_location("migration_ci", SCRIPT) assert SPEC is not None and SPEC.loader is not None MODULE: Final = importlib.util.module_from_spec(SPEC) SPEC.loader.exec_module(MODULE) @pytest.mark.parametrize( "xml,expected,exit_code,passed", ( ('', 2, 0, True), ('', 2, 0, False), ("", 1, 0, False), ("", 1, 0, False), ("", 1, 0, False), ("", 1, 1, False), ("", 1, 5, False), ("", 1, 0, False), ("', 2, 0, False), ), ) def test_only_a_complete_passing_suite_can_certify_an_image( tmp_path: Path, xml: str | None, expected: int, exit_code: int, passed: bool ) -> None: path: Final = tmp_path / "results.xml" if xml is not None: path.write_text(xml) assert MODULE.successful_junit(path, expected, exit_code) is passed