mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
fix lint error
This commit is contained in:
parent
5ede530a4d
commit
b594dee278
@ -1,7 +1,6 @@
|
|||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, Query
|
from fastapi import APIRouter, Depends, Query
|
||||||
from fastapi_cache.decorator import cache
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.database import get_db
|
from app.database import get_db
|
||||||
@ -13,7 +12,6 @@ router = APIRouter(prefix="/v1/shakespeare")
|
|||||||
@router.get(
|
@router.get(
|
||||||
"/",
|
"/",
|
||||||
)
|
)
|
||||||
@cache(namespace="test-2", expire=60)
|
|
||||||
async def find_paragraph(
|
async def find_paragraph(
|
||||||
character: Annotated[str, Query(description="Character name")],
|
character: Annotated[str, Query(description="Character name")],
|
||||||
db_session: AsyncSession = Depends(get_db),
|
db_session: AsyncSession = Depends(get_db),
|
||||||
|
@ -5,8 +5,6 @@ from apscheduler import AsyncScheduler
|
|||||||
from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore
|
from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore
|
||||||
from apscheduler.eventbrokers.redis import RedisEventBroker
|
from apscheduler.eventbrokers.redis import RedisEventBroker
|
||||||
from fastapi import Depends, FastAPI
|
from fastapi import Depends, FastAPI
|
||||||
from fastapi_cache import FastAPICache
|
|
||||||
from fastapi_cache.backends.redis import RedisBackend
|
|
||||||
|
|
||||||
from app.api.health import router as health_router
|
from app.api.health import router as health_router
|
||||||
from app.api.nonsense import router as nonsense_router
|
from app.api.nonsense import router as nonsense_router
|
||||||
@ -15,7 +13,7 @@ from app.api.stuff import router as stuff_router
|
|||||||
from app.api.user import router as user_router
|
from app.api.user import router as user_router
|
||||||
from app.config import settings as global_settings
|
from app.config import settings as global_settings
|
||||||
from app.database import engine
|
from app.database import engine
|
||||||
from app.redis import get_cache, get_redis
|
from app.redis import get_redis
|
||||||
from app.services.auth import AuthBearer
|
from app.services.auth import AuthBearer
|
||||||
from app.services.scheduler import SchedulerMiddleware
|
from app.services.scheduler import SchedulerMiddleware
|
||||||
from app.utils.logging import AppLogger
|
from app.utils.logging import AppLogger
|
||||||
@ -31,10 +29,7 @@ async def lifespan(_app: FastAPI):
|
|||||||
_postgres_dsn = global_settings.postgres_url.unicode_string()
|
_postgres_dsn = global_settings.postgres_url.unicode_string()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Initialize the cache with the redis connection
|
# TODO: cache with the redis connection
|
||||||
redis_cache = await get_cache()
|
|
||||||
FastAPICache.init(RedisBackend(redis_cache), prefix="fastapi-cache")
|
|
||||||
# logger.info(FastAPICache.get_cache_status_header())
|
|
||||||
# Initialize the postgres connection pool
|
# Initialize the postgres connection pool
|
||||||
_app.postgres_pool = await asyncpg.create_pool(
|
_app.postgres_pool = await asyncpg.create_pool(
|
||||||
dsn=_postgres_dsn,
|
dsn=_postgres_dsn,
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from collections.abc import AsyncGenerator
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from httpx import ASGITransport, AsyncClient
|
from httpx import ASGITransport, AsyncClient
|
||||||
|
|
||||||
@ -28,12 +31,11 @@ async def start_db():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
async def client(start_db) -> AsyncClient:
|
async def client(start_db) -> AsyncGenerator[AsyncClient, Any]: # noqa: ARG001
|
||||||
transport = ASGITransport(
|
transport = ASGITransport(
|
||||||
app=app,
|
app=app,
|
||||||
)
|
)
|
||||||
async with AsyncClient(
|
async with AsyncClient(
|
||||||
# app=app,
|
|
||||||
base_url="http://testserver/v1",
|
base_url="http://testserver/v1",
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
transport=transport,
|
transport=transport,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user