import icalendar.cal import pytest import ics2vdir @pytest.mark.parametrize( ("event_a_ical", "event_b_ical", "expected_result"), ( [ ( """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z DESCRIPTION: LAST-MODIFIED:20191231T103841Z LOCATION: STATUS:CONFIRMED TRANSP:OPAQUE END:VEVENT """, """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z DESCRIPTION: LAST-MODIFIED:20191231T103841Z LOCATION: STATUS:CONFIRMED TRANSP:OPAQUE END:VEVENT """, True, ), ( """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z DESCRIPTION: LAST-MODIFIED:20191231T103841Z LOCATION: STATUS:CONFIRMED TRANSP:OPAQUE END:VEVENT """, """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z DESCRIPTION: LAST-MODIFIED:20191231T103841Z STATUS:CONFIRMED TRANSP:OPAQUE END:VEVENT """, False, ), ( """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z LAST-MODIFIED:20191231T103841Z END:VEVENT """, """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:1 CREATED:20191231T103841Z LAST-MODIFIED:20191231T103841Z END:VEVENT """, False, ), ( """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T160640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z LAST-MODIFIED:20191231T103841Z END:VEVENT """, # ignoring DTSTAMP """BEGIN:VEVENT SUMMARY:party DTSTART:20201024T100000Z DTEND:20201026T120000Z DTSTAMP:20200205T200640Z UID:123456789@google.com SEQUENCE:0 CREATED:20191231T103841Z LAST-MODIFIED:20191231T103841Z END:VEVENT """, True, ), ] ), ) def test__events_equal(event_a_ical, event_b_ical, expected_result): event_a = icalendar.cal.Event.from_ical(event_a_ical) event_b = icalendar.cal.Event.from_ical(event_b_ical) # pylint: disable=protected-access assert ics2vdir._events_equal(event_a, event_b) == expected_result