Ejemplo n.º 1
0
    def test_blurbViewDetailDispatch(self):
        """
        Test that we can pass a blurb of any flavor to
        L{hyperbola.hyperbola_view.blurbViewDetailDispatcher} and then render
        the result
        """
        deferreds = list()
        for parentFlavor in hyperblurb.ALL_FLAVORS:
            childFlavor = hyperblurb.FLAVOR.commentFlavors[parentFlavor]

            parent = self._makeBlurb(parentFlavor)
            child = self._makeBlurb(childFlavor)
            child.parent = parent

            childProxy = self._shareAndGetProxy(child)
            deferreds.append(self._renderFragment(
                hyperbola_view.blurbViewDetailDispatcher(childProxy)))
        return defer.gatherResults(deferreds)
Ejemplo n.º 2
0
    def test_blurbViewDetailDispatch(self):
        """
        Test that we can pass a blurb of any flavor to
        L{hyperbola.hyperbola_view.blurbViewDetailDispatcher} and then render
        the result
        """
        deferreds = list()
        for parentFlavor in hyperblurb.ALL_FLAVORS:
            childFlavor = hyperblurb.FLAVOR.commentFlavors[parentFlavor]

            parent = self._makeBlurb(parentFlavor)
            child = self._makeBlurb(childFlavor)
            child.parent = parent

            childProxy = self._shareAndGetProxy(child)
            deferreds.append(
                self._renderFragment(
                    hyperbola_view.blurbViewDetailDispatcher(childProxy)))
        return defer.gatherResults(deferreds)
Ejemplo n.º 3
0
    def test_blogPostDetailRendering(self):
        """
        Test that we can pass a blog post blurb to
        L{hyperbola.hyperbola_view.blurbViewDetailDispatcher} and that the
        rendered result contains the title and body of the parent
        """
        child = self._makeBlurb(hyperblurb.FLAVOR.BLOG_POST)
        child.parent = self._makeBlurb(
            hyperblurb.FLAVOR.BLOG, title=u'Parent Title', body=u'Parent Body')

        childProxy = self._shareAndGetProxy(child)
        D = self._renderFragment(
            hyperbola_view.blurbViewDetailDispatcher(childProxy))

        def rendered(xml):
            elements = {}
            doc = minidom.parseString(xml)
            for elt in doc.getElementsByTagName('*'):
                cls = elt.getAttribute('class')
                if not cls:
                    continue
                if cls not in elements:
                    elements[cls] = []
                elements[cls].append(elt)

            self.assertEquals(
                len(elements['hyperbola-blog-main-title']), 1)
            self.assertEquals(
                elements['hyperbola-blog-main-title'][0].firstChild.nodeValue,
                'Parent Title')
            self.assertEquals(
                len(elements['hyperbola-blog-sub-title']), 1)
            self.assertEquals(
                elements['hyperbola-blog-sub-title'][0].firstChild.nodeValue,
                'Parent Body')

        D.addCallback(rendered)
        return D
Ejemplo n.º 4
0
    def test_blogPostDetailRendering(self):
        """
        Test that we can pass a blog post blurb to
        L{hyperbola.hyperbola_view.blurbViewDetailDispatcher} and that the
        rendered result contains the title and body of the parent
        """
        child = self._makeBlurb(hyperblurb.FLAVOR.BLOG_POST)
        child.parent = self._makeBlurb(hyperblurb.FLAVOR.BLOG,
                                       title=u'Parent Title',
                                       body=u'Parent Body')

        childProxy = self._shareAndGetProxy(child)
        D = self._renderFragment(
            hyperbola_view.blurbViewDetailDispatcher(childProxy))

        def rendered(xml):
            elements = {}
            doc = minidom.parseString(xml)
            for elt in doc.getElementsByTagName('*'):
                cls = elt.getAttribute('class')
                if not cls:
                    continue
                if cls not in elements:
                    elements[cls] = []
                elements[cls].append(elt)

            self.assertEquals(len(elements['hyperbola-blog-main-title']), 1)
            self.assertEquals(
                elements['hyperbola-blog-main-title'][0].firstChild.nodeValue,
                'Parent Title')
            self.assertEquals(len(elements['hyperbola-blog-sub-title']), 1)
            self.assertEquals(
                elements['hyperbola-blog-sub-title'][0].firstChild.nodeValue,
                'Parent Body')

        D.addCallback(rendered)
        return D