Skip to content

Commit

Permalink
ParkenDD#161 - Add test for use GeoJSON data as additional data input
Browse files Browse the repository at this point in the history
  • Loading branch information
Judith committed Nov 12, 2024
1 parent eade27b commit ad2641a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/converters/data/kienzler.geojson
Original file line number Diff line number Diff line change
@@ -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
]
}
}
]
}
35 changes: 35 additions & 0 deletions tests/converters/kienzler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit ad2641a

Please sign in to comment.