예제 #1
0
    def RoundTrip(self):

        # Export
        view0 = self.views[0]
        sandbox0 = view0.findPath("//sandbox")
        coll0 = sandbox0.findPath("testCollection")
        account = sandbox0.findPath("account")

        shares = sharing.publish(coll0, account)
        self.assert_(len(shares) == 2, "Wrong number of shares created")
        share = sharing.getShare(coll0) # Get the 'main' share
        urls = sharing.getUrls(share)
        self.assert_(len(urls) == 2, "Wrong number of sharing urls")
        url = urls[0] # The read/write ticket url

        # Import
        view1 = self.views[1]
        coll1 = sharing.subscribe(view1, url)

        self.assertEqual(coll0.itsUUID, coll1.itsUUID, "Collection UUIDs "
            "don't match")

        # Make sure that the items we imported have the same displayNames
        # as the ones we exported (and no fewer, no more), and UUIDs match
        names = {}
        for item in coll0:
            names[item.displayName] = 1
        for item in coll1:
            self.assert_(item.displayName in names, "Imported item that wasn't "
             "exported")
            del names[item.displayName]
            self.assertEqual(item.displayName, self.uuids[item.itsUUID],
                "UUID of imported item doesn't match original")
        self.assert_(len(names) == 0, "Import is missing some items that were "
         "exported")
            def run(task):

                account = task.view.find(task.accountUUID)
                collection = task.view.find(task.collectionUUID)

                msg = _(u"Publishing collection to server...\n")
                task.callInMainThread(self._showStatus, msg)

                displayName = self.collection.displayName

                if self.name:
                    displayName = self.name

                share = sharing.publish(collection, account,
                                         filters=filters,
                                         displayName=displayName,
                                         activity=task.activity,
                                         overwrite=task.overwrite,
                                         options=task.options)

                return share.itsUUID
예제 #3
0
    def RoundTrip(self):

        # Export
        view0 = self.views[0]
        sandbox0 = view0.findPath("//sandbox")
        coll0 = sandbox0.findPath("testCollection")
        account = sandbox0.findPath("account")

        shares = sharing.publish(coll0, account)
        self.assert_(len(shares) == 2, "Wrong number of shares created")
        share = sharing.getShare(coll0)  # Get the 'main' share
        urls = sharing.getUrls(share)
        self.assert_(len(urls) == 2, "Wrong number of sharing urls")
        url = urls[0]  # The read/write ticket url

        # Import
        view1 = self.views[1]
        coll1 = sharing.subscribe(view1, url)

        self.assertEqual(coll0.itsUUID, coll1.itsUUID, "Collection UUIDs "
                         "don't match")

        # Make sure that the items we imported have the same displayNames
        # as the ones we exported (and no fewer, no more), and UUIDs match
        names = {}
        for item in coll0:
            names[item.displayName] = 1
        for item in coll1:
            self.assert_(item.displayName in names,
                         "Imported item that wasn't "
                         "exported")
            del names[item.displayName]
            self.assertEqual(item.displayName, self.uuids[item.itsUUID],
                             "UUID of imported item doesn't match original")
        self.assert_(
            len(names) == 0, "Import is missing some items that were "
            "exported")
 def on_debug_InMemoryPublishEvent(self, event):
     collection = self.getSidebarSelectedCollection()
     sharing.publish(collection, None)