refactor test_issue_168

pull/413/head
jaca 2022-09-09 15:59:10 +02:00
rodzic 6e78ab6a3b
commit 7723670e09
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B67CEF4EE3D609B0
5 zmienionych plików z 30 dodań i 23 usunięć

Wyświetl plik

@ -0,0 +1,7 @@
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20150905T090000Z
DTEND:20150905T100000Z
UID:123
END:VEVENT
END:VCALENDAR

Wyświetl plik

@ -0,0 +1,8 @@
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20150905T090000Z
DTEND:20150905T100000Z
UID:123
X-APPLE-RADIUS=49.91307046514149
END:VEVENT
END:VCALENDAR

Wyświetl plik

@ -32,6 +32,7 @@ class DataSource:
HERE = os.path.dirname(__file__)
TIMEZONES_FOLDER = os.path.join(HERE, 'timezones')
EVENTS_FOLDER = os.path.join(HERE, 'events')
CALENDARS_FOLDER = os.path.join(HERE, 'calendars')
@pytest.fixture
def timezones():
@ -41,3 +42,7 @@ def timezones():
def events():
return DataSource(EVENTS_FOLDER, icalendar.Event.from_ical)
@pytest.fixture
def calendars():
return DataSource(CALENDARS_FOLDER, icalendar.Calendar.from_ical)

Wyświetl plik

@ -344,29 +344,6 @@ END:VEVENT"""
b'FREQ=YEARLY;BYDAY=1SU;BYMONTH=11'
)
def test_issue_168(self):
"""Issue #168 - Parsing invalid icalendars fails without any warning
https://github.com/collective/icalendar/issues/168
"""
event_str = """
BEGIN:VCALENDAR
BEGIN:VEVENT
DTEND:20150905T100000Z
DTSTART:20150905T090000Z
X-APPLE-RADIUS=49.91307046514149
UID:123
END:VEVENT
END:VCALENDAR"""
calendar = icalendar.Calendar.from_ical(event_str)
self.assertEqual(
calendar.to_ical(),
b'BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20150905T090000Z\r\n'
b'DTEND:20150905T100000Z\r\nUID:123\r\n'
b'END:VEVENT\r\nEND:VCALENDAR\r\n'
)
def test_index_error_issue(self):
"""Found an issue where from_ical() would raise IndexError for
properties without parent components.

Wyświetl plik

@ -0,0 +1,10 @@
'''Issue #168 - Parsing invalid icalendars fails without any warning
https://github.com/collective/icalendar/issues/168
'''
from icalendar import Calendar
def test_issue_168_parsing_inavlid_calendars_no_warning(calendars):
expected_error = (None, "Content line could not be parsed into parts: 'X-APPLE-RADIUS=49.91307046514149': X-APPLE-RADIUS=49.91307046514149")
assert expected_error in calendars.issue_168_input.walk('VEVENT')[0].errors
assert calendars.issue_168_input.to_ical() == calendars.issue_168_expected_output.raw_ics