style: fix formatting and linting issues in conftest.py

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-09 15:38:31 +00:00
parent 98cf9e0e0b
commit a63983a26c
+21 -35
View File
@@ -1,10 +1,12 @@
"""
Pytest configuration and shared fixtures for DocuElevate tests.
"""
import os
import tempfile
import pytest
from typing import Generator
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
@@ -22,10 +24,11 @@ os.environ["WORKDIR"] = "/tmp"
os.environ["AUTH_ENABLED"] = "False"
os.environ["SESSION_SECRET"] = "test_secret_key_for_testing_must_be_at_least_32_characters_long"
from app.database import Base, get_db
from app.main import app as fastapi_app
from app.database import Base # noqa: E402
from app.main import app as fastapi_app # noqa: E402
# Import models to register them with SQLAlchemy Base
from app.models import DocumentMetadata, FileRecord, ProcessingLog
from app.models import DocumentMetadata, FileRecord, ProcessingLog # noqa: F401, E402
@pytest.fixture(scope="session")
@@ -127,7 +130,7 @@ startxref
%%EOF
"""
with open(pdf_path, 'wb') as f:
with open(pdf_path, "wb") as f:
f.write(pdf_content)
return pdf_path
@@ -138,7 +141,7 @@ def sample_text_file(test_workdir) -> str:
"""Create a sample text file for testing."""
text_path = os.path.join(test_workdir, "test.txt")
with open(text_path, 'w') as f:
with open(text_path, "w") as f:
f.write("This is a test document.\nWith multiple lines.\n")
return text_path
@@ -148,46 +151,29 @@ def sample_text_file(test_workdir) -> str:
def mock_openai_response():
"""Mock OpenAI API response for testing."""
return {
"choices": [{
"choices": [
{
"message": {
"content": '{"document_type": "invoice", "summary": "Test invoice", "tags": ["test", "invoice"]}'
}
}]
}
]
}
@pytest.fixture
def mock_azure_response():
"""Mock Azure Document Intelligence API response for testing."""
return {
"analyzeResult": {
"content": "Test document content extracted by OCR",
"pages": [{"pageNumber": 1}]
}
}
return {"analyzeResult": {"content": "Test document content extracted by OCR", "pages": [{"pageNumber": 1}]}}
# Markers for categorizing tests
def pytest_configure(config):
"""Configure custom pytest markers."""
config.addinivalue_line(
"markers", "unit: Unit tests for individual functions/methods"
)
config.addinivalue_line(
"markers", "integration: Integration tests for API endpoints and workflows"
)
config.addinivalue_line(
"markers", "slow: Tests that take significant time to run"
)
config.addinivalue_line(
"markers", "security: Security-related tests"
)
config.addinivalue_line(
"markers", "requires_external: Tests requiring external services"
)
config.addinivalue_line(
"markers", "requires_db: Tests requiring database"
)
config.addinivalue_line(
"markers", "requires_redis: Tests requiring Redis"
)
config.addinivalue_line("markers", "unit: Unit tests for individual functions/methods")
config.addinivalue_line("markers", "integration: Integration tests for API endpoints and workflows")
config.addinivalue_line("markers", "slow: Tests that take significant time to run")
config.addinivalue_line("markers", "security: Security-related tests")
config.addinivalue_line("markers", "requires_external: Tests requiring external services")
config.addinivalue_line("markers", "requires_db: Tests requiring database")
config.addinivalue_line("markers", "requires_redis: Tests requiring Redis")