Improve test for creation of whole calendar

This commit is contained in:
Unrud 2017-07-01 00:11:13 +02:00
parent cc888ebe9e
commit 70043c07b9
2 changed files with 49 additions and 10 deletions

View File

@ -0,0 +1,34 @@
BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Paris
X-LIC-LOCATION:Europe/Paris
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:event
SUMMARY:Event
DTSTART;TZID=Europe/Paris:20130901T190000
DTEND;TZID=Europe/Paris:20130901T200000
END:VEVENT
BEGIN:VTODO
UID:todo
DTSTART;TZID=Europe/Paris:20130901T220000
DURATION:PT1H
SUMMARY:Todo
END:VTODO
END:VCALENDAR

View File

@ -160,20 +160,25 @@ class BaseRequestsMixIn:
assert "DTSTART;TZID=Europe/Paris:20140901T180000" in answer assert "DTSTART;TZID=Europe/Paris:20140901T180000" in answer
assert "DTEND;TZID=Europe/Paris:20140901T210000" in answer assert "DTEND;TZID=Europe/Paris:20140901T210000" in answer
def test_put_whole_collection(self): def test_put_whole_calendar(self):
"""Create and overwrite a whole collection.""" """Create and overwrite a whole calendar."""
event = get_file_content("event1.ics") status, _, _ = self.request(
status, headers, answer = self.request("PUT", "/calendar.ics/", event) "PUT", "/calendar.ics/", "BEGIN:VCALENDAR\r\nEND:VCALENDAR")
event1 = get_file_content("event1.ics")
assert status == 201 assert status == 201
status, headers, answer = self.request( status, _, _ = self.request(
"PUT", "/calendar.ics/test_event.ics", event) "PUT", "/calendar.ics/test_event.ics", event1)
assert status == 201 assert status == 201
# Overwrite # Overwrite
status, headers, answer = self.request("PUT", "/calendar.ics/", event) events = get_file_content("event_multiple.ics")
status, _, _ = self.request("PUT", "/calendar.ics/", events)
assert status == 201 assert status == 201
status, headers, answer = self.request( status, _, _ = self.request("GET", "/calendar.ics/test_event.ics")
"GET", "/calendar.ics/test_event.ics")
assert status == 404 assert status == 404
status, _, answer = self.request("GET", "/calendar.ics/")
assert status == 200
assert "\r\nUID:event\r\n" in answer and "\r\nUID:todo\r\n" in answer
assert "\r\nUID:event1\r\n" not in answer
def test_delete(self): def test_delete(self):
"""Delete an event.""" """Delete an event."""
@ -278,7 +283,7 @@ class BaseRequestsMixIn:
assert ":calendar-color>#BADA55</" in answer assert ":calendar-color>#BADA55</" in answer
assert "200 OK</status" in answer assert "200 OK</status" in answer
def test_multiple_events_with_same_uid(self): def test_put_whole_calendar_multiple_events_with_same_uid(self):
"""Add two events with the same UID.""" """Add two events with the same UID."""
self.request("MKCOL", "/calendar.ics/") self.request("MKCOL", "/calendar.ics/")
self.request("PUT", "/calendar.ics/", get_file_content("event2.ics")) self.request("PUT", "/calendar.ics/", get_file_content("event2.ics"))