import pytest, asyncio from TaxisLibrary.taxis_client import ( TaxisClient, OrderNotificationsIn, OrderNotificationsOut, OrderNotifySide, OrderNotifyType, ClientIn, ClientOut, OrderIn, OrderOut ) @pytest.fixture def client(): c = TaxisClient("http://127.0.0.1:7000") asyncio.run(c.login("root", "12345")) return c class TestOrderNotifications: @pytest.mark.asyncio async def test_create_and_process_notification(self, client): # создаём клиента created_client = await client.get_client_by_phone("79281230010") if not created_client: c_in = ClientIn(phone="79281230010") created_client = await client.create_client(c_in) # создаём заказ order_in = OrderIn( client_id=created_client.id, from_address="Город Ставрополь улица Ленина 1", to_address="Город Ставрополь улица Мира 10" ) created_order = await client.create_order(order_in) # создаём уведомление по заказу n_in = OrderNotificationsIn( order_id=created_order.id, notify_side=OrderNotifySide.CLIENT.value, notify_type=OrderNotifyType.CANCELED_BY_CLIENT.value ) created_notification = await client.create_order_notification(n_in) assert isinstance(created_notification, OrderNotificationsOut) # помечаем как обработанное processed = await client.mark_order_notification_processed(created_notification.id, True) assert processed.processed is True # чистим await client.delete_order_notification(created_notification.id) await client.delete_order(created_order.id) await client.delete_client(created_client.id)