def test_observation(self): met_office = MetOffice(self.license_keys) self.assertIsNotNone(met_office) observation = met_office.current_observation(self.lat, self.lng) self.assertIsNotNone(observation) report = observation.get_latest_report() self.assertIsNotNone(report) date = DateFormatter.year_month_day_now() report = observation.get_report_for_date(date) self.assertIsNotNone(report) datapoint = report.get_time_period_by_time("300") self.assertIsNotNone(datapoint) self.assertIsInstance(datapoint, ObservationDataPoint)
def test_threehourly_forecast(self): met_office = MetOffice(self.license_keys) self.assertIsNotNone(met_office) forecast = met_office.three_hourly_forecast(self.lat, self.lng) self.assertIsNotNone(forecast) report = forecast.get_latest_report() self.assertIsNotNone(report) date = DateFormatter.year_month_day_now() report = forecast.get_report_for_date(date) self.assertIsNotNone(report) datapoint = report.get_time_period_by_time("900") self.assertIsNotNone(datapoint) self.assertIsInstance(datapoint, ThreeHourlyForecastDataPoint)
def test_daily_forecast(self): met_office = MetOffice(self.license_keys) self.assertIsNotNone(met_office) forecast = met_office.daily_forecast(self.lat, self.lng) self.assertIsNotNone(forecast) report = forecast.get_latest_report() self.assertIsNotNone(report) date = DateFormatter.year_month_day_now() report = forecast.get_report_for_date(date) self.assertIsNotNone(report) day_datapoint = report.get_time_period_by_type('Day') self.assertIsNotNone(day_datapoint) self.assertIsInstance(day_datapoint, DailyForecastDayDataPoint) night_datapoint = report.get_time_period_by_type('Night') self.assertIsNotNone(night_datapoint) self.assertIsInstance(night_datapoint, DailyForecastNightDataPoint)
def test_year_month_day_now(self): result = DateFormatter.year_month_day_now() self.assertIsNotNone(result) now = datetime.datetime.now() self.assertEqual(datetime.datetime(now.year, now.month, now.day, 0, 0), result)