Initial commit of document-service
This commit is contained in:
68
tests/conftest.py
Normal file
68
tests/conftest.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Test configuration and fixtures for document-service tests.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import os
|
||||
from fastapi.testclient import TestClient
|
||||
from unittest.mock import Mock, patch
|
||||
from moto import mock_aws
|
||||
import boto3
|
||||
|
||||
from app.main import app
|
||||
|
||||
# Test data paths
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures")
|
||||
|
||||
@pytest.fixture
|
||||
def test_client():
|
||||
"""Create a test client with auth bypass."""
|
||||
return TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def sample_org_id():
|
||||
"""Sample organization ID for testing."""
|
||||
return "test-org-123"
|
||||
|
||||
@pytest.fixture
|
||||
def sample_document_id():
|
||||
"""Sample document ID for testing."""
|
||||
return "test-doc-456"
|
||||
|
||||
@pytest.fixture
|
||||
def test_pdf_files():
|
||||
"""Paths to test PDF files."""
|
||||
return {
|
||||
"simple_form": os.path.join(FIXTURES_DIR, "simple_form.pdf"),
|
||||
"complex_form": os.path.join(FIXTURES_DIR, "complex_form.pdf"),
|
||||
"no_form": os.path.join(FIXTURES_DIR, "no_form.pdf"),
|
||||
"large_form": os.path.join(FIXTURES_DIR, "large_form.pdf"),
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def mock_s3_client():
|
||||
"""Create a mock S3 client for testing."""
|
||||
with mock_aws():
|
||||
client = boto3.client(
|
||||
"s3",
|
||||
region_name="us-east-1",
|
||||
aws_access_key_id="minioadmin",
|
||||
aws_secret_access_key="minioadmin",
|
||||
)
|
||||
# Create test bucket
|
||||
client.create_bucket(Bucket="document-bucket")
|
||||
yield client
|
||||
|
||||
@pytest.fixture
|
||||
def auth_bypass_middleware():
|
||||
"""Fixture to bypass auth middleware in tests."""
|
||||
def bypass_auth(request):
|
||||
request.state.org_id = "test-org-123"
|
||||
return request
|
||||
|
||||
return bypass_auth
|
||||
|
||||
@pytest.fixture
|
||||
def sample_auth_token():
|
||||
"""Sample auth token for testing."""
|
||||
return "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmdfaWQiOiJ0ZXN0LW9yZy0xMjMifQ.test"
|
||||
Reference in New Issue
Block a user