Example #1
0
    def test_postWithoutPrivileges(self):
        """
        Attempting to post to a blog should result in a L{LoginPage} which
        remembers the parameters of the attempted post.
        """
        class StubBlurb(object):
            """
            L{Blurb}-alike for testing purposes.
            """
            def __init__(self, store, flavor):
                self.store = store
                self.flavor = flavor

        currentSegments = ['foo', 'bar']
        postSegments = ['post', 'baz']
        arguments = {'quux': ['1', '2']}
        request = FakeRequest(
            uri='/'.join([''] + currentSegments + postSegments),
            currentSegments=currentSegments, args=arguments)
        blurb = StubBlurb(self.userStore, FLAVOR.BLOG)
        sharedBlurb = SharedProxy(blurb, (IViewable,), 'abc')
        view = BlurbViewer(sharedBlurb)
        child, segments = view.locateChild(request, postSegments)
        self.assertTrue(isinstance(child, LoginPage))
        self.assertEqual(child.segments, currentSegments + postSegments[:1])
        self.assertEqual(child.arguments, arguments)
        self.assertEqual(segments, postSegments[1:])
Example #2
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)))
Example #3
0
 def test_bodyRendererEmptyBody(self):
     """
     L{BlurbViewer.body} should be able to render Blurbs
     with empty bodies.
     """
     body = u''
     view = BlurbViewer(self._makeBlurb(hyperblurb.FLAVOR.BLOG, None, body))
     result = flatten(view.body(None, None))
     self.assertEqual(result, body)
Example #4
0
 def test_bodyRenderer(self):
     """
     L{BlurbViewer.body} should return a well-formed XHTML document
     fragment even if the body of the blurb being rendered is not
     well-formed.
     """
     body = u'<i>hello'
     expectedBody = u'<i>hello</i><br />'
     view = BlurbViewer(self._makeBlurb(hyperblurb.FLAVOR.BLOG, None, body))
     result = flatten(view.body(None, None))
     self.assertEqual(result, expectedBody)