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
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
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", }
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", }
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", }
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", }
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", }