2023-11-24 14:35:47 +02:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from typing import List
|
|
|
|
|
2023-11-20 00:05:48 +02:00
|
|
|
import pytest
|
|
|
|
|
2023-11-24 14:35:47 +02:00
|
|
|
from pyrmv import Client, enums
|
2023-11-27 22:44:17 +02:00
|
|
|
from pyrmv.classes import BoardArrival, BoardDeparture, Journey, Message, Stop, Trip
|
2023-11-24 14:35:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_board_arrival(api_client: Client, sample_stop_id: str):
|
|
|
|
assert isinstance(
|
|
|
|
api_client.board_arrival(id=sample_stop_id, journeys_max=3), BoardArrival
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_board_departure(api_client: Client, sample_stop_id: str):
|
|
|
|
assert isinstance(
|
|
|
|
api_client.board_departure(id=sample_stop_id, journeys_max=3), BoardDeparture
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_him_search(api_client: Client):
|
2024-09-08 02:28:18 +03:00
|
|
|
response = api_client.him_search(time_end=datetime.now() + timedelta(days=10))
|
|
|
|
|
|
|
|
if len(response) != 0:
|
|
|
|
assert isinstance(response[0], Message)
|
|
|
|
else:
|
|
|
|
assert isinstance(response, list)
|
2023-11-24 14:35:47 +02:00
|
|
|
|
|
|
|
|
2023-11-25 00:52:50 +02:00
|
|
|
def test_journey_detail(api_client: Client, sample_journey_id: str):
|
2023-11-27 22:44:17 +02:00
|
|
|
assert isinstance(
|
2023-11-25 00:52:50 +02:00
|
|
|
api_client.journey_detail(
|
|
|
|
sample_journey_id,
|
|
|
|
real_time_mode=enums.RealTimeMode.FULL,
|
|
|
|
),
|
|
|
|
Journey,
|
|
|
|
)
|
2023-11-24 14:35:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_stop_by_coords(api_client: Client, sample_origin: List[str]):
|
|
|
|
assert isinstance(
|
|
|
|
api_client.stop_by_coords(sample_origin[0], sample_origin[1], max_number=3)[0], Stop
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_stop_by_id(api_client: Client, sample_stop_id: str):
|
|
|
|
assert isinstance(api_client.stop_by_id(sample_stop_id), Stop)
|
|
|
|
|
|
|
|
|
|
|
|
def test_trip_find(
|
|
|
|
api_client: Client, sample_origin: List[str], sample_destination: List[float]
|
|
|
|
):
|
|
|
|
assert isinstance(
|
|
|
|
api_client.trip_find(
|
|
|
|
origin_coord_lat=sample_origin[0],
|
|
|
|
origin_coord_lon=sample_origin[1],
|
|
|
|
destination_coord_lat=sample_destination[0],
|
|
|
|
destination_coord_lon=sample_destination[1],
|
|
|
|
messages=True,
|
|
|
|
)[0],
|
|
|
|
Trip,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-11-25 00:52:50 +02:00
|
|
|
def test_trip_recon(
|
|
|
|
api_client: Client, sample_origin: List[str], sample_destination: List[float]
|
|
|
|
):
|
|
|
|
assert isinstance(
|
|
|
|
api_client.trip_recon(
|
|
|
|
api_client.trip_find(
|
|
|
|
origin_coord_lat=sample_origin[0],
|
|
|
|
origin_coord_lon=sample_origin[1],
|
|
|
|
destination_coord_lat=sample_destination[0],
|
|
|
|
destination_coord_lon=sample_destination[1],
|
|
|
|
messages=True,
|
|
|
|
)[0],
|
|
|
|
)[0],
|
|
|
|
Trip,
|
|
|
|
)
|
2023-11-20 00:05:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_stop_by_name(api_client: Client):
|
|
|
|
assert isinstance(api_client.stop_by_name("Hauptwache", max_number=1)[0], Stop)
|