[TC-642] modify template (#3)

https://eva.avroid.tech/desk/Task/TC-642#be-dorabotat-shablon-servisov-backend

Дорабатываем шаблон сервисов по требованиям: https://eva.avroid.tech/project/Document/DOC-002710#trebovanija-k-versijam

Reviewed-on: https://git.avroid.tech/Templates/template-backend-service/pulls/3
Reviewed-by: Victor Stratov <victor.stratov@avroid.team>
Reviewed-by: Petr Brovchenko <petr.brovchenko@avroid.team>
Co-authored-by: Nadezhda <nadezhda.lavrentieva@avroid.team>
Co-committed-by: Nadezhda <nadezhda.lavrentieva@avroid.team>
This commit is contained in:
Nadezhda
2024-12-16 10:26:11 +03:00
committed by Nadezhda Lavrentieva
parent a4b2c99c25
commit ac441a108b
33 changed files with 782 additions and 862 deletions

View File

@@ -16,17 +16,8 @@ from src.settings import WebAppSettings
@pytest.fixture
def test_settings() -> WebAppSettings:
return WebAppSettings(
postgres_user="postgres",
postgres_password="postgres",
postgres_host="localhost",
postgres_db="postgres",
postgres_port=5432,
postgres_dsn="postgresql://messenger:messenger@localhost:5432/messenger_test",
port=8000,
scylladb_host="localhost",
scylladb_port="9042",
scylladb_user="test",
scylladb_password="test",
scylladb_keyspace="test",
)
@@ -65,8 +56,7 @@ def sa_enums():
@pytest.fixture(autouse=True)
async def db_engine(test_settings: WebAppSettings, sa_tables, sa_enums) -> AsyncGenerator[Engine, None]:
postgres_dsn = f"postgresql://{test_settings.postgres_user}:{test_settings.postgres_password}@{test_settings.postgres_host}:5432/{test_settings.postgres_db}"
async with create_engine(postgres_dsn) as engine:
async with create_engine(test_settings.postgres_dsn) as engine:
async with engine.acquire() as connection:
await drop_tables(connection)
await create_enums(connection, sa_enums)

0
tests/routes/__init__.py Normal file
View File

View File

View File

@@ -2,18 +2,18 @@ import pytest
from aiopg.sa import SAConnection
from httpx import AsyncClient
from src.repositories.tables import messenger_handbook_country_table
from src.repositories.tables.tables import todo_table
from tests.samples import ACCOUNT_1, ACCOUNT_2
@pytest.fixture
def sa_tables():
return [messenger_handbook_country_table]
return [todo_table]
@pytest.fixture(autouse=True)
async def _enter_data(connection: SAConnection):
await connection.execute(messenger_handbook_country_table.insert().values([ACCOUNT_1, ACCOUNT_2]))
await connection.execute(todo_table.insert().values([ACCOUNT_1, ACCOUNT_2]))
async def test_get_info_from_postgresql(test_client: AsyncClient):

View File

@@ -1,9 +1,7 @@
ACCOUNT_1 = {
"country_id": 1,
"iso_3166_code_alpha3": "RU",
"id": 1,
}
ACCOUNT_2 = {
"country_id": 2,
"iso_3166_code_alpha3": "EN",
"id": 2,
}