Some checks failed
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 20s
Docker Build and Push / build-and-push (push) Failing after 37s
Integration Tests / integration-tests (push) Failing after 32s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 15s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m18s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 22s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 23s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 21s
LabFusion CI/CD Pipeline / frontend (push) Failing after 2m0s
Service Adapters (Python FastAPI) / build (push) Has been skipped
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m53s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
### Summary of Changes - Removed unnecessary blank lines and standardized import statements across test files. - Ensured consistent use of quotes in patch decorators and improved formatting of test data structures. - Enhanced readability and maintainability of test code by applying clean code principles. ### Expected Results - Improved clarity and consistency in test code, facilitating easier understanding and future modifications.
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
"""
|
|
Tests for the main FastAPI application
|
|
"""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
from main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
class TestMainApp:
|
|
"""Test the main FastAPI application"""
|
|
|
|
def test_app_creation(self):
|
|
"""Test that the FastAPI app is created correctly"""
|
|
assert app is not None
|
|
assert app.title == "LabFusion Service Adapters"
|
|
assert app.version == "1.0.0"
|
|
|
|
def test_cors_middleware(self):
|
|
"""Test that CORS middleware is properly configured"""
|
|
# Test a simple request to verify CORS headers
|
|
response = client.get("/")
|
|
assert response.status_code == 200
|
|
# CORS headers should be present
|
|
assert "access-control-allow-origin" in response.headers
|
|
|
|
def test_routers_included(self):
|
|
"""Test that all routers are included"""
|
|
# Check that all expected routes are available
|
|
routes = [route.path for route in app.routes]
|
|
|
|
# General routes
|
|
assert "/" in routes
|
|
assert "/health" in routes
|
|
assert "/services" in routes
|
|
|
|
# Other service routes should be included
|
|
# (exact paths depend on router definitions)
|
|
|
|
def test_openapi_docs(self):
|
|
"""Test that OpenAPI documentation is available"""
|
|
response = client.get("/docs")
|
|
assert response.status_code == 200
|
|
|
|
response = client.get("/openapi.json")
|
|
assert response.status_code == 200
|
|
assert "openapi" in response.json()
|