Files
baby-monitor/tests/integration/test_main.py
T
Brian Bjarke Jensen 298fb192de
Python Code Quality / python-code-quality (push) Successful in 9s
Python Test / python-test (push) Successful in 12s
fixed tests
2025-11-04 21:50:58 +01:00

73 lines
2.5 KiB
Python

"""Integration tests for FastAPI application."""
import pytest
from fastapi.testclient import TestClient
@pytest.mark.integration
def test_read_root(app_test_client: TestClient) -> None:
"""Test root endpoint returns expected message."""
response = app_test_client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello World"}
@pytest.mark.integration
def test_health_check(app_test_client: TestClient) -> None:
"""Test health check endpoint returns healthy status."""
response = app_test_client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "healthy"}
@pytest.mark.integration
def test_readiness_check(app_test_client: TestClient) -> None:
"""Test readiness check endpoint returns ready status."""
response = app_test_client.get("/ready")
assert response.status_code == 200
assert response.json() == {"status": "ready"}
@pytest.mark.integration
def test_openapi_docs_accessible(app_test_client: TestClient) -> None:
"""Test OpenAPI documentation is accessible."""
response = app_test_client.get("/docs")
assert response.status_code == 200
@pytest.mark.integration
def test_openapi_json_accessible(app_test_client: TestClient) -> None:
"""Test OpenAPI JSON schema is accessible."""
response = app_test_client.get("/openapi.json")
assert response.status_code == 200
assert "openapi" in response.json()
assert "info" in response.json()
@pytest.mark.integration
def test_nonexistent_endpoint_returns_404(app_test_client: TestClient) -> None:
"""Test requesting a non-existent endpoint returns 404."""
response = app_test_client.get("/nonexistent")
assert response.status_code == 404
@pytest.mark.integration
def test_root_endpoint_content_type(app_test_client: TestClient) -> None:
"""Test root endpoint returns JSON content type."""
response = app_test_client.get("/")
assert response.headers["content-type"] == "application/json"
@pytest.mark.integration
def test_health_endpoint_content_type(app_test_client: TestClient) -> None:
"""Test health endpoint returns JSON content type."""
response = app_test_client.get("/health")
assert response.headers["content-type"] == "application/json"
@pytest.mark.integration
def test_ready_endpoint_content_type(app_test_client: TestClient) -> None:
"""Test readiness endpoint returns JSON content type."""
response = app_test_client.get("/ready")
assert response.headers["content-type"] == "application/json"