def test_filter_by_status(self):
     result_1 = weatherutils.filter_by_status(self.__test_weathers,
                                              "rain",
                                              self.__test_registry)
     self.assertEqual(1, len(result_1))
     self.assertTrue(weatherutils.status_is(result_1[0], "rain",
                                            self.__test_registry))
     
     result_2 = weatherutils.filter_by_status(self.__test_weathers,
                                              "sun",
                                              self.__test_registry)
     self.assertEqual(1, len(result_2))
     self.assertTrue(weatherutils.status_is(result_2[0], "sun",
                                            self.__test_registry))
Ejemplo n.º 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)
Ejemplo n.º 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_status_is(self):
     self.assertTrue(weatherutils.status_is(self.__test_weather_rain,
                                            "rain", self.__test_registry))
     self.assertFalse(weatherutils.status_is(self.__test_weather_sun,
                                            "rain", self.__test_registry))