diff --git a/pyproject.toml b/pyproject.toml index 3b9f4ca..fc80c47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mvg" -version = "1.0.5" +version = "1.1.0" description = "An unofficial interface to timetable information of the Münchner Verkehrsgesellschaft (MVG)." readme = "README.md" diff --git a/src/mvg/mvgapi.py b/src/mvg/mvgapi.py index ed51150..60a2435 100644 --- a/src/mvg/mvgapi.py +++ b/src/mvg/mvgapi.py @@ -41,7 +41,12 @@ class TransportType(Enum): BUS: tuple[str, str] = ("Bus", "mdi:bus") REGIONAL_BUS: tuple[str, str] = ("Regionalbus", "mdi:bus") SEV: tuple[str, str] = ("SEV", "mdi:taxi") - SHIFF: tuple[str, str] = ("Schiff", "mdi:ferry") + SCHIFF: tuple[str, str] = ("Schiff", "mdi:ferry") + + @classmethod + def all(cls) -> list[TransportType]: + """Returns a list of all products.""" + return [getattr(TransportType, c.name) for c in cls if c.name != "SEV"] class MvgApiError(Exception): @@ -339,8 +344,9 @@ async def departures_async( try: args = dict.fromkeys(Endpoint.FIB_LOCATION.value[1]) args.update({"globalId": station_id, "offsetInMinutes": offset, "limit": limit}) - if transport_types: - args.update({"transportTypes": ",".join([product.name for product in transport_types])}) + if transport_types is None: + transport_types = TransportType.all() + args.update({"transportTypes": ",".join([product.name for product in transport_types])}) result = await MvgApi.__api(Base.FIB, Endpoint.FIB_DEPARTURE, args) assert isinstance(result, list) diff --git a/tests/test_demo.py b/tests/test_demo.py index c70b56b..626e121 100644 --- a/tests/test_demo.py +++ b/tests/test_demo.py @@ -27,6 +27,17 @@ def test_faraway() -> None: print("BASIC: ", station, departures, end="\n\n") +def test_village() -> None: + """Test: basic usage""" + station = MvgApi.station('Egmating, Schule') + assert station['id'] == "de:09175:4212" + if station: + mvgapi = MvgApi(station['id']) + departures = mvgapi.departures() + assert len(departures) > 0 + print("BASIC: ", station, departures, end="\n\n") + + def test_nearby() -> None: """Test: station by coordinates""" station = MvgApi.nearby(48.1, 11.5)