TaxisLibrary/tests/test_orders.py

43 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pytest, asyncio
from TaxisLibrary.taxis_client import (
TaxisClient, OrderIn, OrderOut, OrderStatus,
ClientIn, ClientOut, DriverIn, DriverOut
)
@pytest.fixture
def client():
c = TaxisClient("http://127.0.0.1:7000")
asyncio.run(c.login("root", "12345"))
return c
class TestOrders:
@pytest.mark.asyncio
async def test_create_and_update_order(self, client):
# создаём клиента
c_in = ClientIn(name="Пётр", phone="+79281230001")
created_client = await client.create_client(c_in)
# создаём заказ с корректными адресами
order = OrderIn(
client_id=created_client.id,
from_address="Город Ставрополь улица Ленина 1",
to_address="Город Ставрополь улица Мира 10"
)
created_order = await client.create_order(order)
assert isinstance(created_order, OrderOut)
# обновляем статус
updated = await client.update_order_status(created_order.id, OrderStatus.SEARCHING_TAXI)
assert isinstance(updated, OrderOut)
# чистим
await client.delete_order(created_order.id)
await client.delete_client(created_client.id)
@pytest.mark.asyncio
async def test_list_orders(self, client):
result = await client.list_orders()
assert isinstance(result, list)
if result:
assert all(isinstance(o, OrderOut) for o in result)