コード例 #1
0
 def test_find_closest_weather(self):
     self.assertEqual(self.__test_weather_rain,
                      weather.find_closest_weather(self.__test_weathers,
                                                   self.__test_time_low + 200))
     self.assertEqual(self.__test_weather_sun,
                      weather.find_closest_weather(self.__test_weathers,
                                                   self.__test_time_high - 200))
コード例 #2
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)
コード例 #3
0
 def test_find_closest_weather_with_empty_list(self):
     self.assertFalse(weather.find_closest_weather([],
                                                   self.__test_time_low + 200))