def test_immature_eto(self): station = pm.Station(41.42, 109) day = station.get_day(238) eto = day.eto() self.assertEqual(eto, None)
def test_altitude_range_error(self): try: station = pm.Station(latitude=41.42, altitude=-1) except: self.assertTrue(True, "Exception was expected and raised") else: self.assertTrue(False, "Exception was expected but NOT raised")
def test_type_error(self): try: station = pm.Station(latitude=10, altitude=109) except TypeError: self.assertTrue(True, "Exception was expected and raised") else: self.assertTrue(False, "Exception was expected but was NOT raised")
def test_day_number_type(self): station = pm.Station(latitude=41.42, altitude=109) try: day = station.get_day(365.0) except TypeError: self.assertTrue(True, "Exception was expected and raised") else: self.assertTrue(False, "Exception was expected but was NOT raised")
def test_bug(self): station = pm.Station(37.31, 263) day = station.get_day("1979-01-11") day.temp_min=1.247 day.temp_max=3.10 day.humidity_mean=85.34 day.wind_speed=2.13654 day.radiation_s=3.21356 self.assertTrue(day.net_radiation(), day.net_radiation()) self.assertTrue(day.eto(), day.eto())
def calculate_eto(col): try: day = pm.Station(col["latitude"], col["altitude"], anemometer_height=10).get_day( col["date"].strftime("%Y-%m-%d"), temp_min=round(col["temp_min"], 1), temp_max=round(col["temp_max"], 1), wind_speed=round(col["wind_speed"], 1), humidity_mean=round(col["humidity_mean"] * 100, 1), radiation_s=round(col["solar_radiation"], 1)) return day.eto() except: raise Exception("Exception raised while processing line:\n" + str(col))
class Test(unittest.TestCase): import penmon.eto as pm station = pm.Station(41.42, 109) def testName(self): #day_228 = self.station.get_day(228, temp_min=19.5, temp_max=25.6, humidity_mean=60, wind_speed=2.35) day_228 = self.station.get_day(228) day_228.temp_min = 19.5 day_228.temp_max = 25.6 day_228.humidity_mean = 60 day_228.wind_speed = 2.35 self.assertEqual(day_228.eto(), 3.94) def test_new_get_day(self): day_228_2 = self.station.get_day(228, temp_min=19.5, temp_max=25.6, humidity_mean=60, wind_speed=2.35) self.assertEqual(day_228_2.eto(), 3.94)
def test_smoke(self): station = pm.Station(latitude=41.42, altitude=109) self.assertIsInstance(station, pm.Station, "Smoke test passed")