예제 #1
0
    def getExportedTodoComponent(self, **todoParams):
        """
        Utility method to reparse the iCalendar content
        we've generated, so that we can check that it's
        what we expect.
        """
        create = todoParams.pop('create', pim.Task)
        new = create(itsView=self.view)
        new.InitOutgoingAttributes() # simulate creation in the Chandler UI
        
        item = getattr(new, 'itsItem', new)
        for attr, value in todoParams.iteritems():
            setattr(item, attr, value)
        
        iCalendarContent = serialize(self.view, [item],
                                     translator.SharingTranslator,
                                     ics.ICSSerializer)

        self.failUnlessEqual(type(iCalendarContent), str)
        # Could in general add a check for utf-8 decodability

        io = cStringIO.StringIO(iCalendarContent)

        components = list(vobject.readComponents(io, validate=True))
        self.failUnlessEqual(len(components), 1,
                            "exportProcess should create a single calendar")
        
        calendar = components[0]

        # We expect exactly one child component ...
        self.failUnlessEqual(len(list(calendar.components())), 1)
        
        vobj = list(calendar.components())[0]
        self.failUnlessEqual(item.itsUUID.str16(),
                             vobj.getChildValue('uid'))
        
        return (item, vobj)
예제 #2
0
    def getExportedTodoComponent(self, **todoParams):
        """
        Utility method to reparse the iCalendar content
        we've generated, so that we can check that it's
        what we expect.
        """
        create = todoParams.pop('create', pim.Task)
        new = create(itsView=self.view)
        new.InitOutgoingAttributes()  # simulate creation in the Chandler UI

        item = getattr(new, 'itsItem', new)
        for attr, value in todoParams.iteritems():
            setattr(item, attr, value)

        iCalendarContent = serialize(self.view, [item],
                                     translator.SharingTranslator,
                                     ics.ICSSerializer)

        self.failUnlessEqual(type(iCalendarContent), str)
        # Could in general add a check for utf-8 decodability

        io = cStringIO.StringIO(iCalendarContent)

        components = list(vobject.readComponents(io, validate=True))
        self.failUnlessEqual(len(components), 1,
                             "exportProcess should create a single calendar")

        calendar = components[0]

        # We expect exactly one child component ...
        self.failUnlessEqual(len(list(calendar.components())), 1)

        vobj = list(calendar.components())[0]
        self.failUnlessEqual(item.itsUUID.str16(), vobj.getChildValue('uid'))

        return (item, vobj)
예제 #3
0
def getVObjectData(view, events):
    text = serialize(view, events, translator.SharingTranslator,
                     ics.ICSSerializer)
    return vobject.readOne(text)
예제 #4
0
def getVObjectData(view, events):
    text = serialize(view, events, translator.SharingTranslator,
                     ics.ICSSerializer)
    return vobject.readOne(text)