TaxisLibrary/tests/test_union.py

33 lines
1.3 KiB
Python

import pytest, asyncio
from TaxisLibrary.taxis_client import TaxisClient, AddressRequest, DistanceRequest, Geocode
@pytest.fixture
def client():
c = TaxisClient("http://127.0.0.1:7000")
asyncio.run(c.login("root", "12345"))
return c
class TestUnion:
@pytest.mark.asyncio
async def test_geocode_address(self, client):
result = await client.geocode_address("Город Ставрополь улица Мира 10")
assert isinstance(result, Geocode)
@pytest.mark.asyncio
async def test_distance(self, client):
req = DistanceRequest(
coord_from=Geocode(latitude=45.0428, longitude=41.9734), # координаты центра Ставрополя
coord_to=Geocode(latitude=45.0450, longitude=41.9800) # точка рядом
)
result = await client.get_distance(req)
assert isinstance(result, float)
@pytest.mark.asyncio
async def test_distance_by_address(self, client):
req = AddressRequest(
address_from="Город Ставрополь улица Доваторцев 10",
address_to="Город Ставрополь улица Мира 10"
)
result = await client.get_distance_by_address(req)
assert isinstance(result, float)