Beispiel #1
0
    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)
Beispiel #2
0
    def get_forecast3(self, bot, clientid, postcode, when):
        if logging.getLogger().isEnabledFor(logging.DEBUG):
            logging.debug(
                "Getting 3 hourly weather forecast for [%s] at time [%s]" %
                (postcode, when))

        googlemaps = GoogleMaps(bot.license_keys)
        latlng = googlemaps.get_latlong_for_location(postcode)

        met_office = MetOffice(bot.license_keys)

        forecast = met_office.three_hourly_forecast(latlng.latitude,
                                                    latlng.longitude)
        if forecast is not None:
            return forecast.get_latest().to_program_y_text()
        else:
            return None
Beispiel #3
0
    def test_threehourly_forecast(self):
        met_office = MetOffice(self.license_keys)
        self.assertIsNotNone(met_office)

        met_office.set_three_hourly_forecast_response_file(
            os.path.dirname(__file__) + "/forecast_3hourly.json")

        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(2017, 4, 3)
        report = forecast.get_report_for_date(date)
        self.assertIsNotNone(report)

        datapoint = report.get_time_period_by_time("540")
        self.assertIsNotNone(datapoint)
        self.assertIsInstance(datapoint, ThreeHourlyForecastDataPoint)