Skip to content

Commit

Permalink
#51: Fix invalid coordinate handling (#54)
Browse files Browse the repository at this point in the history
* Fix invalid coordinate handling

* Increase the version

* Update github actions
  • Loading branch information
saaste authored May 9, 2024
1 parent 7e574e0 commit a7bb8a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions fmi_weather_client/parsers/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def _get_place(data: Dict[str, Any]) -> FMIPlace:
['gml:MultiPoint']['gml:pointMembers']['gml:Point'])

coordinates = place_data['gml:pos'].split(' ', 1)
lon = float(coordinates[0])
lat = float(coordinates[1])
lat = float(coordinates[0])
lon = float(coordinates[1])

return FMIPlace(place_data['gml:name'], lat, lon)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="fmi-weather-client",
version="0.2.1",
version="0.2.2",
author="Mika Hiltunen",
author_email="saaste@gmail.com",
description="Library for fetching weather information from Finnish Meteorological Institute (FMI)",
Expand Down
10 changes: 5 additions & 5 deletions test/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_get_forecast_by_coordinates(self, mock_get):
@mock.patch('requests.get', side_effect=test_data.mock_coordinate_forecast_response)
def test_async_get_forecast_by_coordinates(self, mock_get):
loop = asyncio.get_event_loop()
forecast = loop.run_until_complete(fmi_weather_client.async_forecast_by_coordinates(29.742731, 67.583988))
forecast = loop.run_until_complete(fmi_weather_client.async_forecast_by_coordinates(67.583988, 29.742731))
self.assert_coordinate_forecast(forecast)

# CORNER CASES
Expand Down Expand Up @@ -128,17 +128,17 @@ def assert_coordinate_weather(self, weather):

def assert_name_forecast(self, forecast):
self.assertEqual(forecast.place, 'Iisalmi')
self.assertEqual(forecast.lat, 27.19067)
self.assertEqual(forecast.lon, 63.55915)
self.assertEqual(forecast.lat, 63.55915)
self.assertEqual(forecast.lon, 27.19067)
self.assertEqual(len(forecast.forecasts), 12)
self.assertEqual(forecast.forecasts[0].temperature.value, 12.3)
self.assertEqual(forecast.forecasts[1].pressure.value, 1000.6)
self.assertEqual(forecast.forecasts[4].humidity.value, 80.7)

def assert_coordinate_forecast(self, forecast):
self.assertEqual(forecast.place, 'Sauoiva')
self.assertEqual(forecast.lat, 29.74273)
self.assertEqual(forecast.lon, 67.58399)
self.assertEqual(forecast.lat, 67.58399)
self.assertEqual(forecast.lon, 29.74273)
self.assertEqual(len(forecast.forecasts), 12)
self.assertEqual(forecast.forecasts[0].temperature.value, 6.8)
self.assertEqual(forecast.forecasts[1].pressure.value, 1005.8)
Expand Down

0 comments on commit a7bb8a8

Please sign in to comment.