"""Tests for agent analysis and report generation primitives.""" import pytest import os pytest.importorskip("duckdb") class TestAnalyzePartyShift: def test_returns_shift_data(self, tmp_duckdb_path): from agent_tools.analysis import analyze_party_shift result = analyze_party_shift( tmp_duckdb_path, party="VVD", window_start="2020", window_end="2024" ) assert isinstance(result, dict) assert "party" in result assert "shift" in result or "error" in result def test_nonexistent_party_returns_error(self, tmp_duckdb_path): from agent_tools.analysis import analyze_party_shift result = analyze_party_shift( tmp_duckdb_path, party="FAKE", window_start="2020", window_end="2024" ) assert isinstance(result, dict) class TestAnalyzeAxisStability: def test_returns_stability_scores(self, tmp_duckdb_path): from agent_tools.analysis import analyze_axis_stability result = analyze_axis_stability(tmp_duckdb_path, component=1, windows=["2020", "2024"]) assert isinstance(result, dict) assert "component" in result assert "stability" in result or "error" in result class TestGenerateReport: def test_writes_markdown_file(self, tmp_duckdb_path, tmp_path): from agent_tools.reports import generate_report output_path = str(tmp_path / "report.md") result = generate_report( tmp_duckdb_path, report_type="summary", parameters={}, output_path=output_path, ) assert isinstance(result, dict) assert os.path.exists(output_path) def test_returns_error_for_unknown_type(self, tmp_duckdb_path, tmp_path): from agent_tools.reports import generate_report output_path = str(tmp_path / "report.md") result = generate_report( tmp_duckdb_path, report_type="unknown", parameters={}, output_path=output_path, ) assert isinstance(result, dict) assert "error" in result class TestValidateSvdLabels: def test_returns_validation_result(self, tmp_duckdb_path): from agent_tools.analysis import validate_svd_labels result = validate_svd_labels(tmp_duckdb_path, component=1) assert isinstance(result, dict) assert "component" in result assert "valid" in result or "error" in result