Skip to content

Commit 88b3aba

Browse files
committed
fixes
1 parent b4e4a3c commit 88b3aba

2 files changed

Lines changed: 7 additions & 19 deletions

File tree

api_v1/tests/conftest.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from asgi_lifespan import LifespanManager
99
from fastapi import FastAPI
1010
from sqlalchemy.pool import NullPool
11-
from alembic.config import Config
12-
from alembic import command
1311

1412
from config import test_connection, settings, BaseModel
1513
from config import db_connection
@@ -22,16 +20,6 @@
2220
)
2321

2422

25-
cfg = Config()
26-
cfg.set_main_option(
27-
'sqlalchemy.url',
28-
settings.test_db.url,
29-
)
30-
cfg.set_main_option('script_location',
31-
settings.alembic.MIGRATION_PATH.as_posix(),
32-
)
33-
34-
3523
@pytest.fixture(scope='session', autouse=True)
3624
def event_loop(request):
3725
loop = asyncio.get_event_loop_policy().new_event_loop()
@@ -50,7 +38,6 @@ async def app() -> AsyncGenerator[LifespanManager, Any]:
5038
async def lifespan(app: FastAPI):
5139
async with db_setup.engine.begin() as conn:
5240
await conn.run_sync(BaseModel.metadata.create_all)
53-
await conn.run_sync(alembic_do_upgrade)
5441
yield
5542
await conn.run_sync(BaseModel.metadata.drop_all)
5643

@@ -76,9 +63,7 @@ async def client(app: FastAPI) -> AsyncGenerator[httpx.AsyncClient, Any]:
7663
yield client
7764

7865

79-
def alembic_do_upgrade(connection):
80-
"""
81-
Upgrade миграция алембик
82-
"""
83-
cfg.attributes['connection'] = connection
84-
command.upgrade(cfg, 'head')
66+
@pytest_asyncio.fixture()
67+
async def get_async_session():
68+
async with db_setup.session() as session:
69+
yield session

config/celery/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ def wrapper(*args,
4141

4242
app = Celery(__name__)
4343
app.conf.broker_url = settings.rabbit.broker_url
44+
app.conf.result_backend = 'db+' + settings.db.url
45+
app.conf.database_engine_options = {'echo': True}
4446
app.conf.timezone = settings.celery.TIMEZONE
47+
app.conf.broker_connection_retry_on_startup = True
4548
app.autodiscover_tasks(packages=['api_v1.users'])

0 commit comments

Comments
 (0)