Example #1
0
 def test_appStoreLinkTo(self):
     """
     When L{websharing.linkTo} is called on a shared item in an app store,
     it returns an URL with a single path segment consisting of the app's
     name.
     """
     s = Store(dbdir=self.mktemp())
     Mantissa().installSite(s, u"localhost", u"", False)
     Mantissa().installAdmin(s, u'admin', u'localhost', u'asdf')
     off = offering.Offering(
         name=u'test_offering',
         description=u'Offering for creating a sample app store',
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     userbase = s.findUnique(LoginSystem)
     adminAccount = userbase.accountByAddress(u'admin', u'localhost')
     conf = adminAccount.avatars.open().findUnique(
         offering.OfferingConfiguration)
     conf.installOffering(off, None)
     ss = userbase.accountByAddress(off.name, None).avatars.open()
     sharedItem = sharing.getEveryoneRole(ss).getShare(
         websharing.getDefaultShareID(ss))
     linkURL = websharing.linkTo(sharedItem)
     self.failUnless(
         isinstance(linkURL, url.URL),
         "linkTo should return a nevow.url.URL, not %r" % (type(linkURL)))
     self.assertEquals(str(linkURL), '/test_offering/')
Example #2
0
 def test_appStoreLinkTo(self):
     """
     When L{websharing.linkTo} is called on a shared item in an app store,
     it returns an URL with a single path segment consisting of the app's
     name.
     """
     s = Store(dbdir=self.mktemp())
     Mantissa().installSite(s, u"localhost", u"", False)
     Mantissa().installAdmin(s, u'admin', u'localhost', u'asdf')
     off = offering.Offering(
         name=u'test_offering',
         description=u'Offering for creating a sample app store',
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
         )
     userbase = s.findUnique(LoginSystem)
     adminAccount = userbase.accountByAddress(u'admin', u'localhost')
     conf = adminAccount.avatars.open().findUnique(
         offering.OfferingConfiguration)
     conf.installOffering(off, None)
     ss = userbase.accountByAddress(off.name, None).avatars.open()
     sharedItem = sharing.getEveryoneRole(ss).getShare(
         websharing.getDefaultShareID(ss))
     linkURL = websharing.linkTo(sharedItem)
     self.failUnless(isinstance(linkURL, url.URL),
                     "linkTo should return a nevow.url.URL, not %r" %
                     (type(linkURL)))
     self.assertEquals(str(linkURL), '/test_offering/')
Example #3
0
 def installApp(self, ss1):
     """
     Create a public item and share it as the default.
     """
     fpi = FakePublicItem(store=ss1)
     shareItem(fpi, toRole=getEveryoneRole(ss1),
               shareID=getDefaultShareID(ss1))
Example #4
0
 def test_findShareID(self):
     """
     Verify that L{websharing.getDefaultShareID} reads the share ID set by a
     L{websharing.addDefaultShareID} call.
     """
     store = Store()
     websharing.addDefaultShareID(store, u'share id', 0)
     self.assertEqual(websharing.getDefaultShareID(store), u'share id')
Example #5
0
 def test_findShareID(self):
     """
     Verify that L{websharing.getDefaultShareID} reads the share ID set by a
     L{websharing.addDefaultShareID} call.
     """
     store = Store()
     websharing.addDefaultShareID(store, u'share id', 0)
     self.assertEqual(websharing.getDefaultShareID(store), u'share id')
Example #6
0
 def installApp(self, ss1):
     """
     Create a public item and share it as the default.
     """
     fpi = FakePublicItem(store=ss1)
     shareItem(fpi,
               toRole=getEveryoneRole(ss1),
               shareID=getDefaultShareID(ss1))
Example #7
0
 def test_findHighestPriorityShareID(self):
     """
     Verify that L{websharing.getDefaultShareID} reads the highest-priority
     share ID set by L{websharing.addDefaultShareID}.
     """
     store = Store()
     websharing.addDefaultShareID(store, u'share id!', 24)
     websharing.addDefaultShareID(store, u'share id',  25)
     websharing.addDefaultShareID(store, u'share id.', -1)
     self.assertEqual(websharing.getDefaultShareID(store), u'share id')
Example #8
0
 def test_findHighestPriorityShareID(self):
     """
     Verify that L{websharing.getDefaultShareID} reads the highest-priority
     share ID set by L{websharing.addDefaultShareID}.
     """
     store = Store()
     websharing.addDefaultShareID(store, u'share id!', 24)
     websharing.addDefaultShareID(store, u'share id', 25)
     websharing.addDefaultShareID(store, u'share id.', -1)
     self.assertEqual(websharing.getDefaultShareID(store), u'share id')
Example #9
0
 def setUp(self):
     """
     Set up a store with an installed offering.
     """
     self.siteStore = Store(dbdir=self.mktemp())
     Mantissa().installSite(self.siteStore, u"localhost", u"", False)
     off = Offering(
         name=u"test_offering",
         description=u"Offering for creating a sample app store",
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     self.installedOffering = installOffering(self.siteStore, off, None)
     self.app = self.installedOffering.application
     self.substore = self.app.open()
     sharedItem = getEveryoneRole(self.substore).getShare(getDefaultShareID(self.substore))
     self.frontPage = self.siteStore.findUnique(FrontPage)
     self.webViewer = IWebViewer(self.siteStore)
Example #10
0
    def data_offerings(self, ctx, data):
        """
        Generate a list of installed offerings.

        @return: a generator of dictionaries mapping 'name' to the name of an
        offering installed on the store.
        """
        for io in self.original.store.query(offering.InstalledOffering):
            pp = ixmantissa.IPublicPage(io.application, None)
            if pp is not None and getattr(pp, 'index', True):
                warn("Use the sharing system to provide public pages,"
                     " not IPublicPage",
                     category=DeprecationWarning,
                     stacklevel=2)
                yield {'name': io.offeringName}
            else:
                s = io.application.open()
                try:
                    pp = getEveryoneRole(s).getShare(getDefaultShareID(s))
                    yield {'name': io.offeringName}
                except NoSuchShare:
                    continue
Example #11
0
 def setUp(self):
     """
     Set up a store with an installed offering.
     """
     self.siteStore = Store(dbdir=self.mktemp())
     Mantissa().installSite(self.siteStore, u"localhost", u"", False)
     off = Offering(
         name=u'test_offering',
         description=u'Offering for creating a sample app store',
         siteRequirements=[],
         appPowerups=[TestAppPowerup],
         installablePowerups=[],
         loginInterfaces=[],
         themes=[],
     )
     self.installedOffering = installOffering(self.siteStore, off, None)
     self.app = self.installedOffering.application
     self.substore = self.app.open()
     sharedItem = getEveryoneRole(self.substore).getShare(
         getDefaultShareID(self.substore))
     self.frontPage = self.siteStore.findUnique(FrontPage)
     self.webViewer = IWebViewer(self.siteStore)
Example #12
0
    def data_offerings(self, ctx, data):
        """
        Generate a list of installed offerings.

        @return: a generator of dictionaries mapping 'name' to the name of an
        offering installed on the store.
        """
        for io in self.original.store.query(offering.InstalledOffering):
            pp = ixmantissa.IPublicPage(io.application, None)
            if pp is not None and getattr(pp, 'index', True):
                warn(
                    "Use the sharing system to provide public pages,"
                    " not IPublicPage",
                    category=DeprecationWarning,
                    stacklevel=2)
                yield {'name': io.offeringName}
            else:
                s = io.application.open()
                try:
                    pp = getEveryoneRole(s).getShare(getDefaultShareID(s))
                    yield {'name': io.offeringName}
                except NoSuchShare:
                    continue
Example #13
0
 def test_findsNoItem(self):
     """
     Verify that L{websharing.getDefaultShareID} returns C{u''} if there is
     no default share ID.
     """
     self.assertEqual(websharing.getDefaultShareID(Store()), u'')
Example #14
0
 def test_findsNoItem(self):
     """
     Verify that L{websharing.getDefaultShareID} returns C{u''} if there is
     no default share ID.
     """
     self.assertEqual(websharing.getDefaultShareID(Store()), u'')