add tests for project #1

Merged
gitark merged 8 commits from test into dev1 2025-08-24 09:52:15 +03:00
6 changed files with 20 additions and 2 deletions
Showing only changes of commit 4104dd7e15 - Show all commits

3
pytest.ini Normal file
View File

@@ -0,0 +1,3 @@
[pytest]
pythonpath = . src
asyncio_mode = auto

View File

@@ -34,7 +34,7 @@ class AccessToken(BaseSettings):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
env_file=".env", env_file_encoding="utf-8", env_prefix="ACCESS_TOKEN_" env_file=".env", env_file_encoding="utf-8", env_prefix="ACCESS_TOKEN_"
) )
expire_minutes: int = 15 expire_minutes: int
secret_key: str secret_key: str
algorithm: str = "HS256" algorithm: str = "HS256"
token_type: str = "bearer" # noqa: S105 token_type: str = "bearer" # noqa: S105
@@ -43,7 +43,7 @@ class AccessToken(BaseSettings):
class Settings(BaseSettings): class Settings(BaseSettings):
api: ApiPrefix = ApiPrefix() api: ApiPrefix = ApiPrefix()
db: DbSettings = DbSettings() db: DbSettings = DbSettings()
access_token: AccessToken = AccessToken() access_token: AccessToken = AccessToken() # type: ignore
settings = Settings() settings = Settings()

0
tests/__init__.py Normal file
View File

15
tests/conftest.py Normal file
View File

@@ -0,0 +1,15 @@
import pytest
from sqlalchemy import NullPool
from sqlalchemy.ext.asyncio import create_async_engine
from src.core.database import Base
from src.models import * # noqa: F403
engine_null_pool = create_async_engine('sqlite+aiosqlite:///tests/test_db.db', poolclass=NullPool)
@pytest.fixture(scope="session", autouse=True)
async def setup_database():
async with engine_null_pool.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)

View File

View File