Skip to content

Commit

Permalink
Fixing issue csparpa#387 - updating lat, lon keys
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpirogov committed Jan 24, 2022
1 parent 0474b61 commit 6b16ca8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyowm/airpollutionapi30/airstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def from_dict(cls, the_dict):
raise exceptions.ParseAPIResponseError('Data is None')
try:
# -- location
lon = float(the_dict['coord']['lat'])
lat = float(the_dict['coord']['lon'])
lon = float(the_dict['coord']['lon'])
lat = float(the_dict['coord']['lat'])
place = location.Location(None, lon, lat, None)

# -- reception time (now)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,38 @@ class IntegrationTestsPollutionAPI30(unittest.TestCase):

__owm = owm.OWM(os.getenv('OWM_API_KEY', None)).airpollution_manager()

def test_air_quality_at_coords(self):
def test_air_quality_at_coords(self, lat=45, lon=9):
"""
Test feature: get all air quality data around geo-coordinates.
"""
airstatus = self.__owm.air_quality_at_coords(45, 9)
airstatus = self.__owm.air_quality_at_coords(lat, lon)
self.assertIsNotNone(airstatus)
self.assertIsNotNone(airstatus.air_quality_data)
self.assertIsNotNone(airstatus.reception_time())
self.assertIsNotNone(airstatus.reference_time())
self.assertIsNotNone(airstatus.location)

def test_air_quality_at_range_of_coords(self):
"""
Test feature: tests air quality data around a range of geo-coordinates
"""

# Cities chosen based on extreme locations in longitude and latitude as well
# as being major hubs that measure and return air quality data
geocoords = [
{'lat': -43.951 , 'lon': -176.561 }, # Waitangi
{'lat': 21.3294 , 'lon': -157.846 }, # Honolulu
{'lat': 45.6366 , 'lon': -122.5967}, # Vancouver
{'lat': 37.7562 , 'lon': -122.443 }, # San Francisco
{'lat': 64.7333 , 'lon': 177.7 }, # Ugol'nyye Kopi
{'lat': -77.6554, 'lon': 168.2227 }, # McMurdo Station, Antarctica
{'lat': -38.6625, 'lon': 178.0178 }, # Gisborne
{'lat': -18.1333, 'lon': 178.4333 }, # Suva
]

for location in geocoords:
self.test_air_quality_at_coords(lat=location['lat'], lon=location['lon'])

def test_air_quality_forecast_at_coords(self):
"""
Test feature: get all forecasted air quality data around geo-coordinates.
Expand Down

0 comments on commit 6b16ca8

Please sign in to comment.