diff options
author | Arun Isaac | 2025-08-04 12:34:06 +0100 |
---|---|---|
committer | Arun Isaac | 2025-08-06 22:40:41 +0100 |
commit | 9e2fbdb8141549cbaf4688e52f62fec0b720d8b8 (patch) | |
tree | e744d87290010431dad554fceb2685e97ebee335 /tests/test_pyhegp.py | |
parent | bcdb235949c06db07172b0c6355a0059436b86fb (diff) | |
download | pyhegp-9e2fbdb8141549cbaf4688e52f62fec0b720d8b8.tar.gz pyhegp-9e2fbdb8141549cbaf4688e52f62fec0b720d8b8.tar.lz pyhegp-9e2fbdb8141549cbaf4688e52f62fec0b720d8b8.zip |
Test joint workflow CLI.
* tests/test_pyhegp.py: Import CliRunner from click.testing, and main from pyhegp.pyhegp. (test_joint_workflow): New test. * test-data/genotype0.tsv, test-data/genotype1.tsv, test-data/genotype2.tsv, test-data/genotype3.tsv: New files.
Diffstat (limited to 'tests/test_pyhegp.py')
-rw-r--r-- | tests/test_pyhegp.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_pyhegp.py b/tests/test_pyhegp.py index 1fceb99..0ddba99 100644 --- a/tests/test_pyhegp.py +++ b/tests/test_pyhegp.py @@ -18,12 +18,13 @@ import math +from click.testing import CliRunner from hypothesis import given, settings, strategies as st from hypothesis.extra.numpy import arrays, array_shapes import numpy as np from pytest import approx -from pyhegp.pyhegp import Stats, hegp_encrypt, hegp_decrypt, random_key, pool_stats, standardize, unstandardize +from pyhegp.pyhegp import Stats, main, hegp_encrypt, hegp_decrypt, random_key, pool_stats, standardize, unstandardize from pyhegp.utils import negate @given(st.lists(st.lists(arrays("float64", @@ -102,3 +103,28 @@ def test_conservation_of_solutions(genotype, phenotype): abs=1e-6, rel=1e-6) == np.linalg.solve(hegp_encrypt(genotype, key), hegp_encrypt(phenotype, key))) + +def test_joint_workflow(tmp_path): + runner = CliRunner() + for i in range(4): + result = runner.invoke( + main, ["summary", f"test-data/genotype{i}.tsv", + "-o", tmp_path / f"summary{i}"]) + assert result.exit_code == 0 + result = runner.invoke( + main, ["pool", + "-o", tmp_path / "complete-summary", + *(str(tmp_path / f"summary{i}") for i in range(4))]) + assert result.exit_code == 0 + for i in range(4): + result = runner.invoke( + main, ["encrypt", + "-s", tmp_path / "complete-summary", + "-o", tmp_path / f"encrypted-genotype{i}.tsv", + f"test-data/genotype{i}.tsv"]) + assert result.exit_code == 0 + result = runner.invoke( + main, ["cat", + "-o", tmp_path / "complete-encrypted-genotype.tsv", + *(str(tmp_path / f"encrypted-genotype{i}.tsv") for i in range(4))]) + assert result.exit_code == 0 |