Files
bttoxin-pipeline/tools/crispr_cas_analysis/tests/test_detect_crispr.py
zly c75c85c53b Refactor: Unified pipeline execution, simplified UI, and fixed Docker config
- Backend: Refactored tasks.py to directly invoke run_single_fna_pipeline.py for consistency.
- Backend: Changed output format to ZIP and added auto-cleanup of intermediate files.
- Backend: Fixed language parameter passing in API and tasks.
- Frontend: Removed CRISPR Fusion UI elements from Submit and Monitor views.
- Frontend: Implemented simulated progress bar for better UX.
- Frontend: Restored One-click load button and added result file structure documentation.
- Docker: Fixed critical Restarting loop by removing incorrect image directive in docker-compose.yml.
- Docker: Optimized Dockerfile to correct .pixi environment path issues and prevent accidental deletion of frontend assets.
2026-01-20 20:25:25 +08:00

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"