Exemple #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/')
 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/')
Exemple #3
0
    def test_blogsRenderer(self):
        """
        Test that L{hyperbola_view.BlogListFragment.blogs} renders a list of blogs.
        """
        site = self.siteStore.findUnique(SiteConfiguration)
        site.hostname = u'blogs.renderer'
        blog1 = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG))
        blog2 = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG))
        blf = hyperbola_view.BlogListFragment(
            athena.LivePage(), self.publicPresence)
        blf.docFactory = loaders.stan(
            tags.div(pattern='blog')[
                tags.span[tags.slot('title')],
                tags.span[tags.slot('link')],
                tags.span[tags.slot('post-url')]])
        tag = tags.invisible
        markup = flat.flatten(tags.div[blf.blogs(None, tag)])
        doc = minidom.parseString(markup)
        blogNodes = doc.firstChild.getElementsByTagName('div')
        self.assertEqual(len(blogNodes), 2)

        for (blogNode, blog) in zip(blogNodes, (blog1, blog2)):
            (title, blogURL, postURL) = blogNode.getElementsByTagName('span')
            blogURL = blogURL.firstChild.nodeValue
            expectedBlogURL = str(websharing.linkTo(blog))
            self.assertEqual(blogURL, expectedBlogURL)
            postURL = postURL.firstChild.nodeValue
            self.assertEqual(
                postURL, 'https://blogs.renderer' + expectedBlogURL + '/post')
 def test_linkToMatchesUserURL(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL using the
     localpart of the account's internal L{axiom.userbase.LoginMethod}
     """
     pathString = str(websharing.linkTo(self.share))
     expected = u'/users/%s/%s' % (self.username, self.shareID)
     self.assertEqual(pathString, expected.encode('ascii'))
 def titleLink(self, request, tag):
     """
     @return: title of our blurb
     """
     url = websharing.linkTo(self.original)
     return tag.fillSlots(
         'link', url.child('detail')).fillSlots(
         'title', self.original.title)
 def test_linkToProxy(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL that I can
     link to.
     """
     self._verifyPath(
         websharing.linkTo(sharing.getShare(self.s, sharing.getEveryoneRole(
                     self.s), u'loginsystem')))
Exemple #7
0
 def test_linkToMatchesUserURL(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL using the
     localpart of the account's internal L{axiom.userbase.LoginMethod}
     """
     pathString = str(websharing.linkTo(self.share))
     expected = u'/users/%s/%s' % (self.username, self.shareID)
     self.assertEqual(pathString, expected.encode('ascii'))
Exemple #8
0
 def test_absoluteURL(self):
     """
     Verify that L{BlurbViewer._absoluteURL} returns something that looks
     correct.
     """
     share = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG_POST))
     frag = BlurbViewer(share)
     self.assertEqual(
         frag._absoluteURL(), 'https://localhost' + str(websharing.linkTo(share)))
Exemple #9
0
 def test_linkToProxy(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL that I can
     link to.
     """
     self._verifyPath(
         websharing.linkTo(
             sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'loginsystem')))
Exemple #10
0
 def test_defaultShareIDInteractionNoMatch(self):
     """
     Verify that L{websharing.linkTo} explicitly includes a share ID in the
     URL if the ID of the share it is passed doesn't match the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     shareable = Shareable(store=self.s)
     sharing.shareItem(Shareable(store=self.s), shareID=u'not-the-share-id')
     share = sharing.getShare(
         self.s, sharing.getEveryoneRole(self.s), u'not-the-share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/not-the-share-id')
Exemple #11
0
 def test_defaultShareIDInteractionNoMatch(self):
     """
     Verify that L{websharing.linkTo} explicitly includes a share ID in the
     URL if the ID of the share it is passed doesn't match the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     shareable = Shareable(store=self.s)
     sharing.shareItem(Shareable(store=self.s), shareID=u'not-the-share-id')
     share = sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'not-the-share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/not-the-share-id')
Exemple #12
0
 def test_titleLink(self):
     """
     Verify that L{hyperbola_view.BlogPostBlurbViewer.titleLink} links to
     the correct url.
     """
     share = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG_POST))
     tag = tags.div[tags.slot('link')]
     frag = hyperbola_view.BlogPostBlurbViewer(share)
     tag = page.renderer.get(frag, 'titleLink')(None, tag)
     self.assertEqual(
         str(tag.slotData['link']),
         str(websharing.linkTo(share).child('detail')))
 def _absoluteURL(self):
     """
     Return the absolute URL the websharing system makes this blurb
     available at.
     """
     subStore = sharing.itemFromProxy(self.original).store
     site = ixmantissa.ISiteURLGenerator(subStore.parent)
     siteURL = site.encryptedRoot()
     blurbURL = websharing.linkTo(self.original)
     blurbURL.netloc = siteURL.netloc
     blurbURL.scheme = siteURL.scheme
     return str(blurbURL)
Exemple #14
0
 def test_defaultShareIDInteractionMatching(self):
     """
     Verify that L{websharing.linkTo} does not explicitly include a share
     ID in the URL if the ID of the share it is passed matches the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     sharing.shareItem(Shareable(store=self.s), shareID=u'share-id')
     share = sharing.getShare(
         self.s, sharing.getEveryoneRole(self.s), u'share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/')
     # and if we call child()
     self.assertEqual(str(url.child('child')), '/users/right/share-id/child')
    def _getPostURL(self, blog):
        """
        Figure out a URL which could be used for posting to C{blog}

        @type blog: L{xmantissa.sharing.SharedProxy}
        @rtype: L{nevow.url.URL}
        """
        site = ixmantissa.ISiteURLGenerator(self.hyperbola.store.parent)
        blogURL = websharing.linkTo(blog)
        siteURL = site.encryptedRoot()
        blogURL.netloc = siteURL.netloc
        blogURL.scheme = siteURL.scheme
        return blogURL.child('post')
Exemple #16
0
 def test_defaultShareIDInteractionMatching(self):
     """
     Verify that L{websharing.linkTo} does not explicitly include a share
     ID in the URL if the ID of the share it is passed matches the default.
     """
     websharing.addDefaultShareID(self.s, u'share-id', 0)
     sharing.shareItem(Shareable(store=self.s), shareID=u'share-id')
     share = sharing.getShare(self.s, sharing.getEveryoneRole(self.s),
                              u'share-id')
     url = websharing.linkTo(share)
     self.assertEqual(str(url), '/users/right/')
     # and if we call child()
     self.assertEqual(str(url.child('child')),
                      '/users/right/share-id/child')
 def blogs(self, req, tag):
     """
     Render all blogs
     """
     p = inevow.IQ(self.docFactory).patternGenerator('blog')
     webapp = ixmantissa.IWebTranslator(self.hyperbola.store)
     blogs = list()
     primaryRole = sharing.getSelfRole(self.hyperbola.store)
     for blog in self.hyperbola.getTopLevelFor(primaryRole):
         blogs.append(p.fillSlots(
                 'title', blog.title).fillSlots(
                 'link', websharing.linkTo(blog)).fillSlots(
                 'post-url', self._getPostURL(blog)))
     return tag[blogs]
Exemple #18
0
 def test_linkToShare(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL using the
     localpart of the account's internal L{axiom.userbase.LoginMethod}
     """
     self._verifyPath(websharing.linkTo(self.share))
Exemple #19
0
 def test_linkToShare(self):
     """
     Test that L{xmantissa.websharing.linkTo} generates a URL using the
     localpart of the account's internal L{axiom.userbase.LoginMethod}
     """
     self._verifyPath(websharing.linkTo(self.share))