Skip to content

Commit

Permalink
Issue 581 fix2 (#589)
Browse files Browse the repository at this point in the history
* return wsi from station metadata

* update test, as fix leads to more bufr conversion

* remove trailing whitespace
  • Loading branch information
maaikelimper authored Nov 29, 2023
1 parent 4da37b6 commit 45d6267
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/integration/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
14 changes: 6 additions & 8 deletions wis2box-management/wis2box/metadata/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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

Expand All @@ -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']

Expand Down

0 comments on commit 45d6267

Please sign in to comment.