Exemplo n.º 1
0
 def test_messageRendering(self):
     """
     Test rendering of message detail for an extremely complex message.
     """
     msg = self.substore.findUnique(Message)
     msg.classifyClean()
     return renderLivePage(ThemedFragmentWrapper(MessageDetail(msg)))
Exemplo n.º 2
0
    def test_transportHookup(self):
        """
        When a LivePage is rendered, it needs to hook up to its transport,
        which is a special resource (associated with the particular LivePage
        object in memory).  This hookup is done by some special logic in
        LivePage.locateChild, among other places.  Let's make sure that we can
        look up the live page by its client ID with the default transport root.

        Athena's default transport root is whatever URL the page is rendered
        at.  In the case of this plugin, that will usually be
        http://localhost:8080/
        """
        w = WidgetPluginRoot(DummyLiveElement)
        page1, seg = w.locateChild(None, [''])
        page1.element.docFactory = stan('the element')
        page1.element.jsClass = u'Dummy.ClassName'

        def cbCheckPageByClientID(result):
            req = FakeRequest()
            ctx = WovenContext()
            ctx.remember(req, IRequest)
            page1prime, seg = w.locateChild(ctx, [page1.clientID])
            self.assertIdentical(page1prime, page1)

        renderDeferred = renderLivePage(page1)
        renderDeferred.addCallback(cbCheckPageByClientID)
        return renderDeferred
Exemplo n.º 3
0
 def test_renderedScrollerRenderable(self):
     """
     L{hyperbola_view.BlogBlurbViewer.render_view} should return a
     L{hyperba.hyperbola_view.ShareScrollTable} that is renderable
     - i.e. has a docFactory and is not an orphan.
     """
     scroller = self._getRenderViewScroller()
     self.failUnless(scroller.fragmentParent is not None)
     return renderLivePage(FragmentWrapper(scroller))
Exemplo n.º 4
0
    def _renderFragment(self, fragment, *a, **k):
        """
        Render the fragment C{fragment}

        @rtype: L{twisted.internet.defer.Deferred} firing with string
        rendering result
        """
        fragment.docFactory = webtheme.getLoader(fragment.fragmentName)
        return renderLivePage(FragmentWrapper(fragment), *a, **k)
Exemplo n.º 5
0
 def test_messageRendering(self):
     """
     Test rendering of message detail for an extremely complex message.
     """
     msg = self.substore.findUnique(Message)
     msg.classifyClean()
     return renderLivePage(
                ThemedFragmentWrapper(
                    MessageDetail(msg)))
Exemplo n.º 6
0
    def _renderFragment(self, fragment, *a, **k):
        """
        Render the fragment C{fragment}

        @rtype: L{twisted.internet.defer.Deferred} firing with string
        rendering result
        """
        fragment.docFactory = webtheme.getLoader(fragment.fragmentName)
        return renderLivePage(FragmentWrapper(fragment), *a, **k)
Exemplo n.º 7
0
 def test_rendering(self):
     """
     L{AddBlogPostDialogFragment} can be rendered as part of a Mantissa
     public Athena page.
     """
     page = PublicAthenaLivePage(self.store, self.fragment, None, None)
     request = FakeRequest()
     request.args = {'title': ['foo'],
                     'body': ['bar'],
                     'url': ['baz']}
     return renderLivePage(page, reqFactory=lambda: request)
Exemplo n.º 8
0
    def test_inboxComposeFragmentRendering(self):
        """
        Test rendering of the L{xquotient.compose.ComposeFragment} returned
        from L{xquotient.inbox.InboxScreen.getComposer}
        """
        installOn(compose.Composer(store=self.substore), self.substore)

        inbox = self.substore.findUnique(Inbox)
        inboxScreen = InboxScreen(inbox)

        composeFrag = inboxScreen.getComposer()

        return renderLivePage(ThemedFragmentWrapper(composeFrag))
Exemplo n.º 9
0
    def test_inboxComposeFragmentRendering(self):
        """
        Test rendering of the L{xquotient.compose.ComposeFragment} returned
        from L{xquotient.inbox.InboxScreen.getComposer}
        """
        installOn(compose.Composer(store=self.substore), self.substore)

        inbox = self.substore.findUnique(Inbox)
        inboxScreen = InboxScreen(inbox)

        composeFrag = inboxScreen.getComposer()

        return renderLivePage(
            ThemedFragmentWrapper(composeFrag))
Exemplo n.º 10
0
 def test_renderEcho(self):
     """
     Rendering the echo example element should produce a very simple text area.
     """
     from echothing.echobox import EchoElement
     TEXT = 'Echo Element'
     eb = EchoElement()
     erlp = ElementRenderingLivePage(eb)
     def checkContent(result):
         # The "liveElement" renderer inserts this, let's look for it to
         # make sure it rendered live:
         self.assertIn('id="athena:'+str(eb._athenaID)+'"', result)
         self.assertIn('athena:class="EchoThing.EchoWidget"', result)
         self.assertIn(TEXT, result)
     return renderLivePage(erlp).addCallback(checkContent)
Exemplo n.º 11
0
 def test_basicRendering(self):
     """
     Rendering the example element should produce a chat area.
     """
     from chatthing.chatterbox import ChatterElement, ChatRoom
     PROMPT = 'Choose your username: '******'s look for it to
         # make sure it rendered live:
         self.assertIn('id="athena:'+str(cb._athenaID)+'"', result)
         self.assertIn('athena:class="ChatThing.ChatterWidget"', result)
         self.assertIn(PROMPT, result)
     return renderLivePage(erlp).addCallback(checkContent)
Exemplo n.º 12
0
    def test_inboxRendering(self):
        """
        Test rendering of the inbox with a handful of extremely complex
        messages in it.
        """
        def deliverMessages():
            for i in xrange(5):
                makeMessage(self.createMIMEReceiver(),
                            self.aBunchOfRelatedParts, None)

        self.substore.transact(deliverMessages)

        inbox = self.substore.findUnique(Inbox)

        composer = compose.Composer(store=self.substore)
        installOn(composer, self.substore)

        return renderLivePage(ThemedFragmentWrapper(InboxScreen(inbox)))
Exemplo n.º 13
0
    def test_inboxRendering(self):
        """
        Test rendering of the inbox with a handful of extremely complex
        messages in it.
        """
        def deliverMessages():
            for i in xrange(5):
                makeMessage(
                    self.createMIMEReceiver(), self.aBunchOfRelatedParts, None)
        self.substore.transact(deliverMessages)

        inbox = self.substore.findUnique(Inbox)

        composer = compose.Composer(store=self.substore)
        installOn(composer, self.substore)

        return renderLivePage(
                   ThemedFragmentWrapper(
                       InboxScreen(inbox)))
Exemplo n.º 14
0
def renderWidget(widget, debug=False):
    """
    Flatten and render a widget.

    @rtype: C{Deferred} -> C{ElementTree}
    @return: A deferred that fires with the parsed flattened output.
    """

    def parse(result):
        return etree.ElementTree(etree.fromstring("<widget>" + result + "</widget>"))

    def printIt(result):
        print result
        return result

    page = athena.LivePage(docFactory=loaders.stan(widget))
    widget.setFragmentParent(page)
    d = renderLivePage(page)
    if debug:
        d.addCallback(printIt)
    d.addCallback(parse)
    return d
Exemplo n.º 15
0
def renderWidget(widget, debug=False):
    """
    Flatten and render a widget.

    @rtype: C{Deferred} -> C{ElementTree}
    @return: A deferred that fires with the parsed flattened output.
    """
    def parse(result):
        return etree.ElementTree(
            etree.fromstring('<widget>' + result + '</widget>'))

    def printIt(result):
        print result
        return result

    page = athena.LivePage(docFactory=loaders.stan(widget))
    widget.setFragmentParent(page)
    d = renderLivePage(page)
    if debug:
        d.addCallback(printIt)
    d.addCallback(parse)
    return d
Exemplo n.º 16
0
    def test_livePageRendering(self):
        """
        Verify that an L{ElementRenderingLivePage} instantiated with a
        particular LiveElement properly renders that element.
        """
        element = DummyLiveElement()
        element.jsClass = u'Dummy.ClassName'
        element.docFactory = stan('the element')
        page = ElementRenderingLivePage(element)
        renderDeferred = renderLivePage(page)

        def cbRendered(result):
            document = parseString(result)
            titles = document.getElementsByTagName('title')
            self.assertEqual(len(titles), 1)
            self.assertEqual(titles[0].firstChild.nodeValue,
                             DummyLiveElement.__name__)
            divs = document.getElementsByTagName('div')
            self.assertEqual(len(divs), 1)
            self.assertEqual(divs[0].firstChild.nodeValue, 'the element')

        renderDeferred.addCallback(cbRendered)
        return renderDeferred
Exemplo n.º 17
0
    def _renderAggregateSearch(self, charset, term):
        """
        Set up a store, and render an aggregate search, with charset
        C{charset} and search term {term}

        @return: deferred firing with string render result
        """
        s = Store()

        installOn(TrivialSearchProvider(store=s), s)

        agg = search.SearchAggregator(store=s)
        installOn(agg, s)

        f = search.AggregateSearchResults(agg)
        f.docFactory = getLoader(f.fragmentName)

        page = FragmentWrapper(f)

        req = AccumulatingFakeRequest()
        req.args = dict(_charset_=[charset], term=[term])

        result = renderLivePage(page, reqFactory=lambda: req)
        return result
Exemplo n.º 18
0
    def _renderAggregateSearch(self, charset, term):
        """
        Set up a store, and render an aggregate search, with charset
        C{charset} and search term {term}

        @return: deferred firing with string render result
        """
        s = Store()

        installOn(TrivialSearchProvider(store=s), s)

        agg = search.SearchAggregator(store=s)
        installOn(agg, s)

        f = search.AggregateSearchResults(agg)
        f.docFactory = getLoader(f.fragmentName)

        page = FragmentWrapper(f)

        req = AccumulatingFakeRequest()
        req.args = dict(_charset_=[charset], term=[term])

        result = renderLivePage(page, reqFactory=lambda: req)
        return result
Exemplo n.º 19
0
 def test_errorRendering(self):
     te = TestError(_DummyErrorHolder())
     return renderLivePage(FragmentWrapper(te)).addCallback(
         lambda output: self.assertIn(MESSAGE, output))
Exemplo n.º 20
0
 def gotSearchResult((fragment,)):
     deferred = renderLivePage(ThemedFragmentWrapper(fragment))
     def rendered(res):
         self.assertIn('no results', res.lower())
         return service.stopService()
     return deferred.addCallback(rendered)
Exemplo n.º 21
0
 def test_errorRendering(self):
     te = TestError(_DummyErrorHolder())
     return renderLivePage(FragmentWrapper(te)).addCallback(
         lambda output: self.assertIn(MESSAGE, output))