From b300727c1881a591a24f39a3730810f93bd43245 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 1 Sep 2025 17:03:22 +0100 Subject: Do not require output ciphertext file path. Make output ciphertext file path implicit; infer it by appending ".hegp" to the plaintext file. We take inspiration from GnuPG. --- tests/test_pyhegp.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/test_pyhegp.py') diff --git a/tests/test_pyhegp.py b/tests/test_pyhegp.py index 61f65cd..0a62ad1 100644 --- a/tests/test_pyhegp.py +++ b/tests/test_pyhegp.py @@ -18,6 +18,7 @@ import math from pathlib import Path +import shutil from click.testing import CliRunner from hypothesis import given, settings, strategies as st @@ -50,11 +51,11 @@ def test_pool_stats(pools): rel=1e-6)) def test_encrypt(tmp_path): - ciphertext = tmp_path / "encrypted-genotype.tsv" + shutil.copy("test-data/encrypt-test-genotype.tsv", tmp_path) + ciphertext = tmp_path / "encrypt-test-genotype.tsv.hegp" result = CliRunner().invoke(main, ["encrypt", "-s", "test-data/encrypt-test-summary", - "-o", ciphertext, - "test-data/encrypt-test-genotype.tsv"]) + str(tmp_path / "encrypt-test-genotype.tsv")]) assert result.exit_code == 0 assert ciphertext.exists() assert "Dropped 1 SNP(s)" in result.output @@ -143,20 +144,20 @@ def test_pool(tmp_path): assert pooled_summary.n == expected_pooled_summary.n def test_simple_workflow(tmp_path): - ciphertext = tmp_path / "encrypted_genotype.tsv" + shutil.copy(f"test-data/genotype.tsv", tmp_path) + ciphertext = tmp_path / "genotype.tsv.hegp" result = CliRunner().invoke(main, - ["encrypt", - "-o", ciphertext, - "test-data/genotype.tsv"]) + ["encrypt", str(tmp_path / "genotype.tsv")]) assert result.exit_code == 0 assert ciphertext.exists() def test_joint_workflow(tmp_path): runner = CliRunner() for i in range(4): + shutil.copy(f"test-data/genotype{i}.tsv", tmp_path) summary = tmp_path / f"summary{i}" result = runner.invoke( - main, ["summary", f"test-data/genotype{i}.tsv", + main, ["summary", str(tmp_path / f"genotype{i}.tsv"), "-o", summary]) assert result.exit_code == 0 assert summary.exists() @@ -168,18 +169,17 @@ def test_joint_workflow(tmp_path): assert result.exit_code == 0 assert complete_summary.exists() for i in range(4): - ciphertext = tmp_path / f"encrypted-genotype{i}.tsv" + ciphertext = tmp_path / f"genotype{i}.tsv.hegp" result = runner.invoke( main, ["encrypt", "-s", complete_summary, - "-o", ciphertext, - f"test-data/genotype{i}.tsv"]) + str(tmp_path / f"genotype{i}.tsv")]) assert result.exit_code == 0 assert ciphertext.exists() - complete_ciphertext = tmp_path / "complete-encrypted-genotype.tsv" + complete_ciphertext = tmp_path / "complete-genotype.tsv.hegp" result = runner.invoke( main, ["cat", "-o", complete_ciphertext, - *(str(tmp_path / f"encrypted-genotype{i}.tsv") for i in range(4))]) + *(str(tmp_path / f"genotype{i}.tsv.hegp") for i in range(4))]) assert result.exit_code == 0 assert complete_ciphertext.exists() -- cgit 1.4.1