コード例 #1
0
    def test_no_result_with_filtering(self, mock_now):
        """Test that nothing is returned since nothing matches."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar, False,
                                               "This is a non-existing event")

        assert cal.data.event is None
コード例 #2
0
    def test_filter_matching_past_event(self, mock_now):
        """Test that the matching past event is not returned."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar, False,
                                               "This is a normal event")

        assert cal.data.event is None
コード例 #3
0
    def test_ongoing_event_with_offset(self, mock_now):
        """Test that the offset is taken into account."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar)

        assert cal.state == STATE_OFF
        assert cal.device_state_attributes == {
            "message": "This is an offset event",
            "all_day": False,
            "offset_reached": True,
            "start_time": "2017-11-27 10:00:00",
            "end_time": "2017-11-27 11:00:00",
            "location": "Hamburg",
            "description": "Surprisingly shiny",
        }
コード例 #4
0
    def test_all_day_event_returned(self, mock_now):
        """Test that the event lasting the whole day is returned."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar, True)

        assert cal.name == DEVICE_DATA["name"]
        assert cal.state == STATE_ON
        assert cal.device_state_attributes == {
            "message": "This is an all day event",
            "all_day": True,
            "offset_reached": False,
            "start_time": "2017-11-27 00:00:00",
            "end_time": "2017-11-28 00:00:00",
            "location": "Hamburg",
            "description": "What a beautiful day",
        }
コード例 #5
0
    def test_ongoing_event_different_tz(self, mock_now):
        """Test that the ongoing event with another timezone is returned."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar)

        assert cal.name == DEVICE_DATA["name"]
        assert cal.state == STATE_ON
        assert cal.device_state_attributes == {
            "message": "Enjoy the sun",
            "all_day": False,
            "offset_reached": False,
            "start_time": "2017-11-27 16:30:00",
            "description": "Sunny day",
            "end_time": "2017-11-27 17:30:00",
            "location": "San Francisco",
        }
コード例 #6
0
    def test_just_ended_event(self, mock_now):
        """Test that the next ongoing event is returned."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar)

        assert cal.name == DEVICE_DATA["name"]
        assert cal.state == STATE_ON
        assert cal.device_state_attributes == {
            "message": "This is a normal event",
            "all_day": False,
            "offset_reached": False,
            "start_time": "2017-11-27 17:00:00",
            "end_time": "2017-11-27 18:00:00",
            "location": "Hamburg",
            "description": "Surprisingly rainy",
        }
コード例 #7
0
    def test_matching_filter_real_regexp(self, mock_now):
        """Test that the event matching the regexp is returned."""
        cal = caldav.WebDavCalendarEventDevice(self.hass, DEVICE_DATA,
                                               self.calendar, False,
                                               "^This.*event")

        assert cal.state == STATE_OFF
        assert not cal.offset_reached()
        assert cal.device_state_attributes == {
            "message": "This is a normal event",
            "all_day": False,
            "offset_reached": False,
            "start_time": "2017-11-27 17:00:00",
            "end_time": "2017-11-27 18:00:00",
            "location": "Hamburg",
            "description": "Surprisingly rainy",
        }