Skip to content

Commit

Permalink
fix test_find_stations_from_gps
Browse files Browse the repository at this point in the history
  • Loading branch information
docNord committed Apr 23, 2024
1 parent 7a9cf8b commit 3e07f72
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/unit/test_unit_smhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ def test_unit_get_data_by_city(
data = client.get_data_by_city(parameter, city, distance)
assert data == "test"

distanceresponse = MagicMock()
distanceresponse.km = 0

@pytest.mark.parametrize(
"latitude, longitude,dist",
[
(
59,
17,
None,
0,
),
(
59.4,
Expand All @@ -105,23 +108,25 @@ def test_unit_get_data_by_city(
),
],
)
@patch("geopy.distance")
@patch("geopy.distance.distance", return_value=distanceresponse)
def test_find_stations_from_gps(self, mock_distance, latitude, longitude, dist):
"""Unit test for SMHI find_stations_from_gps method.
Args:
"""
station1 = MagicMock()
station1.id = 1
station1.name = "Akalla"
station1.latitude = 59.5
station1.longitude = 17.8
stations = MagicMock()
stations.station.id.return_value = 1
stations.station.name.return_value = "Akalla"
stations.station.latitude.return_value = 59.5
stations.station.longitude.return_value = 17.8
mock_distance.distance.return_value = 0
stations.station = [station1]

client = SMHI()
nearby_town = client._find_stations_from_gps(
stations, latitude, longitude, dist
)
assert nearby_town[0][0] in stations.station.id
assert nearby_town[0][0] == 1

def test_find_stations_by_city(
self,
Expand Down

0 comments on commit 3e07f72

Please sign in to comment.