/
nevers
/
hackINTERPOL
Обзор
Документация
Войти
/
nevers
/
hackINTERPOL
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/test_cli_smoke.py
88 строк
3 KB
nevers
upload files
13 янв 2026, 17:20
13 янв 2026, 17:20
ddbbb62
Код
Авторство
О чём код?
"""Smoke tests for CLI commands.""" import json from pathlib import Path import subprocess import tempfile def test_cli_validate_command() -> None: """Test validate command works on sample CSV.""" sample_csv = Path(__file__).parent.parent / "data" / "sample_students.csv" result = subprocess.run( ["studypulse", "validate", "--input", str(sample_csv)], capture_output=True, text=True, ) assert result.returncode == 0 assert "Validation passed" in result.stdout def test_cli_validate_invalid_file() -> None: """Test validate command fails on invalid file.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".csv", delete=False) as f: f.write("invalid,columns\n") invalid_csv = Path(f.name) try: result = subprocess.run( ["studypulse", "validate", "--input", str(invalid_csv)], capture_output=True, text=True, ) assert result.returncode != 0 finally: invalid_csv.unlink() def test_cli_analyze_command() -> None: """Test analyze command generates JSON summary.""" sample_csv = Path(__file__).parent.parent / "data" / "sample_students.csv" with tempfile.TemporaryDirectory() as tmpdir: output_json = Path(tmpdir) / "summary.json" result = subprocess.run( [ "studypulse", "analyze", "--input", str(sample_csv), "--out", str(output_json), ], capture_output=True, text=True, ) assert result.returncode == 0 assert output_json.exists() # Verify JSON is valid with open(output_json) as f: data = json.load(f) assert "summary_stats" in data assert "top_risks" in data assert "total_records" in data def test_cli_report_command() -> None: """Test report command generates HTML report.""" sample_csv = Path(__file__).parent.parent / "data" / "sample_students.csv" with tempfile.TemporaryDirectory() as tmpdir: output_html = Path(tmpdir) / "report.html" result = subprocess.run( [ "studypulse", "report", "--input", str(sample_csv), "--out", str(output_html), ], capture_output=True, text=True, ) assert result.returncode == 0 assert output_html.exists() # Verify HTML content html_content = output_html.read_text() assert "<html" in html_content.lower() assert "StudyPulse" in html_content assert "data:image/png;base64" in html_content # Embedded plots