Skip to content

Commit

Permalink
Add period station_set unit test, skipping data station_set currently
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcth committed Mar 25, 2024
1 parent 6d93a91 commit b1bd846
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
3 changes: 3 additions & 0 deletions tests/fixtures/metobs/periods_data_set.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"latest-hour"
]
17 changes: 17 additions & 0 deletions tests/fixtures/metobs/periods_set.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Date: Mon, 25 Mar 2024 21:03:03 GMT
Cache-Control: max-age=60
Content-Encoding: gzip
Vary: Accept-Encoding
X-Varnish: 406815169 414449707
Age: 16
Via: 1.1 varnish (Varnish/6.6)
X-hits: 2
Access-Control-Allow-Origin: *
Last-Modified: Mon, 25 Mar 2024 21:03:20 GMT
Accept-Ranges: bytes
Content-Length: 365
Connection: keep-alive

{"key":"all","updated":1711396800000,"title":"Lufttemperatur - Alla Stationer: Välj tidsutsnitt","summary":"Data från alla aktiva mätstationer för senaste timmen i en fil.","link":[{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all.json","rel":"stationSet","type":"application/json"},{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all.xml","rel":"stationSet","type":"application/xml"},{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all.atom","rel":"stationSet","type":"application/atom+xml"},{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1.atom","rel":"parameter","type":"application/atom+xml"}],"period":[{"key":"latest-hour","updated":1711396800000,"title":"Data från senaste timmen","summary":"","link":[{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all/period/latest-hour.json","rel":"period","type":"application/json"},{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all/period/latest-hour.xml","rel":"period","type":"application/xml"},{"href":"https://opendata-download-metobs.smhi.se/api/version/1.0/parameter/1/station-set/all/period/latest-hour.atom","rel":"period","type":"application/atom+xml"}]}]}
30 changes: 1 addition & 29 deletions tests/unit/test_unit_metobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def setup_periods_set(setup_stations):

mocked_response = get_response("tests/fixtures/metobs/periods_set.txt")
mocked_model = PeriodModel.model_validate_json(mocked_response.content)
mocked_data = get_data("tests/fixtures/metobs/periods_data.json", "period")
mocked_data = get_data("tests/fixtures/metobs/periods_data_set.json", "period")

return (
mocked_response,
Expand Down Expand Up @@ -250,34 +250,6 @@ def setup_data(setup_periods):
)


@pytest.fixture
def setup_data_set(setup_periods):
"""Read in Data response for station_set.
Returns:
mocked response
expected answer as pydantic structure
data data
"""
_, mocked_model_periods, _, _ = setup_periods_set

mocked_response = get_response("tests/fixtures/metobs/data.txt", encode=True)
mocked_model = DataModel.model_validate_json(mocked_response.content)
mocked_csv_data = get_data("tests/fixtures/metobs/data_csv.csv", "data")

mocked_parameter = get_data("tests/fixtures/metobs/data_parameter.json")
mocked_data = get_data("tests/fixtures/metobs/data_data.json")

return (
mocked_response,
mocked_model,
mocked_model_periods,
mocked_csv_data,
mocked_parameter,
mocked_data,
)


class TestUnitBaseMetobs:
"""Unit tests for BaseMetobs class."""

Expand Down

0 comments on commit b1bd846

Please sign in to comment.