Skip to content

Instantly share code, notes, and snippets.

@stefanjenkner
Created June 12, 2018 21:11
Show Gist options
  • Save stefanjenkner/572373a9c84f2b0c6c4f36a326f065ba to your computer and use it in GitHub Desktop.
Save stefanjenkner/572373a9c84f2b0c6c4f36a326f065ba to your computer and use it in GitHub Desktop.
test_get_conditions2
class WeatherTestCase(unittest.TestCase):
# ...
@mock.patch('chalicelib.weather.requests.get', side_effect=mocked_requests_get)
@mock.patch('chalicelib.weather.REQUESTS_SESSION.get', side_effect=mocked_requests_get)
@mock.patch('chalicelib.weather._WU_API_KEY_ID', 'key')
def test_get_conditions2(self, mock_requests_get, mock_requests_session_get):
date_local = datetime(2018, 5, 27, 8, 19, 36, 0)
latitude = 50.75
longitude = 12.18
res = weather.get_conditions(date_local, latitude, longitude)
self.assertEqual(19.0, float(res['temp']))
self.assertEqual(5887, res['temp_distance'])
self.assertEqual('pws:ILANGENW10', res['temp_station'])
self.assertEqual(36, res['temp_offset'])
self.assertEqual('Clear', res['weather'])
self.assertEqual(33209, res['weather_distance'])
self.assertEqual('EDAC', res['weather_station'])
self.assertEqual(3624, res['weather_offset'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment