From 32af63d62b503076ae6c50520728b63c3852346f Mon Sep 17 00:00:00 2001 From: Fast Code Date: Sat, 10 Aug 2024 11:50:08 +0300 Subject: [PATCH] update makefile --- Makefile | 7 ++++++- app/core/settings.py | 20 ++++++++++---------- app/logic/logic.py | 2 +- app/logic/users.py | 8 ++++++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index d1ff4cb..b91abef 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,9 @@ help: @echo " dev Start the app" @echo " ref Reformat code" @echo " req pyproject.toml >> requirements.txt" + @echo " test Start the pytest" @echo " migrate Alembic migrate database" - @echo " generate Alembic generate database" + @echo " generate Alembic generate database" .PHONY: blue @@ -30,6 +31,10 @@ dev: req: poetry export --without-hashes --without-urls | awk '{ print $1 }' FS=';' > requirements.txt +.PHONY: test +test: + poetry run pytest tests + .PHONY: migrate migrate: poetry run alembic upgrade head diff --git a/app/core/settings.py b/app/core/settings.py index b5ee50a..cd97f04 100644 --- a/app/core/settings.py +++ b/app/core/settings.py @@ -8,22 +8,22 @@ class Settings(BaseSettings): model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", case_sensitive=True + env_file='.env', env_file_encoding='utf-8', case_sensitive=True ) # APP - APP_PATH: str = "/api" - APP_TITLE: str = "FastAPI Template" - APP_VERSION: str = "beta" - APP_SECRET_KEY: str = "abc" + APP_PATH: str = '/api' + APP_TITLE: str = 'FastAPI Template' + APP_VERSION: str = 'beta' + APP_SECRET_KEY: str = 'abc' # DATABASE - DB: str = "postgres" - DB_HOST: str = "localhost" + DB: str = 'postgres' + DB_HOST: str = 'localhost' DB_PORT: int = 5432 - DB_USER: str = "" - DB_PASSWORD: str = "" - DB_DRIVERNAME: str = "postgresql+asyncpg" + DB_USER: str = '' + DB_PASSWORD: str = '' + DB_DRIVERNAME: str = 'postgresql+asyncpg' @property def db_dsn(self) -> str: diff --git a/app/logic/logic.py b/app/logic/logic.py index 29c3eab..4083787 100644 --- a/app/logic/logic.py +++ b/app/logic/logic.py @@ -17,6 +17,6 @@ def __init__(self, db: Database): @classmethod @asynccontextmanager - async def create(cls) -> AsyncGenerator["Logic", None]: + async def create(cls) -> AsyncGenerator['Logic', None]: async with Database() as db: yield cls(db) diff --git a/app/logic/users.py b/app/logic/users.py index 6899792..f1ab280 100644 --- a/app/logic/users.py +++ b/app/logic/users.py @@ -8,7 +8,7 @@ class Users: - def __init__(self, logic: "Logic"): + def __init__(self, logic: 'Logic'): self.logic = logic async def create(self, data: UserCreate) -> User | None: @@ -21,7 +21,11 @@ async def create(self, data: UserCreate) -> User | None: async def retrieve_by_token(self, token: str) -> User | None: payload = self.logic.security.jwt.decode_token(token) - if not (user := await self.logic.db.user.retrieve_one(ident=payload.get("id"))): + if not ( + user := await self.logic.db.user.retrieve_one( + ident=payload.get('id') + ) + ): raise exps.UserNotFoundException() return user