Skip to content

Commit

Permalink
add assertions to the SMHI unit testing per instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
docNord committed May 4, 2024
1 parent 9d42f22 commit b455417
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/unit/test_unit_smhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def __init__(self, station: MockMetobsStationLink):
self.station = station


class MockStationModel:
"""Support class to mock Metobs Station object."""

def __init__(self, data="str"):
"""Initiate data"""
self.data = data


@pytest.fixture
def setup_test_x():
"""Pytest fixture"""
Expand Down Expand Up @@ -57,7 +65,7 @@ def setup_test_x():
class TestUnitSMHI:
"""Unit tests for SMHI class."""

@patch("smhi.metobs.Parameters.__new__")
@patch("smhi.metobs.Parameters.__new__", return_value="test")
def test_unit_smhi_init(self, mock_parameters):
"""Unit test for SMHI init method.
Expand All @@ -66,10 +74,10 @@ def test_unit_smhi_init(self, mock_parameters):
"""
client = SMHI()

assert client.parameters
assert client.parameters == "test"

@pytest.mark.parametrize("parameter", [(None), (1)])
@patch("smhi.metobs.Stations.__new__")
@patch("smhi.metobs.Stations.__new__", return_value=MockStationModel("Test"))
def test_unit_smhi_get_stations(self, mock_station_data, parameter):
"""Unit test for SMHI get_stations method.
Expand All @@ -78,10 +86,10 @@ def test_unit_smhi_get_stations(self, mock_station_data, parameter):
parameter: parameter (int)
"""
client = SMHI()
assert client.get_stations(parameter)
assert client.get_stations(parameter) == "Test"

@pytest.mark.parametrize("parameter_title", [(None), ("Snöfall")])
@patch("smhi.metobs.Stations.__new__")
@patch("smhi.metobs.Stations.__new__", return_value=MockStationModel("Test"))
def test_unit_smhi_get_stations_from_title(
self, mock_station_data, parameter_title
):
Expand All @@ -92,7 +100,7 @@ def test_unit_smhi_get_stations_from_title(
parameter_title: title of parameter
"""
client = SMHI()
assert client.get_stations_from_title(parameter_title)
assert client.get_stations_from_title(parameter_title) == "Test"

@pytest.mark.parametrize(
"parameter, station, distance", [(8, 180960, None), (8, 180960, 50)]
Expand Down

0 comments on commit b455417

Please sign in to comment.