How to use the pyowm.commons.http_client.HttpClient.cacheable_get_json function in pyowm

To help you get started, we’ve selected a few pyowm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_three_hours_forecast_when_forecast_not_found(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_empty_3h_forecast
        result = self.__test_instance.three_hours_forecast("London,uk")
        HttpClient.cacheable_get_json = original_func
        self.assertIsNone(result)
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_three_hours_forecast_at_id(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_3h_forecast_at_id
        result = self.__test_instance.three_hours_forecast_at_id(2643743)
        HttpClient.cacheable_get_json = original_func
        self.assertTrue(isinstance(result, Forecaster))
        forecast = result.get_forecast()
        self.assertTrue(isinstance(forecast, Forecast))
        self.assertTrue(forecast.get_interval() is not None)
        self.assertTrue(forecast.get_reception_time() is not None)
        self.assertTrue(isinstance(forecast.get_location(), Location))
        self.assertEqual(1, len(forecast))
        for weather in forecast:
            self.assertTrue(isinstance(weather, Weather))
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_three_hours_forecast_at_id(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_3h_forecast_at_id
        result = self.__test_instance.three_hours_forecast_at_id(2643743)
        HttpClient.cacheable_get_json = original_func
        self.assertTrue(isinstance(result, Forecaster))
        forecast = result.get_forecast()
        self.assertTrue(isinstance(forecast, Forecast))
        self.assertTrue(forecast.get_interval() is not None)
        self.assertTrue(forecast.get_reception_time() is not None)
        self.assertTrue(isinstance(forecast.get_location(), Location))
        self.assertEqual(1, len(forecast))
        for weather in forecast:
            self.assertTrue(isinstance(weather, Weather))
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_is_API_online_failure(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_failing_ping
        result = self.__test_instance.is_API_online()
        HttpClient.cacheable_get_json = original_func
        self.assertFalse(result)
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_weather_history_at_id(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_city_weather_history
        result = self.__test_instance.weather_history_at_id(12345)
        HttpClient.cacheable_get_json = original_func
        self.assertTrue(isinstance(result, list))
        for weather in result:
            self.assertTrue(isinstance(weather, Weather))
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_weather_history_at_coords(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_weather_history_at_coords
        result = self.__test_instance.weather_history_at_coords(51.503614, -0.107331)
        HttpClient.cacheable_get_json = original_func
        self.assertTrue(isinstance(result, list))
        for weather in result:
            self.assertTrue(isinstance(weather, Weather))
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_daily_forecast_when_forecast_not_found(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_empty_daily_forecast
        result = self.__test_instance.daily_forecast('London,uk')
        HttpClient.cacheable_get_json = original_func
        self.assertIsNone(result)
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_is_API_online(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_ping
        result = self.__test_instance.is_API_online()
        HttpClient.call_API = original_func
        self.assertTrue(result)
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_station_hour_history_when_forecast_not_found(self):
        original_call = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_call_api_returning_station_history_with_no_items
        result = self.__test_instance.station_hour_history(1234, limit=4)
        HttpClient.cacheable_get_json = original_call
        self.assertIsNone(result)
github csparpa / pyowm / tests / unit / webapi25 / test_owm25.py View on Github external
def test_daily_forecast_at_coords(self):
        original_func = HttpClient.cacheable_get_json
        HttpClient.cacheable_get_json = \
            self.mock_api_call_returning_daily_forecast_at_coords
        result = \
            self.__test_instance.daily_forecast_at_coords(51.50853, -0.12574, 2)
        HttpClient.cacheable_get_json = original_func
        self.assertTrue(isinstance(result, Forecaster))
        forecast = result.get_forecast()
        self.assertTrue(isinstance(forecast, Forecast))
        self.assertTrue(forecast.get_interval() is not None)
        self.assertTrue(forecast.get_reception_time() is not None)
        self.assertTrue(isinstance(forecast.get_location(), Location))
        self.assertEqual(1, len(forecast))
        for weather in forecast:
            self.assertTrue(isinstance(weather, Weather))