def test_powersUpWebViewer(self): """ L{AnonymousSite} provides an indirected L{IWebViewer} powerup, and its indirected powerup should be the default provider of that interface. """ webViewer = IWebViewer(self.store) self.assertIsInstance(webViewer, _AnonymousWebViewer) self.assertIdentical(webViewer._siteStore, self.store)
def test_powersUpWebViewer(self): """ L{PrivateApplication} should provide an indirected L{IWebViewer} powerup, and its indirected powerup should be the default provider of that interface. """ webViewer = IWebViewer(self.privapp.store) self.assertIsInstance(webViewer, _AuthenticatedWebViewer) self.assertIdentical(webViewer._privateApplication, self.privapp)
def test_offeringChild(self): """ Installing an offering makes its shared items accessible under a child of L{_PublicFrontPage} with the offering's name. """ frontPage = FrontPage(store=self.siteStore) resource = _PublicFrontPage(frontPage, self.webViewer) request = FakeRequest() result, segments = resource.locateChild(request, ("test_offering",)) self.assertIdentical(result.userStore, self.substore) self.assertTrue(IWebViewer.providedBy(result.webViewer))
def indirect(self, interface): """ Create a L{VirtualHostWrapper} so it can have the first chance to handle web requests. """ if interface is IResource: siteStore = self.store.parent if self.store.parent is None: siteStore = self.store return VirtualHostWrapper(siteStore, IWebViewer(self.store), self) return self
def test_offeringChild(self): """ Installing an offering makes its shared items accessible under a child of L{_PublicFrontPage} with the offering's name. """ frontPage = FrontPage(store=self.siteStore) resource = _PublicFrontPage(frontPage, self.webViewer) request = FakeRequest() result, segments = resource.locateChild(request, ('test_offering', )) self.assertIdentical(result.userStore, self.substore) self.assertTrue(IWebViewer.providedBy(result.webViewer))
def setUp(self): self.siteStore = Store(filesdir=self.mktemp()) Mantissa().installSite(self.siteStore, u"example.com", u"", False) self.userAccount = Create().addAccount( self.siteStore, u'testuser', u'example.com', u'password') self.userStore = self.userAccount.avatars.open() self.privapp = PrivateApplication(store=self.userStore) installOn(self.privapp, self.userStore) self.webViewer = IWebViewer(self.userStore)
def locateChild(self, context, segments): """ Return a statically defined child or a child defined by a site root plugin or an avatar from guard. """ request = IRequest(context) webViewer = IWebViewer(self.store, None) childAndSegments = self.siteProduceResource(request, segments, webViewer) if childAndSegments is not None: return childAndSegments return NotFound
def test_rootChildWithDefaultApp(self): """ The root resource provided by L{_PublicFrontPage} when a primary application has been selected is that application's L{SharingIndex}. """ resource, segments = self.frontPage.produceResource( None, ('', ), IWebViewer(self.siteStore)) self.assertEqual(segments, ('', )) self.frontPage.defaultApplication = self.app result, segments = resource.locateChild(None, ('', )) self.assertIsInstance(result, PublicPage) self.assertIsInstance(result.fragment, TestAppElement)
def test_nonExistentChild(self): """ L{_PublicFrontPage.locateChild} returns L{rend.NotFound} for a child segment which does not exist. """ store = Store() frontPage = FrontPage(store=store) resource = _PublicFrontPage(frontPage, IWebViewer(self.siteStore)) request = FakeRequest() ctx = context.WebContext() ctx.remember(request, inevow.IRequest) result = resource.locateChild(ctx, ('foo', )) self.assertIdentical(result, rend.NotFound)
def test_viewability(self): """ Verify that a blog may be viewed publicly, by retrieving it through the web sharing index and inspecting the result to verify that it will have appropriate properties set. """ er = getEveryoneRole(self.userStore) si = SharingIndex(self.userStore, IWebViewer(self.siteStore)) child, segs = si.locateChild(None, ['blog']) self.assertEquals(len(segs), 0) self.failUnless(isinstance(child, PublicAthenaLivePage)) viewer = child.fragment self.failUnless(isinstance(viewer, BlurbViewer)) blurbish = viewer.original self.failUnless(blurbish.title, self.blog.title) self.assertEquals(viewer.getRole(), er)
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 setUp(self): store = Store() ss = SubStore.createNew(store, ['test']).open() self.pa = PrivateApplication(store=ss) installOn(self.pa, ss) self.webViewer = IWebViewer(ss)