Spaces:
Sleeping
Sleeping
Download tests/conftest.py from faseehsandhu/Digitalytics: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/spaces/faseehsandhu/Digitalytics/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/faseehsandhu/Digitalytics/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/faseehsandhu/Digitalytics/resolve/main/tests/conftest.py
2.59 kB
| """ | |
| 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)) | |
| 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 | |
| def chat_interface_tests(test_cases): | |
| """Get chat interface test cases.""" | |
| return test_cases.get("chat_interface_tests", []) | |
| def area_insights_tests(test_cases): | |
| """Get area insights test cases.""" | |
| return test_cases.get("area_insights_tests", []) | |
| def validation_rules(test_cases): | |
| """Get validation rules.""" | |
| return test_cases.get("validation_rules", {}) | |
| 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}") | |
| 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}") | |
| 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}") | |
| 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}") | |