Example #1
0
    def test_filter_on_specific_date(self):
        sun_weather = Weather(70, 40, "Sunny")
        rain_weather = Weather(70, 40, "Rain")

        forecast = Forecast(Coordinates(127.13, 23.53))
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        forecast.daily_weather[today.isoformat()] = rain_weather
        forecast.daily_weather[tomorrow.isoformat()] = sun_weather

        filtered_forecasts = filters.filter_by_sun_on_date([forecast], today)
        assert forecast not in filtered_forecasts
Example #2
0
    def test_filter_with_partly_sunny(self):
        sun_weather = Weather(70, 40, "Partly Sunny")
        cloud_weather = Weather(70, 40, "Mostly Cloudy")

        forecast = Forecast(Coordinates(127.13, 23.53))
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        forecast.daily_weather[today.isoformat()] = cloud_weather
        forecast.daily_weather[tomorrow.isoformat()] = sun_weather

        filtered_forecasts = filters.filter_by_sun_on_date([forecast], today)
        assert forecast in filtered_forecasts
        assert_equals (forecast.daily_weather[tomorrow.isoformat()].condition, "Partly Sunny")