示例#1
0
    def test_ImportComponentNoScheduling(self):

        component = Component.allFromString(DATA_NO_SCHEDULING)
        yield importCollectionComponent(self.store, component)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been set
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "Sample Import Calendar"),
            (customxml.CalendarColor, "#0E61B9FF"),
        ):
            self.assertEquals(
                value,
                collectionProperties[PropertyName.fromElement(element)]
            )

        # Verify child objects
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 2)

        yield txn.commit()

        # Reimport different component into same collection

        component = Component.allFromString(DATA_NO_SCHEDULING_REIMPORT)

        yield importCollectionComponent(self.store, component)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been changed
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "Sample Import Calendar Reimported"),
            (customxml.CalendarColor, "#FFFFFFFF"),
        ):
            self.assertEquals(
                value,
                collectionProperties[PropertyName.fromElement(element)]
            )

        # Verify child objects (should be 3 now)
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 3)

        yield txn.commit()
示例#2
0
    def test_ImportComponentNoScheduling(self):

        component = Component.allFromString(DATA_NO_SCHEDULING)
        yield importCollectionComponent(self.store, component)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been set
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "Sample Import Calendar"),
            (customxml.CalendarColor, "#0E61B9FF"),
        ):
            self.assertEquals(
                value, collectionProperties[PropertyName.fromElement(element)])

        # Verify child objects
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 2)

        yield txn.commit()

        # Reimport different component into same collection

        component = Component.allFromString(DATA_NO_SCHEDULING_REIMPORT)

        yield importCollectionComponent(self.store, component)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been changed
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "Sample Import Calendar Reimported"),
            (customxml.CalendarColor, "#FFFFFFFF"),
        ):
            self.assertEquals(
                value, collectionProperties[PropertyName.fromElement(element)])

        # Verify child objects (should be 3 now)
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 3)

        yield txn.commit()
示例#3
0
    def test_ImportComponentMissingSource(self):

        component = Component.allFromString(DATA_MISSING_SOURCE)
        try:
            yield importCollectionComponent(self.store, component)
        except ImportException:
            pass
        else:
            self.fail("Did not raise ImportException")
示例#4
0
    def test_ImportComponentMissingSource(self):

        component = Component.allFromString(DATA_MISSING_SOURCE)
        try:
            yield importCollectionComponent(self.store, component)
        except ImportException:
            pass
        else:
            self.fail("Did not raise ImportException")
示例#5
0
    def test_ImportComponentOrganizer(self):

        component = Component.allFromString(DATA_WITH_ORGANIZER)
        yield importCollectionComponent(self.store, component)

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been set
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "I'm the organizer"),
            (customxml.CalendarColor, "#0000FFFF"),
        ):
            self.assertEquals(
                value,
                collectionProperties[PropertyName.fromElement(element)]
            )

        # Verify the organizer's child objects
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        # Verify the attendees' child objects
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        home = yield txn.calendarHomeWithUID("user03")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        home = yield txn.calendarHomeWithUID("mercury")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        yield txn.commit()
示例#6
0
    def test_ImportComponentOrganizer(self):

        component = Component.allFromString(DATA_WITH_ORGANIZER)
        yield importCollectionComponent(self.store, component)

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")

        # Verify properties have been set
        collectionProperties = collection.properties()
        for element, value in (
            (davxml.DisplayName, "I'm the organizer"),
            (customxml.CalendarColor, "#0000FFFF"),
        ):
            self.assertEquals(
                value, collectionProperties[PropertyName.fromElement(element)])

        # Verify the organizer's child objects
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        # Verify the attendees' child objects
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        home = yield txn.calendarHomeWithUID("user03")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        home = yield txn.calendarHomeWithUID("mercury")
        collection = yield home.childWithName("calendar")
        objects = yield collection.listObjectResources()
        self.assertEquals(len(objects), 1)

        yield txn.commit()
示例#7
0
    def test_ImportComponentAttendee(self):

        # Have user02 invite this user01
        yield storeComponentInHomeAndCalendar(
            self.store,
            Component.allFromString(DATA_USER02_INVITES_USER01_ORGANIZER_COPY),
            "user02", "calendar", "invite.ics")

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Delete the attendee's copy, thus declining the event
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        yield objects[0].remove()
        yield txn.commit()
        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Make sure attendee's copy is gone
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 0)
        yield txn.commit()

        # Make sure attendee shows as declined to the organizer
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        prop = component.getAttendeeProperty(("urn:x-uid:user01", ))
        self.assertEquals(prop.parameterValue("PARTSTAT"), "DECLINED")
        yield txn.commit()

        # When importing the event again, update through the organizer's copy
        # of the event as if it were an iTIP reply
        component = Component.allFromString(
            DATA_USER02_INVITES_USER01_ATTENDEE_COPY)
        yield importCollectionComponent(self.store, component)

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Make sure organizer now sees the right partstats
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        # print(str(component))
        props = component.getAttendeeProperties(("urn:x-uid:user01", ))
        # The master is ACCEPTED
        self.assertEquals(props[0].parameterValue("PARTSTAT"), "ACCEPTED")
        # 2nd instance is TENTATIVE
        self.assertEquals(props[1].parameterValue("PARTSTAT"), "TENTATIVE")
        # 3rd instance is not in the attendee's copy, so remains DECLILNED
        self.assertEquals(props[2].parameterValue("PARTSTAT"), "DECLINED")
        yield txn.commit()

        # Make sure attendee now sees the right partstats
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        # print(str(component))
        props = component.getAttendeeProperties(("urn:x-uid:user01", ))
        # The master is ACCEPTED
        self.assertEquals(props[0].parameterValue("PARTSTAT"), "ACCEPTED")
        # 2nd instance is TENTATIVE
        self.assertEquals(props[1].parameterValue("PARTSTAT"), "TENTATIVE")
        # 3rd instance is not in the organizer's copy, so should inherit
        # the value from the master, which is ACCEPTED
        self.assertEquals(props[2].parameterValue("PARTSTAT"), "ACCEPTED")
        yield txn.commit()
示例#8
0
    def test_ImportComponentAttendee(self):

        # Have user02 invite this user01
        yield storeComponentInHomeAndCalendar(
            self.store,
            Component.allFromString(DATA_USER02_INVITES_USER01_ORGANIZER_COPY),
            "user02",
            "calendar",
            "invite.ics"
        )

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Delete the attendee's copy, thus declining the event
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        yield objects[0].remove()
        yield txn.commit()
        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Make sure attendee's copy is gone
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 0)
        yield txn.commit()

        # Make sure attendee shows as declined to the organizer
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        prop = component.getAttendeeProperty(("urn:x-uid:user01",))
        self.assertEquals(
            prop.parameterValue("PARTSTAT"),
            "DECLINED"
        )
        yield txn.commit()

        # When importing the event again, update through the organizer's copy
        # of the event as if it were an iTIP reply
        component = Component.allFromString(DATA_USER02_INVITES_USER01_ATTENDEE_COPY)
        yield importCollectionComponent(self.store, component)

        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)

        # Make sure organizer now sees the right partstats
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user02")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        # print(str(component))
        props = component.getAttendeeProperties(("urn:x-uid:user01",))
        # The master is ACCEPTED
        self.assertEquals(
            props[0].parameterValue("PARTSTAT"),
            "ACCEPTED"
        )
        # 2nd instance is TENTATIVE
        self.assertEquals(
            props[1].parameterValue("PARTSTAT"),
            "TENTATIVE"
        )
        # 3rd instance is not in the attendee's copy, so remains DECLILNED
        self.assertEquals(
            props[2].parameterValue("PARTSTAT"),
            "DECLINED"
        )
        yield txn.commit()

        # Make sure attendee now sees the right partstats
        txn = self.store.newTransaction()
        home = yield txn.calendarHomeWithUID("user01")
        collection = yield home.childWithName("calendar")
        objects = yield collection.objectResources()
        self.assertEquals(len(objects), 1)
        component = yield objects[0].component()
        # print(str(component))
        props = component.getAttendeeProperties(("urn:x-uid:user01",))
        # The master is ACCEPTED
        self.assertEquals(
            props[0].parameterValue("PARTSTAT"),
            "ACCEPTED"
        )
        # 2nd instance is TENTATIVE
        self.assertEquals(
            props[1].parameterValue("PARTSTAT"),
            "TENTATIVE"
        )
        # 3rd instance is not in the organizer's copy, so should inherit
        # the value from the master, which is ACCEPTED
        self.assertEquals(
            props[2].parameterValue("PARTSTAT"),
            "ACCEPTED"
        )
        yield txn.commit()