def test_pick_default_other(self): """ Make calendar """ request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/") inbox = yield request.locateResource("/calendars/users/wsanchez/inbox") # default property present default = yield inbox.readProperty( caldavxml.ScheduleDefaultCalendarURL, request) self.assertEqual( str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar" ) # Create a new default calendar newcalendar = yield request.locateResource( "/calendars/users/wsanchez/newcalendar") yield newcalendar.createCalendarCollection() yield inbox.writeProperty( caldavxml.ScheduleDefaultCalendarURL( davxml.HRef( "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar" )), request) # Delete the normal calendar calendar = yield request.locateResource( "/calendars/users/wsanchez/calendar") yield calendar.storeRemove(request) yield self.commit() request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/") inbox = yield request.locateResource("/calendars/users/wsanchez/inbox") default = yield inbox.readProperty( caldavxml.ScheduleDefaultCalendarURL, request) self.assertEqual( str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar" ) yield self.abort()
def test_set_default_vevent_other(self): """ Test that the default URL can be set to another VEVENT calendar """ request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/") inbox = yield request.locateResource("/calendars/users/wsanchez/inbox") # default property is present default = yield inbox.readProperty( caldavxml.ScheduleDefaultCalendarURL, request) self.assertEqual( str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar" ) # Create a new default calendar newcalendar = yield request.locateResource( "/calendars/users/wsanchez/newcalendar") yield newcalendar.createCalendarCollection() yield newcalendar.setSupportedComponents(("VEVENT", )) yield self.commit() request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/") inbox = yield request.locateResource("/calendars/users/wsanchez/inbox") yield inbox.writeProperty( caldavxml.ScheduleDefaultCalendarURL( davxml.HRef( "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar" )), request) default = yield inbox.readProperty( caldavxml.ScheduleDefaultCalendarURL, request) self.assertEqual( str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar" ) yield self.commit()
def setUp(self): """ Set up two stores to migrate between. """ yield super(HomeMigrationTests, self).setUp() yield self.buildStoreAndDirectory(extraUids=( u"home1", u"home2", u"home3", u"home_defaults", u"home_no_splits", u"home_splits", u"home_splits_shared", )) self.sqlStore = self.store # Add some files to the file store. self.filesPath = CachingFilePath(self.mktemp()) self.filesPath.createDirectory() fileStore = self.fileStore = CommonDataStore( self.filesPath, {"push": StubNotifierFactory()}, self.directory, True, True) self.upgrader = UpgradeToDatabaseStep(self.fileStore, self.sqlStore) requirements = CommonTests.requirements extras = deriveValue(self, "extraRequirements", lambda t: {}) requirements = self.mergeRequirements(requirements, extras) yield populateCalendarsFrom(requirements, fileStore) md5s = CommonTests.md5s yield resetCalendarMD5s(md5s, fileStore) self.filesPath.child("calendars").child("__uids__").child("ho").child( "me").child("home1").child(".some-extra-data").setContent( "some extra data") requirements = ABCommonTests.requirements yield populateAddressBooksFrom(requirements, fileStore) md5s = ABCommonTests.md5s yield resetAddressBookMD5s(md5s, fileStore) self.filesPath.child("addressbooks").child("__uids__").child( "ho").child("me").child("home1").child( ".some-extra-data").setContent("some extra data") # Add some properties we want to check get migrated over txn = self.fileStore.newTransaction() home = yield txn.calendarHomeWithUID("home_defaults") cal = yield home.calendarWithName("calendar_1") props = cal.properties() props[PropertyName.fromElement( caldavxml.SupportedCalendarComponentSet )] = caldavxml.SupportedCalendarComponentSet( caldavxml.CalendarComponent(name="VEVENT"), caldavxml.CalendarComponent(name="VTODO"), ) props[PropertyName.fromElement( element.ResourceType)] = element.ResourceType( element.Collection(), caldavxml.Calendar(), ) props[PropertyName.fromElement( customxml.GETCTag)] = customxml.GETCTag.fromString("foobar") inbox = yield home.calendarWithName("inbox") props = inbox.properties() props[PropertyName.fromElement( customxml.CalendarAvailability )] = customxml.CalendarAvailability.fromString(str(self.av1)) props[PropertyName.fromElement( caldavxml.ScheduleDefaultCalendarURL )] = caldavxml.ScheduleDefaultCalendarURL( element.HRef.fromString( "/calendars/__uids__/home_defaults/calendar_1"), ) yield txn.commit()