Exemplo n.º 1
0
    def RoundTripNonCollection(self):

        # Export
        repo = self.repos[0]
        theItem = ContentItem(view=repo.view)
        theItem.displayName = "I'm an item"

        conduit = Sharing.FileSystemConduit(sharePath=".",
                                            shareName="exporteditem",
                                            view=repo.view)
        format = Sharing.CloudXMLFormat(view=repo.view)
        self.share3 = Sharing.Share(contents=theItem, conduit=conduit,
                                    format=format, view=repo.view)
        if self.share3.exists():
            self.share3.destroy()
        self.share3.create()
        self.share3.put()

        # Import
        repo = self.repos[1]

        conduit = Sharing.FileSystemConduit(sharePath=".",
                                            shareName="exporteditem",
                                            view=repo.view)
        format = Sharing.CloudXMLFormat(view=repo.view)
        self.share4 = Sharing.Share(conduit=conduit, format=format,
                                    view=repo.view)
        self.share4.get()

        alsoTheItem = self.share4.contents
        self.assert_(alsoTheItem.displayName == "I'm an item",
                     "Single-item import/export failed")
Exemplo n.º 2
0
    def RoundTrip(self):

        # Export
        repo = self.repos[0]
        sandbox = repo.findPath("//sandbox")
        coll = sandbox.findPath("testcollection")

        conduit = Sharing.FileSystemConduit(name="conduit", parent=sandbox,
         sharePath=".", shareName="exportedcollection", view=repo.view)
        format = Sharing.CloudXMLFormat(name="format", parent=sandbox,
                                        view=repo.view)
        self.share1 = Sharing.Share(name="share", parent=sandbox,
                                    contents=coll, conduit=conduit,
                                    format=format, view=repo.view)
        if self.share1.exists():
            self.share1.destroy()
        self.share1.create()
        self.share1.put()

        # Import
        repo = self.repos[1]
        sandbox = repo.findPath("//sandbox")
        coll = sandbox.findPath("testcollection")

        conduit = Sharing.FileSystemConduit(name="conduit", parent=sandbox,
         sharePath=".", shareName="exportedcollection", view=repo.view)
        format = Sharing.CloudXMLFormat(name="format", parent=sandbox,
                                        view=repo.view)
        self.share2 = Sharing.Share(name="share", parent=sandbox,
                                    conduit=conduit, format=format,
                                    view=repo.view)
        self.share2.get()

        # Make sure that the items we imported have the same displayNames
        # as the ones we exported (and no fewer, no more)
        names = {}
        for item in self.share1.contents:
            names[item.displayName] = 1
        for item in self.share2.contents:
            self.assert_(item.displayName in names, "Imported item that wasn't"
             "exported")
            del names[item.displayName]
        self.assert_(len(names) == 0, "Import is missing some items that were"
         "exported")
Exemplo n.º 3
0
    def Import(self, view, filename):

        path = os.path.join(os.getenv('CHANDLERHOME') or '.',
                            'parcels', 'osaf', 'sharing', 'tests')

        sandbox = self.repo.findPath("//sandbox")

        conduit = Sharing.FileSystemConduit(parent=sandbox, sharePath=path,
                                            shareName=filename, view=view)
        format = ICalendar.ICalendarFormat(parent=sandbox)
        self.share = Sharing.Share(parent=sandbox, conduit=conduit,
                                   format=format)
        self.share.get()
        return format
Exemplo n.º 4
0
    def testImport(self):
        if os.environ.get('CHANDLER_PERFORMANCE_TEST'):
            self.loadParcel("parcel:osaf.pim.calendar")
            path = os.path.join(os.getenv('CHANDLERHOME') or '.',
                                'parcels', 'osaf', 'sharing', 'tests')

            conduit = Sharing.FileSystemConduit(name="conduit",
                                                sharePath=path,
                                                shareName="3kevents.ics",
                                                view=self.rep.view)
            format = ICalendar.ICalendarFormat(name="format", view=self.rep.view)
            share = Sharing.Share(name="share", conduit=conduit, format=format,
                                  view=self.rep.view)
            share.get()
Exemplo n.º 5
0
    def writeICalendarUnicodeBug3338(self):
        event = Calendar.CalendarEvent(view = self.repo.view)
        event.displayName = u"unicode \u0633\u0644\u0627\u0645"
        event.startTime = datetime.datetime(2010, 1, 1, 10)
        event.endTime = datetime.datetime(2010, 1, 1, 11)

        coll = ItemCollection(name="testcollection", 
                                             parent=self.sandbox)
        coll.add(event)
        filename = "unicode_export.ics"

        conduit = Sharing.FileSystemConduit(name="conduit", sharePath=".",
                            shareName=filename, view=self.repo.view)
        format = ICalendar.ICalendarFormat(name="format", view=self.repo.view)
        self.share = Sharing.Share(name="share",contents=coll, conduit=conduit,
                                    format=format, view=self.repo.view)
        if self.share.exists():
            self.share.destroy()
        self.share.create()
        self.share.put()
        cal=vobject.readComponents(file(filename, 'rb')).next()
        self.assertEqual(cal.vevent[0].summary[0].value, event.displayName)
        self.share.destroy()