Skip to content

Commit

Permalink
Fix strang unit tests and add mesan text files
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcth committed Mar 31, 2024
1 parent 52d8c58 commit bbd5f38
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/fixtures/mesan/multipoint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Via: 1.1 varnish (Varnish/6.6)
X-Varnish: 681874038
X-hits: 0

{"approvedTime":"2024-03-31T08:39:25Z","referenceTime":"2024-03-31T08:00:00Z","geometry":{"type":"MultiPoint","coordinates":[[2.250475,52.500440]]},"timeSeries":[{"validTime":"2024-03-31T08:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[8.3]}]}]}
{"approvedTime":"2024-03-31T08:39:25Z","referenceTime":"2024-03-31T08:00:00Z","geometry":{"type":"MultiPoint","coordinates":[[2.250475,52.500440]]},"timeSeries":[{"validTime":"2024-03-31T08:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[8.3]}]}]}
2 changes: 1 addition & 1 deletion tests/fixtures/mesan/point.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Accept-Ranges: bytes
Connection: keep-alive
Transfer-Encoding: chunked

{"approvedTime":"2024-03-31T08:39:25Z","referenceTime":"2024-03-31T08:00:00Z","geometry":{"type":"Point","coordinates":[[16.150350,58.570784]]},"timeSeries":[{"validTime":"2024-03-31T08:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[5.5]},{"name":"gust","levelType":"hl","level":10,"unit":"m/s","values":[5.7]},{"name":"r","levelType":"hl","level":2,"unit":"percent","values":[90]},{"name":"msl","levelType":"hmsl","level":0,"unit":"hPa","values":[1002.5]},{"name":"Tiw","levelType":"hl","level":2,"unit":"Cel","values":[4.8]},{"name":"cb_sig","levelType":"hmsl","level":0,"unit":"m","values":[178]},{"name":"cb_sig","levelType":"hl","level":0,"unit":"m","values":[143]},{"name":"c_sigfr","levelType":"hl","level":0,"unit":"percent","values":[80]},{"name":"tcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"ct_sig","levelType":"hl","level":0,"unit":"m","values":[9792]},{"name":"lcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"hcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"mcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"prtype","levelType":"hl","level":0,"unit":"code","values":[-9]},{"name":"pmax","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmin","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmedian","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmean","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"prec1h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"prec3h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"frsn1h","levelType":"hl","level":0,"unit":"cm","values":[0.0]},{"name":"vis","levelType":"hl","level":2,"unit":"km","values":[43.9]},{"name":"spp","levelType":"hl","level":0,"unit":"percent","values":[-9]},{"name":"prsort","levelType":"hl","level":0,"unit":"code","values":[0]},{"name":"wd","levelType":"hl","level":10,"unit":"degree","values":[86]},{"name":"ws","levelType":"hl","level":10,"unit":"m/s","values":[2.9]},{"name":"Wsymb2","levelType":"hl","level":0,"unit":"category","values":[6]}]},{"validTime":"2024-03-31T07:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[4.7]},{"name":"gust","levelType":"hl","level":10,"unit":"m/s","values":[5.1]},{"name":"r","levelType":"hl","level":2,"unit":"percent","values":[93]},{"name":"msl","levelType":"hmsl","level":0,"unit":"hPa","values":[1002.6]},{"name":"Tiw","levelType":"hl","level":2,"unit":"Cel","values":[4.2]},{"name":"cb_sig","levelType":"hmsl","level":0,"unit":"m","values":[178]},{"name":"cb_sig","levelType":"hl","level":0,"unit":"m","values":[139]},{"name":"c_sigfr","levelType":"hl","level":0,"unit":"percent","values":[80]},{"name":"tcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"ct_sig","levelType":"hl","level":0,"unit":"m","values":[6728]},{"name":"lcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"hcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"mcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"prtype","levelType":"hl","level":0,"unit":"code","values":[-9]},{"name":"pmax","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmin","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmedian","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmean","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"prec1h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"prec3h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"frsn1h","levelType":"hl","level":0,"unit":"cm","values":[0.0]},{"name":"vis","levelType":"hl","level":2,"unit":"km","values":[38.0]},{"name":"spp","levelType":"hl","level":0,"unit":"percent","values":[-9]},{"name":"prsort","levelType":"hl","level":0,"unit":"code","values":[0]},{"name":"wd","levelType":"hl","level":10,"unit":"degree","values":[83]},{"name":"ws","levelType":"hl","level":10,"unit":"m/s","values":[2.4]},{"name":"Wsymb2","levelType":"hl","level":0,"unit":"category","values":[6]}]}]}
{"approvedTime":"2024-03-31T08:39:25Z","referenceTime":"2024-03-31T08:00:00Z","geometry":{"type":"Point","coordinates":[[16.150350,58.570784]]},"timeSeries":[{"validTime":"2024-03-31T08:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[5.5]},{"name":"gust","levelType":"hl","level":10,"unit":"m/s","values":[5.7]},{"name":"r","levelType":"hl","level":2,"unit":"percent","values":[90]},{"name":"msl","levelType":"hmsl","level":0,"unit":"hPa","values":[1002.5]},{"name":"Tiw","levelType":"hl","level":2,"unit":"Cel","values":[4.8]},{"name":"cb_sig","levelType":"hmsl","level":0,"unit":"m","values":[178]},{"name":"cb_sig","levelType":"hl","level":0,"unit":"m","values":[143]},{"name":"c_sigfr","levelType":"hl","level":0,"unit":"percent","values":[80]},{"name":"tcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"ct_sig","levelType":"hl","level":0,"unit":"m","values":[9792]},{"name":"lcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"hcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"mcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"prtype","levelType":"hl","level":0,"unit":"code","values":[-9]},{"name":"pmax","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmin","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmedian","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmean","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"prec1h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"prec3h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"frsn1h","levelType":"hl","level":0,"unit":"cm","values":[0.0]},{"name":"vis","levelType":"hl","level":2,"unit":"km","values":[43.9]},{"name":"spp","levelType":"hl","level":0,"unit":"percent","values":[-9]},{"name":"prsort","levelType":"hl","level":0,"unit":"code","values":[0]},{"name":"wd","levelType":"hl","level":10,"unit":"degree","values":[86]},{"name":"ws","levelType":"hl","level":10,"unit":"m/s","values":[2.9]},{"name":"Wsymb2","levelType":"hl","level":0,"unit":"category","values":[6]}]},{"validTime":"2024-03-31T07:00:00Z","parameters":[{"name":"t","levelType":"hl","level":2,"unit":"Cel","values":[4.7]},{"name":"gust","levelType":"hl","level":10,"unit":"m/s","values":[5.1]},{"name":"r","levelType":"hl","level":2,"unit":"percent","values":[93]},{"name":"msl","levelType":"hmsl","level":0,"unit":"hPa","values":[1002.6]},{"name":"Tiw","levelType":"hl","level":2,"unit":"Cel","values":[4.2]},{"name":"cb_sig","levelType":"hmsl","level":0,"unit":"m","values":[178]},{"name":"cb_sig","levelType":"hl","level":0,"unit":"m","values":[139]},{"name":"c_sigfr","levelType":"hl","level":0,"unit":"percent","values":[80]},{"name":"tcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"ct_sig","levelType":"hl","level":0,"unit":"m","values":[6728]},{"name":"lcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"hcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"mcc","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"prtype","levelType":"hl","level":0,"unit":"code","values":[-9]},{"name":"pmax","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmin","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmedian","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmean","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"prec1h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"prec3h","levelType":"hl","level":0,"unit":"mm","values":[0.0]},{"name":"frsn1h","levelType":"hl","level":0,"unit":"cm","values":[0.0]},{"name":"vis","levelType":"hl","level":2,"unit":"km","values":[38.0]},{"name":"spp","levelType":"hl","level":0,"unit":"percent","values":[-9]},{"name":"prsort","levelType":"hl","level":0,"unit":"code","values":[0]},{"name":"wd","levelType":"hl","level":10,"unit":"degree","values":[83]},{"name":"ws","levelType":"hl","level":10,"unit":"m/s","values":[2.4]},{"name":"Wsymb2","levelType":"hl","level":0,"unit":"category","values":[6]}]}]}
File renamed without changes.
22 changes: 4 additions & 18 deletions tests/unit/test_unit_strang.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_unit_strang_build_time_multipoint_url(self, time_interval, expected_url
[
(200, [{"date_time": "2020-01-01T00:00:00Z"}]),
(200, [{"lat": 0, "lon": 0, "value": 0}]),
(400, [{"date_time": "2020-01-01T00:00:00Z"}]),
(200, [{"date_time": "2020-01-01T00:00:00Z"}]),
],
)
@patch("smhi.strang.Strang._parse_multipoint_data")
Expand All @@ -430,17 +430,7 @@ def test_unit_strang_get_and_load_data(
status_expected,
data,
):
"""Unit test for Strang Point get_and_load_strang_data method.
Args:
mock_requests_get: mock requests get method
mock_json_loads: mock json loads method
mock_logging: mock of logging warning method
mock_parse_point_data: mock of _parse_point_data
mock_parse_multipoint_data: mock of _parse_multipoint_data
status: request status
data: date
"""
"""Unit test for Strang Point get_and_load_strang_data method."""
client = Strang()
client.url = "URL"
mock_json_loads.return_value = data
Expand Down Expand Up @@ -519,9 +509,7 @@ def test_unit_strang_parse_point_data(
output: output data
"""
client = Strang()
parameter_model = STRANG_PARAMETERS[parameter]

data = client._parse_point_data(input, parameter_model)
data = client._parse_point_data(input)

pd.testing.assert_frame_equal(data, output)

Expand Down Expand Up @@ -550,8 +538,6 @@ def test_unit_strang_parse_multipoint_data(
output: output data
"""
client = Strang()
parameter_model = STRANG_PARAMETERS[parameter]

data = client._parse_multipoint_data(input, parameter_model)
data = client._parse_multipoint_data(input)

pd.testing.assert_frame_equal(data, output)

0 comments on commit bbd5f38

Please sign in to comment.