""" conftest.py Pytest configuration and fixtures for chat automation and accuracy testing. """ import pytest import json import sys from pathlib import Path from dotenv import load_dotenv # Load environment variables load_dotenv() # Add parent directories to path test_dir = Path(__file__).parent project_dir = test_dir.parent src_dir = project_dir / "src" if str(src_dir) not in sys.path: sys.path.insert(0, str(src_dir)) if str(project_dir) not in sys.path: sys.path.insert(0, str(project_dir)) if str(test_dir) not in sys.path: sys.path.insert(0, str(test_dir)) @pytest.fixture def test_cases(): """Load test cases from test_cases.json.""" test_file = Path(__file__).parent / "test_cases.json" with open(test_file, 'r') as f: data = json.load(f) return data @pytest.fixture def chat_interface_tests(test_cases): """Get chat interface test cases.""" return test_cases.get("chat_interface_tests", []) @pytest.fixture def area_insights_tests(test_cases): """Get area insights test cases.""" return test_cases.get("area_insights_tests", []) @pytest.fixture def validation_rules(test_cases): """Get validation rules.""" return test_cases.get("validation_rules", {}) @pytest.fixture def data_dictionary_service(): """Initialize DataDictionaryService for testing.""" try: from services.data_dictionary_service import DataDictionaryService return DataDictionaryService() except Exception as e: pytest.skip(f"Could not initialize DataDictionaryService: {e}") @pytest.fixture def retrieval_service(data_dictionary_service): """Initialize RetrievalService for testing.""" try: from services.retrieval_service import RetrievalService return RetrievalService(data_dictionary_service) except Exception as e: pytest.skip(f"Could not initialize RetrievalService: {e}") @pytest.fixture def chat_automation_mock(): """Initialize ChatAutomation with mock service.""" try: sys.path.insert(0, str(Path(__file__).parent)) from chat_automation import ChatAutomation return ChatAutomation(use_mock=True) except Exception as e: pytest.skip(f"Could not initialize ChatAutomation: {e}") @pytest.fixture def accuracy_analyzer(data_dictionary_service): """Initialize AccuracyAnalyzer for testing.""" try: from accuracy_validators import AccuracyAnalyzer return AccuracyAnalyzer(data_dictionary_service) except Exception as e: pytest.skip(f"Could not initialize AccuracyAnalyzer: {e}")