69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
"""
|
|
Pytest configuration and fixtures for PDF Accessibility Checker tests
|
|
"""
|
|
|
|
import pytest
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock
|
|
|
|
# Add parent directory to path for imports
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
# ── Mock unavailable Docker-only dependencies before any test imports ──
|
|
# redis and psycopg2 are only available inside Docker containers.
|
|
# We mock them at sys.modules level so imports succeed during test collection.
|
|
for _mod in ("redis", "psycopg2", "psycopg2.extras"):
|
|
if _mod not in sys.modules:
|
|
sys.modules[_mod] = MagicMock()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_good_pdf():
|
|
"""Path to sample good PDF file"""
|
|
return Path("Test_files/sample_good.pdf")
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_poor_pdf():
|
|
"""Path to sample poor PDF file"""
|
|
return Path("Test_files/sample_poor.pdf")
|
|
|
|
|
|
@pytest.fixture
|
|
def temp_output_dir(tmp_path):
|
|
"""Temporary directory for test outputs"""
|
|
output_dir = tmp_path / "output"
|
|
output_dir.mkdir()
|
|
return output_dir
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_api_responses():
|
|
"""Mock API responses for testing without actual API calls"""
|
|
return {
|
|
'claude': {
|
|
'type': 'informational',
|
|
'alt_text': 'A test image showing sample content',
|
|
'has_text': False,
|
|
'decorative': False
|
|
},
|
|
'google_vision': {
|
|
'has_text': False,
|
|
'text_content': None,
|
|
'labels': ['Document', 'Text', 'Paper'],
|
|
'objects': []
|
|
}
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_pdf_metadata():
|
|
"""Sample PDF metadata for testing"""
|
|
return {
|
|
'title': 'Test Document',
|
|
'author': 'Test Author',
|
|
'subject': 'Test Subject',
|
|
'language': 'en-US'
|
|
}
|