def test_find_closest_weather(self):
     self.assertEqual(self.__test_weather_rain,
                      weatherutils.find_closest_weather(self.__test_weathers,
                                                self.__test_time_low + 200))
     self.assertEqual(self.__test_weather_sun,
                      weatherutils.find_closest_weather(self.__test_weathers,
                                                self.__test_time_high - 200))
示例#2
0
    def will_be_foggy_at(self, timeobject):
        """
        Tells if at the specified time the condition is fog. 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)
        :returns: boolean

        """
        time = timeformatutils.to_UNIXtime(timeobject)
        closest_weather = weatherutils.find_closest_weather(
                                        self._forecast.get_weathers(), time)
        return weatherutils.status_is(closest_weather, "fog",
                                      weather_code_registry)
示例#3
0
    def will_be_foggy_at(self, timeobject):
        """
        Tells if at the specified time the condition is fog. 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)
        :returns: boolean

        """
        time = timeformatutils.to_UNIXtime(timeobject)
        closest_weather = weatherutils.find_closest_weather(
            self._forecast.get_weathers(), time)
        return weatherutils.status_is(closest_weather, "fog",
                                      weather_code_registry)
 def test_find_closest_weather_with_empty_list(self):
     self.assertFalse(weatherutils.find_closest_weather([],
                                                self.__test_time_low + 200))