Example #1
0
 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))
Example #2
0
 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))
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 = timeformatutils.to_UNIXtime(timeobject)
        closest_weather = weatherutils.find_closest_weather(
            self._forecast.get_weathers(), time_value)
        return weatherutils.status_is(closest_weather, weather_condition,
                                      weather_code_registry)
Example #4
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 = timeformatutils.to_UNIXtime(timeobject)
        closest_weather = weatherutils.find_closest_weather(
                                        self._forecast.get_weathers(),
                                        time_value)
        return weatherutils.status_is(closest_weather, weather_condition,
                                      weather_code_registry)
Example #5
0
 def test_find_closest_weather_with_empty_list(self):
     self.assertFalse(
         weatherutils.find_closest_weather([], self.__test_time_low + 200))
Example #6
0
 def test_find_closest_weather_with_empty_list(self):
     self.assertFalse(weatherutils.find_closest_weather([],
                                                        self.__test_time_low + 200))