コード例 #1
0
    def _resourceTypeUpgrade_setup(self):

        # Set dead property on calendar
        for user in (
                "user01",
                "user02",
        ):
            calendar = (yield self.calendarUnderTest(name="calendar_1",
                                                     home=user))
            calendar.properties()[PropertyName.fromElement(
                element.ResourceType)] = element.ResourceType(
                    element.Collection())
        yield self.commit()

        for user in (
                "user01",
                "user02",
        ):
            calendar = (yield self.calendarUnderTest(name="calendar_1",
                                                     home=user))
            self.assertTrue(
                PropertyName.fromElement(element.ResourceType) in
                calendar.properties())

        yield self.transactionUnderTest().updateCalendarserverValue(
            "CALENDAR-DATAVERSION", "3")

        yield self.commit()
コード例 #2
0
ファイル: extensions.py プロジェクト: advatar/CalendarServer
 def resourceType(self):
     # Allow live property to be overridden by dead property
     if self.deadProperties().contains((dav_namespace, "resourcetype")):
         return self.deadProperties().get((dav_namespace, "resourcetype"))
     if self.isCollection():
         return element.ResourceType(element.Principal(), element.Collection())
     else:
         return element.ResourceType(element.Principal())
コード例 #3
0
    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()