예제 #1
0
 def test_unsuccessful_request_to_api(self, mock_request):
     '''
     A Weather object whose last call time should not be able to make an
     api request
     '''
     w = Weather(datetime.datetime.now())
     w.WeatherData = False
     id = 1
     # api_key = w.api_key
     w.request_weather_with_id(id)
     # http = 'http://api.openweathermap.org/data/2.5/weather?id=1&APPID='
     # arg = f'{http}{api_key}'
     self.assertFalse(w.WeatherData)
예제 #2
0
 def test_successful_request_to_api(self, mock_request, mock_store):
     '''
     A Weather object whose last call time is greater than the rate limit
     should be able to make an api call
     '''
     w = Weather(datetime.datetime(1970, 1, 1))
     id = 1
     api_key = w.api_key
     w.request_weather_with_id(id)
     http = 'http://api.openweathermap.org/data/2.5/weather?id=1&APPID='
     arg = f'{http}{api_key}'
     assert mock_request.called_with(arg)
     self.assertTrue(w.wthr_data_dict)