Skip to content

Commit d02a7a1

Browse files
committed
add integration test
1 parent 70aec98 commit d02a7a1

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

tests/test_integration.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def demo_env():
3838
else:
3939
pytest.fail(f"Required source file missing: {source_bz2}")
4040

41-
# Yield paths so the test function knows where things are
4241
yield {'out': out_dir, 'demo': demo_dir}
4342

4443
def test_guacamole_metrics(demo_env):
@@ -49,7 +48,6 @@ def test_guacamole_metrics(demo_env):
4948
demo_dir = demo_env['demo']
5049
output_file_name = "SRR12996245.1pct.guaca"
5150

52-
# Construct command
5351
cmd = [
5452
sys.executable, "-m", "guacamole.guacamole",
5553
"--output", output_file_name,
@@ -64,15 +62,14 @@ def test_guacamole_metrics(demo_env):
6462
"--plot", "False"
6563
]
6664

67-
# Run Guacamole
6865
result = subprocess.run(
6966
cmd, cwd=out_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
7067
)
7168

7269
# Assert successful run
7370
assert result.returncode == 0, f"Command failed with stderr: {result.stderr}"
7471

75-
# 1. Check Efficiencies (50% - 70%)
72+
# Check Efficiencies
7673
eff_path = os.path.join(out_dir, "efficiencies.txt")
7774
assert os.path.exists(eff_path), "efficiencies.txt was not created"
7875

@@ -81,14 +78,13 @@ def test_guacamole_metrics(demo_env):
8178

8279
assert 20 <= max_eff <= 30, f"Max efficiency {max_eff:.2f} is out of range [20, 30]"
8380

84-
# 2. Check Abundances (4% - 12%)
81+
# Check Abundances
8582
guaca_path = os.path.join(out_dir, output_file_name)
8683
assert os.path.exists(guaca_path), f"{output_file_name} was not created"
8784

8885
df = pd.read_csv(guaca_path, sep="\t")
8986
abundances = df['GuaCAMOLE_estimate']
9087

91-
# Vectorized check (faster and cleaner than a loop)
9288
assert (np.sum(abundances) == pytest.approx(1.0, abs=0.01)), f"Sum of abundances is not 1: {np.sum(abundances)}"
9389
assert (abundances >= 0.03).all(), f"Some abundances are < 4%:\n{df[abundances < 0.04]}"
9490
assert (abundances <= 0.12).all(), f"Some abundances are > 12%:\n{df[abundances > 0.12]}"

0 commit comments

Comments
 (0)