Modernize bot for Python 3.12
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
Примеры использования API сервисов для тестирования
|
||||
"""
|
||||
import asyncio
|
||||
from database import async_session_maker, init_db
|
||||
from services import UserService, LotteryService, ParticipationService
|
||||
from src.core.database import async_session_maker, init_db
|
||||
from src.core.services import UserService, LotteryService, ParticipationService
|
||||
|
||||
|
||||
async def example_usage():
|
||||
@@ -61,7 +61,7 @@ async def example_usage():
|
||||
|
||||
# Добавляем участников
|
||||
for user in users:
|
||||
success = await LotteryService.add_participant(session, lottery.id, user.id)
|
||||
success = await ParticipationService.add_participant(session, lottery.id, user.id)
|
||||
if success:
|
||||
print(f"✅ {user.first_name} присоединился к розыгрышу")
|
||||
|
||||
@@ -93,6 +93,7 @@ async def example_usage():
|
||||
|
||||
# Проводим розыгрыш
|
||||
results = await LotteryService.conduct_draw(session, lottery.id)
|
||||
await session.commit()
|
||||
|
||||
print(f"\n🏆 Результаты розыгрыша:")
|
||||
print(f"🎯 Розыгрыш: {lottery.title}")
|
||||
@@ -134,7 +135,7 @@ async def test_edge_cases():
|
||||
user = await UserService.get_user_by_telegram_id(session, 100000001)
|
||||
lottery = (await LotteryService.get_active_lotteries(session))[0]
|
||||
|
||||
success = await LotteryService.add_participant(session, lottery.id, user.id)
|
||||
success = await ParticipationService.add_participant(session, lottery.id, user.id)
|
||||
print(f"Повторное добавление участника: {'❌ Заблокировано' if not success else '⚠️ Разрешено'}")
|
||||
|
||||
# Попытка установить ручного победителя для несуществующего пользователя
|
||||
|
||||
Reference in New Issue
Block a user