From 9027b675d2e8a1ce82e2f86f0c931f188d9e53c3 Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Wed, 9 Nov 2022 17:04:04 +0000 Subject: [PATCH] move some tests inside proper test suite to help with coverage --- .github/workflows/ci.yml | 6 ------ ceci_example/example_stages.py | 1 + tests/test_executables.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/test_executables.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbad7be..0b362d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,13 +35,7 @@ jobs: - name: Tests run: | - ceci tests/test.yml - ceci --dry-run tests/test.yml - ceci --flow-chart test-flow.png tests/test.yml - test -f test-flow.png pytest --cov=ceci - # add a test with the memory monitor and profiling switched on - python3 -m ceci_example PZEstimationPipe --DM=./tests/inputs/dm.txt --fiducial_cosmology=./tests/inputs/fiducial_cosmology.txt --config=./tests/config.yml --photoz_pdfs=./tests/outputs/photoz_pdfs.txt --memmon=1 --cprofile=profile.stats - name: Upload coverage to Codecov diff --git a/ceci_example/example_stages.py b/ceci_example/example_stages.py index 4135629..92ae5d5 100644 --- a/ceci_example/example_stages.py +++ b/ceci_example/example_stages.py @@ -32,6 +32,7 @@ class PZEstimationPipe(PipelineStage): name = "PZEstimationPipe" inputs = [("DM", TextFile), ("fiducial_cosmology", TextFile)] outputs = [("photoz_pdfs", TextFile)] + parallel = False def run(self): for inp, _ in self.inputs: diff --git a/tests/test_executables.py b/tests/test_executables.py new file mode 100644 index 0000000..a2123ec --- /dev/null +++ b/tests/test_executables.py @@ -0,0 +1,22 @@ +import pytest +import subprocess +import os + +def test_executable(): + subprocess.check_call(["ceci", "tests/test.yml"]) + +def test_dry_run(): + subprocess.check_call(["ceci", "--dry-run", "tests/test.yml",]) + +def test_flow_chart_run(): + subprocess.check_call(["ceci", "--flow-chart", "test-flow.png", "tests/test.yml",]) + assert os.path.exists("test-flow.png") + +def test_profiling_and_memmon_flags(): + cmd = "python3 -m ceci_example PZEstimationPipe --DM=./tests/inputs/dm.txt --fiducial_cosmology=./tests/inputs/fiducial_cosmology.txt --config=./tests/config.yml --photoz_pdfs=./tests/outputs/photoz_pdfs.txt --memmon=1 --cprofile=profile.stats" + subprocess.check_call(cmd.split()) + +def test_misuse_mpi(): + cmd = "python3 -m ceci_example PZEstimationPipe --mpi" + with pytest.raises(subprocess.CalledProcessError): + subprocess.check_call(cmd.split()) \ No newline at end of file