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/')
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/')
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))
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')
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')
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)
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
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)
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
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'')