26 lines
864 B
Python
26 lines
864 B
Python
import pytest, asyncio
|
|
from TaxisLibrary.taxis_client import TaxisClient, ClientIn, ClientOut
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
c = TaxisClient("http://127.0.0.1:7000")
|
|
asyncio.run(c.login("root", "12345"))
|
|
return c
|
|
|
|
class TestClients:
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_and_get_client(self, client):
|
|
c_in = ClientIn(name="Petya", phone="79281234569")
|
|
created = await client.create_client(c_in)
|
|
assert isinstance(created, ClientOut)
|
|
got = await client.get_client(created.id)
|
|
assert isinstance(got, ClientOut)
|
|
await client.delete_client(created.id)
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_clients(self, client):
|
|
result = await client.list_clients()
|
|
assert isinstance(result, list)
|
|
if result:
|
|
assert all(isinstance(c, ClientOut) for c in result)
|