def testgetcityweatherbycoordinates(self): api = OpenWeatherMapApi() citylist = api.getcityweatherbycoordinates(self.latitude, self.longitude, 10) self.assertIsNotNone(citylist, '%s - city list must not be null') self.assertTrue( self.checklistlength(citylist, 1, 10), '%s - list length must be greater than 0 and less than equals 10') for city in citylist: self.logger.info(city) self.assertTrue(self.checkid(city.identifier), 'identifier must be an int greater than zero') self.assertTrue( self.checkname(city.name), 'city name must match regex [A-Za-z]+\s*[A-Za-z]*') self.assertTrue(self.checkclouds(city.getclouds()), 'city clouds must be greater equal 0') self.assertTrue( self.checkcoordinates(city.getcoordtuple()), 'latitude must be in range -90.0 to +90.0 and longitude must be in range -180.0 to +180.0' ) self.assertTrue( self.checktemperatures(city.getmaintemp(), city.getmaintempc(), city.getmaintempf()), 'temperature conversion between kelvin, degree celsius and degree fahrenheit is wrong' )
def testgetstationbycoordinates(self): api = OpenWeatherMapApi() stationlist = api.getstationbycoordinates(self.latitude, self.longitude, 10) self.assertIsNotNone(stationlist, 'station list must not be null') self.assertTrue(self.checklistlength(stationlist, 1, 10), 'list length must be greater than 0 and less than equals 10') for station in stationlist: self.logger.info(station) self.assertTrue(self.checkdatetime(station.dt), 'datetime isn\'t from the current day') self.assertEquals(station.gettypestring(), self.getstationstring(station.stationtype), 'station\'s string representation fails ') self.assertTrue(self.checkid(station.identifier), 'identifier must be a an int greater than zero ') self.assertTrue(self.checkcoordinates(station.getcoordtuple()), 'latitude must be in range -90.0 to +90.0 and longitude must be in range -180.0 to +180.0') self.assertTrue(self.checktemperatures(station.getmaintemp(), station.getmaintempc(), station.getmaintempf()), 'temperature conversion between kelvin, degree celsius and degree fahrenheit is wrong') self.assertTrue(self.checkpressure(station.getmainpressure()), 'pressure must be greather or equal to 0') self.assertTrue(self.checkhumidity(station.getmainhumidity()), 'humidity must be greather or equal to 0') self.assertTrue(self.checkwindspeed(station.getwindspeed(), station.getwindspeedkm()), 'conversion between windspeed in mps and kms fails') self.assertTrue(self.checkwindgust(station.getwindgust()), 'wind gust must be greather or equal to 0') self.assertTrue(self.checkcloudconditions(station.getcloudsconditions()), 'cloud condition has no valid value or value isn\'t valid')
class TestForecast(unittest.TestCase): def setUp(self): self.api = OpenWeatherMapApi() self.city_id = 6324533 def test_getdailyforecast(self): dfc = self.api.getdailyforecast(self.city_id) assert (dfc) assert (dfc.forecastlist) forecast = dfc.forecastlist[1] assert (forecast.datetime) def test_getcityweaterbyid(self): weather = self.api.getcityweaterbyid(self.city_id) assert (weather)
class TestForecast(unittest.TestCase): def setUp(self): self.api = OpenWeatherMapApi() self.city_id = 6324533 def test_getdailyforecast(self): dfc = self.api.getdailyforecast(self.city_id) assert(dfc) assert(dfc.forecastlist) forecast = dfc.forecastlist[1] assert(forecast.datetime) def test_getcityweaterbyid(self): weather = self.api.getcityweaterbyid(self.city_id) assert(weather)
def testgetcityweatherbycoordinates(self): api = OpenWeatherMapApi() citylist = api.getcityweatherbycoordinates(self.latitude, self.longitude, 10) self.assertIsNotNone(citylist, '%s - city list must not be null') self.assertTrue(self.checklistlength(citylist, 1, 10), '%s - list length must be greater than 0 and less than equals 10') for city in citylist: self.logger.info(city) self.assertTrue(self.checkid(city.identifier), 'identifier must be an int greater than zero') self.assertTrue(self.checkname(city.name), 'city name must match regex [A-Za-z]+\s*[A-Za-z]*') self.assertTrue(self.checkclouds(city.getclouds()), 'city clouds must be greater equal 0') self.assertTrue(self.checkcoordinates(city.getcoordtuple()), 'latitude must be in range -90.0 to +90.0 and longitude must be in range -180.0 to +180.0') self.assertTrue(self.checktemperatures(city.getmaintemp(), city.getmaintempc(), city.getmaintempf()), 'temperature conversion between kelvin, degree celsius and degree fahrenheit is wrong')
def testgetstationbycoordinates(self): api = OpenWeatherMapApi() stationlist = api.getstationbycoordinates(self.latitude, self.longitude, 10) self.assertIsNotNone(stationlist, 'station list must not be null') self.assertTrue( self.checklistlength(stationlist, 1, 10), 'list length must be greater than 0 and less than equals 10') for station in stationlist: self.logger.info(station) self.assertTrue(self.checkdatetime(station.dt), 'datetime isn\'t from the current day') self.assertEquals(station.gettypestring(), self.getstationstring(station.stationtype), 'station\'s string representation fails ') self.assertTrue(self.checkid(station.identifier), 'identifier must be a an int greater than zero ') self.assertTrue( self.checkcoordinates(station.getcoordtuple()), 'latitude must be in range -90.0 to +90.0 and longitude must be in range -180.0 to +180.0' ) self.assertTrue( self.checktemperatures(station.getmaintemp(), station.getmaintempc(), station.getmaintempf()), 'temperature conversion between kelvin, degree celsius and degree fahrenheit is wrong' ) self.assertTrue(self.checkpressure(station.getmainpressure()), 'pressure must be greather or equal to 0') self.assertTrue(self.checkhumidity(station.getmainhumidity()), 'humidity must be greather or equal to 0') self.assertTrue( self.checkwindspeed(station.getwindspeed(), station.getwindspeedkm()), 'conversion between windspeed in mps and kms fails') self.assertTrue(self.checkwindgust(station.getwindgust()), 'wind gust must be greather or equal to 0') self.assertTrue( self.checkcloudconditions(station.getcloudsconditions()), 'cloud condition has no valid value or value isn\'t valid')
def setUp(self): self.api = OpenWeatherMapApi() self.city_id = 6324533