File size: 5,091 Bytes
7a92197 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | """
Test Suite for Cancer@Home v2
Run with: pytest test_cancer_at_home.py
"""
import pytest
from pathlib import Path
class TestConfiguration:
"""Test configuration file"""
def test_config_exists(self):
"""Check if config file exists"""
assert Path("config.yml").exists()
def test_requirements_exists(self):
"""Check if requirements file exists"""
assert Path("requirements.txt").exists()
class TestBOINC:
"""Test BOINC integration"""
def test_boinc_client_import(self):
"""Test BOINC client can be imported"""
from backend.boinc import BOINCClient
assert BOINCClient is not None
def test_boinc_task_submission(self):
"""Test task submission"""
from backend.boinc import BOINCClient
client = BOINCClient()
task_id = client.submit_task("test_task", "test_input.txt")
assert task_id is not None
assert task_id.startswith("wu_")
# Check task exists
task = client.get_task_status(task_id)
assert task is not None
assert task.status == "pending"
class TestGDC:
"""Test GDC integration"""
def test_gdc_client_import(self):
"""Test GDC client can be imported"""
from backend.gdc import GDCClient
assert GDCClient is not None
def test_gdc_client_initialization(self):
"""Test GDC client initialization"""
from backend.gdc import GDCClient
client = GDCClient()
assert client.api_url == "https://api.gdc.cancer.gov"
class TestPipeline:
"""Test bioinformatics pipeline"""
def test_fastq_processor_import(self):
"""Test FASTQ processor import"""
from backend.pipeline import FASTQProcessor
assert FASTQProcessor is not None
def test_blast_runner_import(self):
"""Test BLAST runner import"""
from backend.pipeline import BLASTRunner
assert BLASTRunner is not None
def test_variant_caller_import(self):
"""Test variant caller import"""
from backend.pipeline import VariantCaller
assert VariantCaller is not None
class TestNeo4j:
"""Test Neo4j integration"""
def test_db_manager_import(self):
"""Test database manager import"""
from backend.neo4j import DatabaseManager
assert DatabaseManager is not None
def test_repositories_import(self):
"""Test repository imports"""
from backend.neo4j import (
GeneRepository,
MutationRepository,
PatientRepository,
CancerTypeRepository
)
assert GeneRepository is not None
assert MutationRepository is not None
assert PatientRepository is not None
assert CancerTypeRepository is not None
class TestAPI:
"""Test API endpoints"""
def test_api_import(self):
"""Test API can be imported"""
from backend.api import app
assert app is not None
def test_api_title(self):
"""Test API metadata"""
from backend.api import app
assert app.title == "Cancer@Home v2"
assert app.version == "2.0.0"
class TestDirectoryStructure:
"""Test directory structure"""
def test_backend_exists(self):
"""Check backend directory"""
assert Path("backend").exists()
assert Path("backend/__init__.py").exists()
def test_modules_exist(self):
"""Check all modules exist"""
modules = [
"backend/api",
"backend/boinc",
"backend/gdc",
"backend/neo4j",
"backend/pipeline"
]
for module in modules:
assert Path(module).exists()
assert Path(f"{module}/__init__.py").exists()
def test_frontend_exists(self):
"""Check frontend files"""
assert Path("frontend").exists()
assert Path("frontend/index.html").exists()
def test_documentation_exists(self):
"""Check documentation files"""
docs = [
"README.md",
"QUICKSTART.md",
"USER_GUIDE.md",
"GRAPHQL_EXAMPLES.md",
"PROJECT_SUMMARY.md"
]
for doc in docs:
assert Path(doc).exists()
class TestSetupScripts:
"""Test setup scripts"""
def test_setup_scripts_exist(self):
"""Check setup scripts"""
assert Path("setup.ps1").exists()
assert Path("setup.sh").exists()
def test_run_script_exists(self):
"""Check run script"""
assert Path("run.py").exists()
def test_docker_compose_exists(self):
"""Check Docker compose file"""
assert Path("docker-compose.yml").exists()
if __name__ == "__main__":
pytest.main([__file__, "-v"])
|