Files
bttoxin-pipeline/crispr_cas/tests/test_detect_crispr.py

43 lines
1.2 KiB
Python

import pytest
import json
import shutil
from pathlib import Path
from crispr_cas.scripts.detect_crispr import generate_mock_results
def test_generate_mock_results(tmp_path):
"""Test mock result generation"""
input_file = tmp_path / "test_genome.fna"
input_file.touch()
results = generate_mock_results(input_file)
assert results["strain_id"] == "test_genome"
assert "cas_systems" in results
assert "arrays" in results
assert results["summary"]["has_cas"] is True
assert len(results["arrays"]) > 0
def test_script_execution(tmp_path):
"""Test full script execution via subprocess"""
# Create dummy input
input_file = tmp_path / "genome.fna"
input_file.touch()
output_file = tmp_path / "results.json"
script_path = Path("crispr_cas/scripts/detect_crispr.py").absolute()
import subprocess
cmd = [
"python3", str(script_path),
"--input", str(input_file),
"--output", str(output_file),
"--mock"
]
result = subprocess.run(cmd, capture_output=True, text=True)
assert result.returncode == 0
assert output_file.exists()
with open(output_file) as f:
data = json.load(f)
assert data["strain_id"] == "genome"