Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /descoped_authly /tests /infrastructure /test_api.py
| import asyncio | |
| import logging | |
| import pytest | |
| from fastapi import APIRouter | |
| from fastapi_testing import AsyncTestServer | |
| from psycopg import AsyncTransaction | |
| from authly.api import health_router | |
| from authly.config.config import AuthlyConfig | |
| logger = logging.getLogger(__name__) | |
| class PingRouter: | |
| router = APIRouter() | |
| async def read_root(): | |
| return {"status": "ok"} | |
| async def test_authly_initialization(initialize_authly): | |
| # Use initialize_authly directly since it's now the Authly instance | |
| assert initialize_authly.get_config() is not None | |
| async def test_ping(test_server: AsyncTestServer, transaction: AsyncTransaction): | |
| # Register routes | |
| test_server.app.include_router(PingRouter().router) | |
| # Make your request | |
| response = await test_server.client.get("/ping") | |
| _, response_json = await asyncio.gather(response.expect_status(200), response.json()) | |
| logger.info(f"Ping response: {response_json}") | |
| assert response_json == {"status": "ok"} | |
| async def test_health(test_config: AuthlyConfig, test_server: AsyncTestServer): | |
| # Register routes | |
| test_server.app.include_router(health_router) | |
| # Make your request | |
| response = await test_server.client.get("/health") | |
| _, health_response = await asyncio.gather(response.expect_status(200), response.json()) | |
| # Check core health fields | |
| assert health_response["status"] == "healthy" | |
| assert health_response["database"] == "connected" | |
| # Check version is present | |
| assert "version" in health_response | |
| assert health_response["version"] # Should not be empty | |
| # Check psycopg driver information is present | |
| assert "psycopg_driver" in health_response | |
| assert "psycopg_version" in health_response | |
| # Log driver information | |
| logger.info(f"Health check - psycopg driver: {health_response.get('psycopg_driver')}") | |
| logger.info(f"Health check - psycopg version: {health_response.get('psycopg_version')}") | |
Xet Storage Details
- Size:
- 2.07 kB
- Xet hash:
- 156f2b0b28ae4ce8bfc4fa06eb92fcf4eeac6afac4ed7323c5fe0db39b6a8ffb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.