def test_apikey_getter(self): """ Should return the value of _apikey :return: """ expected_apikey = "12345" collector = TemperatureFromOpenWeatherDotCom(parent=None, parameters={}) collector._apikey = "12345" actual_apikey = collector.apikey self.assertEqual(expected_apikey, actual_apikey)
def test__collect_openweathermap_returns_invalid_json(self): """ Should log invalid state of json in "collected" data as string. :return: """ excpeted_data = \ "'https://api.openweathermap.org/data/2.5/weather?q=Munich,ger" \ "&units=Metric&&APPID=123456789abcdefghijkl1234567890a' " \ "returned invalid weather data." collector = TemperatureFromOpenWeatherDotCom(parameters={ 'countrycode': 'ger', 'apikey': '123456789abcdefghijkl1234567890a', 'city': 'Munich' }, parent=None) collector._apikey = '123456789abcdefghijkl1234567890a' collector._collect() self.assertEqual(excpeted_data, collector.data[0].collecteddata)
def test__get_query(self): """ Should return the initialized query string used to query the weather from openweather.com :return: """ expected_query = "https://api.openweathermap.org/data/2.5/weather?q=Munich,ger&units=Metric&&APPID=123456789abcdefghijkl1234567890a" collector = TemperatureFromOpenWeatherDotCom(parameters={ 'city': 'Munich', 'countrycode': 'ger', 'apikey': '123456789abcdefghijkl1234567890a' }, parent=None) collector._apikey = '123456789abcdefghijkl1234567890a' actual_query = collector._get_query() self.assertEqual(expected_query, actual_query)