From 45d6267d8a341c4dab6d192cec541fbc05b473bd Mon Sep 17 00:00:00 2001 From: Maaike Date: Wed, 29 Nov 2023 15:08:45 +0100 Subject: [PATCH] Issue 581 fix2 (#589) * return wsi from station metadata * update test, as fix leads to more bufr conversion * remove trailing whitespace --- tests/integration/test_workflow.py | 4 ++-- wis2box-management/wis2box/metadata/station.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/integration/test_workflow.py b/tests/integration/test_workflow.py index 5343c71b..5fa7385e 100644 --- a/tests/integration/test_workflow.py +++ b/tests/integration/test_workflow.py @@ -229,7 +229,7 @@ def test_message_api(): counts = { 'mw_met_centre': 24, 'roma_met_centre': 33, - 'alger_met_centre': 28, + 'alger_met_centre': 29, 'rnimh': 188, 'brazza_met_centre': 15 } @@ -242,7 +242,7 @@ def test_message_api(): r = SESSION.get(url).json() # should match sum of counts above - assert r['numberMatched'] == 288 + assert r['numberMatched'] == sum(counts.values()) msg = r['features'][5] is_valid, _ = validate_message(msg) diff --git a/wis2box-management/wis2box/metadata/station.py b/wis2box-management/wis2box/metadata/station.py index 18385128..d7b1c6c5 100644 --- a/wis2box-management/wis2box/metadata/station.py +++ b/wis2box-management/wis2box/metadata/station.py @@ -133,11 +133,9 @@ def station(): pass -def load_stations(wsi: str = '') -> dict: +def load_stations() -> dict: """Load stations from API - param wsi: `str` of WIGOS Station Identifier - :returns: `dict` of stations """ @@ -179,7 +177,7 @@ def get_stations_csv(wsi: str = '') -> str: LOGGER.info('Loading stations into csv-string') csv_output = [] - stations = load_stations(wsi) + stations = load_stations() for station in stations.values(): wsi = station['properties']['wigos_station_identifier'] @@ -363,15 +361,15 @@ def get_valid_wsi(wsi: str = '', tsi: str = '') -> Union[str, None]: :returns: `str`, of valid wsi or `None` """ - LOGGER.info(f'Validating WIGOS Station Identifier: {wsi}') - stations = load_stations(wsi) + LOGGER.info(f'Validating wsi={wsi}, tsi={tsi}') + stations = load_stations() if wsi in stations: return wsi else: for station in stations.values(): if station['properties']['traditional_station_identifier'] == tsi: - return wsi + return station['properties']['wigos_station_identifier'] return None @@ -385,7 +383,7 @@ def get_geometry(wsi: str = '') -> Union[dict, None]: :returns: `dict`, of station geometry or `None` """ - stations = load_stations(wsi) + stations = load_stations() if wsi in stations: return stations[wsi]['geometry']