re-structure
This commit is contained in:
@@ -82,7 +82,7 @@ def mock_inference_service():
|
||||
@pytest.fixture
|
||||
def mock_storage_config(temp_storage_dir):
|
||||
"""Create mock storage configuration."""
|
||||
from inference.web.config import StorageConfig
|
||||
from backend.web.config import StorageConfig
|
||||
|
||||
return StorageConfig(
|
||||
upload_dir=temp_storage_dir["uploads"],
|
||||
@@ -104,13 +104,13 @@ def mock_storage_helper(temp_storage_dir):
|
||||
@pytest.fixture
|
||||
def test_app(mock_inference_service, mock_storage_config, mock_storage_helper):
|
||||
"""Create a test FastAPI application with mocked storage."""
|
||||
from inference.web.api.v1.public.inference import create_inference_router
|
||||
from backend.web.api.v1.public.inference import create_inference_router
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Patch get_storage_helper to return our mock
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
inference_router = create_inference_router(mock_inference_service, mock_storage_config)
|
||||
@@ -123,7 +123,7 @@ def test_app(mock_inference_service, mock_storage_config, mock_storage_helper):
|
||||
def client(test_app, mock_storage_helper):
|
||||
"""Create a test client with storage helper patched."""
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
yield TestClient(test_app)
|
||||
@@ -151,7 +151,7 @@ class TestInferenceEndpoint:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -171,7 +171,7 @@ class TestInferenceEndpoint:
|
||||
png_header = b"\x89PNG\r\n\x1a\n" + b"\x00" * 100
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -186,7 +186,7 @@ class TestInferenceEndpoint:
|
||||
def test_infer_invalid_file_type(self, client, mock_storage_helper):
|
||||
"""Test rejection of invalid file types."""
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -199,7 +199,7 @@ class TestInferenceEndpoint:
|
||||
def test_infer_no_file(self, client, mock_storage_helper):
|
||||
"""Test rejection when no file provided."""
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post("/api/v1/infer")
|
||||
@@ -211,7 +211,7 @@ class TestInferenceEndpoint:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -238,7 +238,7 @@ class TestInferenceResultFormat:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -258,7 +258,7 @@ class TestInferenceResultFormat:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -282,7 +282,7 @@ class TestErrorHandling:
|
||||
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -297,7 +297,7 @@ class TestErrorHandling:
|
||||
"""Test handling of empty files."""
|
||||
# Empty file still has valid content type
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -318,7 +318,7 @@ class TestResponseFormat:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -338,7 +338,7 @@ class TestResponseFormat:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -359,7 +359,7 @@ class TestDocumentIdGeneration:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
@@ -376,7 +376,7 @@ class TestDocumentIdGeneration:
|
||||
pdf_content = b"%PDF-1.4\n%test\n"
|
||||
|
||||
with patch(
|
||||
"inference.web.api.v1.public.inference.get_storage_helper",
|
||||
"backend.web.api.v1.public.inference.get_storage_helper",
|
||||
return_value=mock_storage_helper,
|
||||
):
|
||||
response = client.post(
|
||||
|
||||
@@ -11,7 +11,7 @@ import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from inference.data.admin_models import (
|
||||
from backend.data.admin_models import (
|
||||
AdminAnnotation,
|
||||
AdminDocument,
|
||||
AdminToken,
|
||||
@@ -20,8 +20,8 @@ from inference.data.admin_models import (
|
||||
TrainingDataset,
|
||||
TrainingTask,
|
||||
)
|
||||
from inference.web.api.v1.admin.dashboard import create_dashboard_router
|
||||
from inference.web.core.auth import get_admin_token_dep
|
||||
from backend.web.api.v1.admin.dashboard import create_dashboard_router
|
||||
from backend.web.core.auth import validate_admin_token
|
||||
|
||||
|
||||
def create_test_app(override_token_dep):
|
||||
@@ -31,7 +31,7 @@ def create_test_app(override_token_dep):
|
||||
app.include_router(router)
|
||||
|
||||
# Override auth dependency
|
||||
app.dependency_overrides[get_admin_token_dep] = lambda: override_token_dep
|
||||
app.dependency_overrides[validate_admin_token] = lambda: override_token_dep
|
||||
|
||||
return app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user