def test_status_is(self):
     self.assertTrue(
         weather.status_is(self.__test_weather_rain, "rain",
                           self.__test_registry))
     self.assertFalse(
         weather.status_is(self.__test_weather_sun, "rain",
                           self.__test_registry))
    def test_filter_by_status(self):
        result_1 = weather.filter_by_status(self.__test_weathers, "rain",
                                            self.__test_registry)
        self.assertEqual(1, len(result_1))
        self.assertTrue(
            weather.status_is(result_1[0], "rain", self.__test_registry))

        result_2 = weather.filter_by_status(self.__test_weathers, "sun",
                                            self.__test_registry)
        self.assertEqual(1, len(result_2))
        self.assertTrue(
            weather.status_is(result_2[0], "sun", self.__test_registry))
Example #3
0
    def _will_be(self, timeobject, weather_condition):
        """
        Tells if at the specified weather condition will occur at the specified
        time. The check is performed on the *Weather* item of the forecast
        which is closest to the time value conveyed by the parameter

        :param timeobject: may be a UNIX time, a ``datetime.datetime`` object
            or an ISO8601-formatted string in the format
            ``YYYY-MM-DD HH:MM:SS+00``
        :type timeobject: long/int, ``datetime.datetime`` or str)
        :param weather_condition: the weather condition to be looked up
        :type weather_condition: str
        :returns: boolean

        """
        time_value = formatting.to_UNIXtime(timeobject)
        closest_weather = weather.find_closest_weather(self.forecast.weathers,
                                                       time_value)
        return weather.status_is(closest_weather, weather_condition,
                                 self._wc_registry)