diff --git a/tests/converters/data/kienzler.geojson b/tests/converters/data/kienzler.geojson new file mode 100644 index 0000000..dbad4d6 --- /dev/null +++ b/tests/converters/data/kienzler.geojson @@ -0,0 +1,31 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "uid": "unit460", + "type": "TWO_TIER", + "max_height": 1250, + "max_width": 800, + "max_depth": 1970, + "park_and_ride_type": [ + "TRAIN" + ], + "external_identifiers": [ + { + "type": "DHID", + "value": "de:08317:14500_Parent" + } + ] + }, + "geometry": { + "type": "Point", + "coordinates": [ + 7.947474, + 48.475546 + ] + } + } + ] +} diff --git a/tests/converters/kienzler_test.py b/tests/converters/kienzler_test.py index b9f1177..03d228a 100644 --- a/tests/converters/kienzler_test.py +++ b/tests/converters/kienzler_test.py @@ -24,12 +24,27 @@ def requests_mock_kienzler(requests_mock: Mocker) -> Mocker: return requests_mock +@pytest.fixture +def requests_mock_kienzler_with_geojson(requests_mock: Mocker) -> Mocker: + json_path = Path(Path(__file__).parent, 'data', 'kienzler.geojson') + with json_path.open() as json_file: + json_data = json_file.read() + + requests_mock.get( + 'https://raw.githubusercontent.com/ParkenDD/parkapi-static-data/refs/heads/main/sources/kienzler_bike_and_ride.geojson', + text=json_data, + ) + + return requests_mock + + @pytest.fixture def kienzler_config_helper(mocked_config_helper: Mock): config = { 'PARK_API_KIENZLER_BIKE_AND_RIDE_USER': '01275925-742c-460b-8778-eca90eb114bc', 'PARK_API_KIENZLER_BIKE_AND_RIDE_PASSWORD': '626027f2-66e9-40bd-8ff2-4c010f5eca05', 'PARK_API_KIENZLER_BIKE_AND_RIDE_IDS': 'id1,id2,id3', + 'STATIC_GEOJSON_BASE_URL': 'https://raw.githubusercontent.com/ParkenDD/parkapi-static-data/refs/heads/main/sources', } mocked_config_helper.get.side_effect = lambda key, default=None: config.get(key, default) return mocked_config_helper @@ -40,6 +55,11 @@ def kienzler_pull_converter(kienzler_config_helper: Mock) -> KienzlerBikeAndRide return KienzlerBikeAndRidePullConverter(config_helper=kienzler_config_helper) +@pytest.fixture +def kienzler_pull_converter_with_geojson(kienzler_config_helper: Mock) -> KienzlerBikeAndRidePullConverter: + return KienzlerBikeAndRidePullConverter(config_helper=kienzler_config_helper, use_geojson=True) + + class KienzlerPullConverterTest: @staticmethod def test_get_static_parking_sites( @@ -53,6 +73,21 @@ def test_get_static_parking_sites( validate_static_parking_site_inputs(static_parking_site_inputs) + @staticmethod + def test_get_static_parking_sites_with_geojson( + kienzler_pull_converter_with_geojson: KienzlerBikeAndRidePullConverter, + requests_mock_kienzler: Mocker, + requests_mock_kienzler_with_geojson: Mocker, + ): + static_parking_site_inputs, import_parking_site_exceptions = ( + kienzler_pull_converter_with_geojson.get_static_parking_sites() + ) + + assert len(static_parking_site_inputs) == 5 + assert len(import_parking_site_exceptions) == 0 + + validate_static_parking_site_inputs(static_parking_site_inputs) + @staticmethod def test_get_realtime_parking_sites( kienzler_pull_converter: KienzlerBikeAndRidePullConverter,