From e2e6a6fc7e7cd40cefe20c183fcced965f13c4ed Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 19 May 2026 17:40:22 +0200 Subject: [PATCH 1/4] Unit test naming --- ....py => test_calculate_statistical_uncertainties_grid_point.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/unit_tests/production_configuration/{test_calculate_statistical_uncertainties_grid.py => test_calculate_statistical_uncertainties_grid_point.py} (100%) diff --git a/tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid.py b/tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid_point.py similarity index 100% rename from tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid.py rename to tests/unit_tests/production_configuration/test_calculate_statistical_uncertainties_grid_point.py From c4c827f47aa3a86b5f144ad74a51f049ff990e1d Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 19 May 2026 18:08:13 +0200 Subject: [PATCH 2/4] unit test module --- .github/workflows/CI-unittests.yml | 17 +++++++++++++++++ docs/changes/2193.maintenance.md | 1 + 2 files changed, 18 insertions(+) create mode 100644 docs/changes/2193.maintenance.md diff --git a/.github/workflows/CI-unittests.yml b/.github/workflows/CI-unittests.yml index 9e01717163..07dcfcb16e 100644 --- a/.github/workflows/CI-unittests.yml +++ b/.github/workflows/CI-unittests.yml @@ -66,6 +66,23 @@ jobs: echo "SIMTOOLS_DB_SIMULATION_MODEL_VERSION=$SIMTOOLS_DB_SIMULATION_MODEL_VERSION" >> "$GITHUB_ENV" echo "Simulation model set to: $SIMTOOLS_DB_SIMULATION_MODEL version $SIMTOOLS_DB_SIMULATION_MODEL_VERSION" + - name: Check unit test files exist + run: | + python - <<'PY' + from pathlib import Path + src_root = Path("src/simtools") + test_root = Path("tests/unit_tests") + missing = [] + for path in src_root.rglob("*.py"): + rel = path.relative_to(src_root) + if path.name == "__init__.py" or rel.parts[0] == "applications": + continue + if not (test_root / rel.parent / f"test_{path.stem}.py").exists(): + missing.append(str(rel)) + if missing: + raise SystemExit("Modules without unit tests:\n" + "\n".join(sorted(missing))) + PY + - name: Unit tests shell: bash -l {0} env: diff --git a/docs/changes/2193.maintenance.md b/docs/changes/2193.maintenance.md new file mode 100644 index 0000000000..807cf1523a --- /dev/null +++ b/docs/changes/2193.maintenance.md @@ -0,0 +1 @@ +Add CI tests to ensure that every simtools python has a corresponding unit test module. From 4628d5cc0f18097fb13250f1d68f0f3e9189d551 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 19 May 2026 18:16:52 +0200 Subject: [PATCH 3/4] matrix fix --- .github/workflows/CI-unittests.yml | 54 +++++++++++++------ .../unit_tests/configuration/test_defaults.py | 23 ++++++++ 2 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 tests/unit_tests/configuration/test_defaults.py diff --git a/.github/workflows/CI-unittests.yml b/.github/workflows/CI-unittests.yml index 07dcfcb16e..b2c1499657 100644 --- a/.github/workflows/CI-unittests.yml +++ b/.github/workflows/CI-unittests.yml @@ -21,7 +21,44 @@ on: types: [published] jobs: + check_unit_test_files: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash -leo pipefail {0} + + steps: + - name: checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Python setup + uses: actions/setup-python@v6 + with: + python-version: "3.12" + check-latest: true + + - name: Check unit test files exist + run: | + python - <<'PY' + from pathlib import Path + src_root = Path("src/simtools") + test_root = Path("tests/unit_tests") + missing = [] + for path in src_root.rglob("*.py"): + rel = path.relative_to(src_root) + if path.name in {"__init__.py", "_version.py"} or rel.parts[0] == "applications": + continue + if not (test_root / rel.parent / f"test_{path.stem}.py").exists(): + missing.append(str(rel)) + if missing: + raise SystemExit("Modules without unit tests:\n" + "\n".join(sorted(missing))) + PY + unit_tests: + needs: check_unit_test_files runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -66,23 +103,6 @@ jobs: echo "SIMTOOLS_DB_SIMULATION_MODEL_VERSION=$SIMTOOLS_DB_SIMULATION_MODEL_VERSION" >> "$GITHUB_ENV" echo "Simulation model set to: $SIMTOOLS_DB_SIMULATION_MODEL version $SIMTOOLS_DB_SIMULATION_MODEL_VERSION" - - name: Check unit test files exist - run: | - python - <<'PY' - from pathlib import Path - src_root = Path("src/simtools") - test_root = Path("tests/unit_tests") - missing = [] - for path in src_root.rglob("*.py"): - rel = path.relative_to(src_root) - if path.name == "__init__.py" or rel.parts[0] == "applications": - continue - if not (test_root / rel.parent / f"test_{path.stem}.py").exists(): - missing.append(str(rel)) - if missing: - raise SystemExit("Modules without unit tests:\n" + "\n".join(sorted(missing))) - PY - - name: Unit tests shell: bash -l {0} env: diff --git a/tests/unit_tests/configuration/test_defaults.py b/tests/unit_tests/configuration/test_defaults.py new file mode 100644 index 0000000000..c105c4019d --- /dev/null +++ b/tests/unit_tests/configuration/test_defaults.py @@ -0,0 +1,23 @@ +import simtools.configuration.defaults as defaults + + +def test_corsika_defaults(): + """Test default CORSIKA configuration constants.""" + assert defaults.CORSIKA_PATH == "/workdir/simulation_software/corsika7" + assert ( + defaults.CORSIKA_INTERACTION_TABLE_PATH + == "/workdir/external/simpipe/simulation_software/corsika7-interaction-tables/interaction-tables/" + ) + assert defaults.CORSIKA_HE_INTERACTION == "epos" + assert defaults.CORSIKA_LE_INTERACTION == "urqmd" + + +def test_simulation_software_defaults(): + """Test simulation software default values.""" + assert defaults.CURVED_ATMOSPHERE_MIN_ZENITH_ANGLE_DEG == 65 + assert defaults.SIMULATION_SOFTWARE_CHOICES == ( + "corsika", + "sim_telarray", + "corsika_sim_telarray", + ) + assert defaults.SIMULATION_SOFTWARE_DEFAULT == "corsika_sim_telarray" From 4726a181264236f26ecffe9b889fc755b40b7839 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 19 May 2026 18:19:19 +0200 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- docs/changes/2193.maintenance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changes/2193.maintenance.md b/docs/changes/2193.maintenance.md index 807cf1523a..62bd813d0f 100644 --- a/docs/changes/2193.maintenance.md +++ b/docs/changes/2193.maintenance.md @@ -1 +1 @@ -Add CI tests to ensure that every simtools python has a corresponding unit test module. +Add CI tests to ensure that every simtools Python module has a corresponding unit test module.