update dependencies and python to 3.12.3 (#95)

* update dependencies and python to 3.12.3

* fix tests
This commit is contained in:
Dmitry Afanasyev
2024-04-20 19:16:37 +03:00
committed by GitHub
parent 3e7bbb6f60
commit b6a0427b1b
8 changed files with 561 additions and 356 deletions

View File

@@ -70,7 +70,7 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
async def bug_report(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Send a message when the command /bug-report is issued."""
if not update.effective_message:
if not update.effective_message or not settings.ADMIN_CHAT_ID:
return
async with get_bot(settings.TELEGRAM_API_TOKEN) as bot:
await bot.send_message(chat_id=settings.ADMIN_CHAT_ID, text=f"Bug report from user: {update.effective_user}")

View File

@@ -12,6 +12,7 @@ TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
START_WITH_WEBHOOK="false"
SUPERUSER="Superuser"
ADMIN_CHAT_ID="123456789"
# ==== domain settings ====
DOMAIN="http://localhost"

View File

@@ -27,7 +27,7 @@ def test_settings() -> AppSettings:
# Redefine the event_loop fixture to have a session scope. Otherwise `bot` fixture can't be
# session. See https://github.com/pytest-dev/pytest-asyncio/issues/68 for more details.
@pytest.fixture(scope="session", autouse=True)
def event_loop() -> AbstractEventLoop:
async def event_loop() -> AsyncGenerator[AbstractEventLoop, None]:
"""
Пересоздаем луп для изоляции тестов. В основном нужно для запуска юнит тестов
в связке с интеграционными, т.к. без этого pytest зависает.
@@ -35,7 +35,10 @@ def event_loop() -> AbstractEventLoop:
"""
loop = asyncio.get_event_loop_policy().new_event_loop()
asyncio.set_event_loop(loop)
return loop
try:
yield loop
finally:
loop.close()
@pytest.fixture(scope="session")
@@ -186,7 +189,7 @@ async def main_application(
await database.drop_database()
@pytest.fixture()
@pytest.fixture
async def rest_client(main_application: AppApplication) -> AsyncGenerator[AsyncClient, None]:
"""
Default http client. Use to test unauthorized requests, public endpoints