Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
 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))
Exemplo n.º 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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
 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))