def test_openweather_conditions1(self): """ Get the weather conditions for 'Salt Lake City, Utah' and verify that the returned object contains the properties: id dt coord.lat coord.lng name main.temp main.humidity main.pressure wind.speed wind.deg clouds.all For more information, see the Weather Parameters page http://openweathermap.org/weather-data. """ location = 'Salt Lake City, Utah, United States' conditions = pyweather.openweather_conditions(location) expected_keys = ['id', 'dt', 'coord', 'name', 'main', 'wind', 'clouds'] actual_keys = conditions.keys() outcome = all(k in actual_keys for k in expected_keys) self.assertTrue(outcome)
def test_openweather_conditions2(self): """ Attempt to get the weather conditions for an unknown city. As per the API a JSON object will be returned like so: {"message":"Error: Not found city","cod":"404"}. Assert that None is returned, indicating that no weather data could be retrieved. """ location = 'badcity' conditions = pyweather.openweather_conditions(location) self.assertEqual(None, conditions)