def test_okAttachRecurring(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] RRULE:FREQ=YEARLY END:VEVENT BEGIN:VEVENT UID:12345-67890 RECURRENCE-ID:20081114T000000Z DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] ATTACH;VALUE=URI:http://example.com/calendars/__uids__/1234/dropbox/12345-67890Y.dropbox/text.txt END:VEVENT END:VCALENDAR """) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "12345-67890Y.dropbox" )
def test_UIDbadPath(self): test_UIDs = ( ("12345/67890", "12345-67890"), ("http://12345,67890", "12345,67890"), ("https://12345,67890", "12345,67890"), ("12345:67890", "1234567890"), ("12345.67890", "1234567890"), ("12345/6:7.890", "12345-67890"), ) for uid, result in test_UIDs: resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:%s DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] END:VEVENT END:VCALENDAR """ % (uid, )) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "%s.dropbox" % (result, ), )
def test_UIDbadPath(self): test_UIDs = ( ("12345/67890", "12345-67890"), ("http://12345,67890", "12345,67890"), ("https://12345,67890", "12345,67890"), ("12345:67890", "1234567890"), ("12345.67890", "1234567890"), ("12345/6:7.890", "12345-67890"), ) for uid, result in test_UIDs: resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:%s DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] END:VEVENT END:VCALENDAR """ % (uid,)) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "%s.dropbox" % (result,), )
def test_noAttachOrXdash(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] END:VEVENT END:VCALENDAR """) self.assertEquals((yield dropboxIDFromCalendarObject(resource)), "12345-67890.dropbox")
def test_emptyXdash(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] X-APPLE-DROPBOX: END:VEVENT END:VCALENDAR """) self.assertEquals((yield dropboxIDFromCalendarObject(resource)), "12345-67890.dropbox")
def test_okXdash(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] X-APPLE-DROPBOX:http://example.com/calendars/__uids__/1234/dropbox/12345-67890X.dropbox END:VEVENT END:VCALENDAR """) self.assertEquals((yield dropboxIDFromCalendarObject(resource)), "12345-67890X.dropbox")
def test_multipleAttach(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] ATTACH;VALUE=URI:tag:bogus ATTACH:bmFzZTY0 ATTACH;VALUE=URI:http://example.com/calendars/__uids__/1234/dropbox/12345-67890Z.dropbox/text.txt END:VEVENT END:VCALENDAR """) self.assertEquals((yield dropboxIDFromCalendarObject(resource)), "12345-67890Z.dropbox")
def test_inlineAttach(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] ATTACH:bmFzZTY0 END:VEVENT END:VCALENDAR """) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "12345-67890.dropbox" )
def test_multipleAttach(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] ATTACH;VALUE=URI:tag:bogus ATTACH:bmFzZTY0 ATTACH;VALUE=URI:http://example.com/calendars/__uids__/1234/dropbox/12345-67890Z.dropbox/text.txt END:VEVENT END:VCALENDAR """) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "12345-67890Z.dropbox" )
def test_okAttachAlarm(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] BEGIN:VALARM ACTION:AUDIO ATTACH;VALUE=URI:Ping TRIGGER:-PT15M X-WR-ALARMUID:5548D654-8FDA-49DB-8983-8FCAD1F322B1 END:VALARM END:VEVENT END:VCALENDAR """) self.assertEquals((yield dropboxIDFromCalendarObject(resource)), "12345-67890.dropbox")
def test_okAttachAlarm(self): resource = DropboxIDTests.FakeCalendarResource("""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT UID:12345-67890 DTSTART:20071114T000000Z ATTENDEE:mailto:[email protected] ATTENDEE:mailto:[email protected] BEGIN:VALARM ACTION:AUDIO ATTACH;VALUE=URI:Ping TRIGGER:-PT15M X-WR-ALARMUID:5548D654-8FDA-49DB-8983-8FCAD1F322B1 END:VALARM END:VEVENT END:VCALENDAR """) self.assertEquals( (yield dropboxIDFromCalendarObject(resource)), "12345-67890.dropbox" )
def dropboxID(self): return dropboxIDFromCalendarObject(self)
def dropboxID(self): # NB: Deferred return dropboxIDFromCalendarObject(self)