示例#1
0
    def test_batches_and_formatting(self):
        # DTML test 3: batches and formatting:
        pass  # for unittest
        """
          <html><head><title>Test of documentation templates</title></head>
          <body>
          <!--#if args-->
            The arguments were:
            <!--#in args size=size end=end-->
                <!--#if previous-sequence-->
                   (<!--#var previous-sequence-start-arg-->-
                    <!--#var previous-sequence-end-arg-->)
                <!--#/if previous-sequence-->
                <!--#if sequence-start-->
                   <dl>
                <!--#/if sequence-start-->
                <dt><!--#var sequence-arg-->.</dt>
                <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
                <!--#if next-sequence-->
                   (<!--#var next-sequence-start-arg-->-
                    <!--#var next-sequence-end-arg-->)
                <!--#/if next-sequence-->
            <!--#/in args-->
            </dl>
          <!--#else args-->
            No arguments were given.<p>
          <!--#/if args-->
          And I\'m 100% sure!
          </body></html>
        """
        tal = util.read_input('dtml3.html')
        self.t.write(tal)

        aa = util.argv((
            'one',
            'two',
            'three',
            'four',
            'five',
            'six',
            'seven',
            'eight',
            'nine',
            'ten',
            'eleven',
            'twelve',
            'thirteen',
            'fourteen',
            'fifteen',
            'sixteen',
            'seventeen',
            'eighteen',
            'nineteen',
            'twenty',
        ))
        from zope.pagetemplate.tests import batch
        o = self.t(content=aa, batch=batch.batch(aa.args, 5))

        expect = util.read_output('dtml3.html')
        util.check_xml(expect, o)
示例#2
0
    def test_topics(self):
        path = os.path.join(testdir(), 'help.txt')

        id = 'topic1'
        title = 'Topic1'
        parentPath = ""
        topic1 = OnlineHelpTopic(id, title, path, parentPath)
        self.onlinehelp['topic1'] = topic1

        id = 'topic1_1'
        title = 'Topic1_1'
        parentPath = 'topic1'
        topic1_1 = OnlineHelpTopic(id, title, path, parentPath)
        topic1['topic1_1'] = topic1_1

        id = 'topic1_1_1'
        title = 'Topic1_1_1'
        parentPath = 'topic1/topic1_1'
        topic1_1_1 = OnlineHelpTopic(id, title, path, parentPath)
        topic1_1['topic1_1_1'] = topic1_1_1

        id = 'topic2'
        title = 'Topic2'
        parentPath = ""
        topic2 = OnlineHelpTopic(id, title, path, parentPath)
        self.onlinehelp['topic2'] = topic2

        view = OnlineHelpTopicTreeView
        treeView = view(self.rootFolder, TestRequest()).getTopicTree
        check_xml(treeView(), util.read_output('test2.xml'))
示例#3
0
    def test_if_in_var(self):
        # DTML test 1: if, in, and var:
        pass  # for unittest
        """
        %(comment)[ blah %(comment)]
        <html><head><title>Test of documentation templates</title></head>
        <body>
        %(if args)[
        <dl><dt>The arguments to this test program were:<p>
        <dd>
        <ul>
        %(in args)[
          <li>Argument number %(num)d was %(arg)s
        %(in args)]
        </ul></dl><p>
        %(if args)]
        %(else args)[
        No arguments were given.<p>
        %(else args)]
        And thats da trooth.
        </body></html>
        """
        tal = util.read_input('dtml1.html')
        self.t.write(tal)

        aa = util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
        o = self.t(content=aa)
        expect = util.read_output('dtml1a.html')

        util.check_xml(expect, o)

        aa = util.argv(())
        o = self.t(content=aa)
        expect = util.read_output('dtml1b.html')
        util.check_xml(expect, o)
示例#4
0
 def test_simple_tree_view_1(self):
     context = self.rootFolder['folder1']
     request = TestRequest()
     view = SimpleJSONTreeView(context, request)
     view.update()
     ultree = view.tree
     check_xml(ultree, util.read_output('tree_1.txt'))
    def test_if_in_var(self):
        # DTML test 1: if, in, and var:
        pass # for unittest
        """
        %(comment)[ blah %(comment)]
        <html><head><title>Test of documentation templates</title></head>
        <body>
        %(if args)[
        <dl><dt>The arguments to this test program were:<p>
        <dd>
        <ul>
        %(in args)[
          <li>Argument number %(num)d was %(arg)s
        %(in args)]
        </ul></dl><p>
        %(if args)]
        %(else args)[
        No arguments were given.<p>
        %(else args)]
        And thats da trooth.
        </body></html>
        """
        tal = util.read_input('dtml1.html')
        self.t.write(tal)

        aa = util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
        o = self.t(content=aa)
        expect = util.read_output('dtml1a.html')

        util.check_xml(expect, o)

        aa = util.argv(())
        o = self.t(content=aa)
        expect = util.read_output('dtml1b.html')
        util.check_xml(expect, o)
示例#6
0
    def test_topics(self):
        path = os.path.join(testdir(), 'help.txt')
        
        id = 'topic1'
        title = 'Topic1'
        parentPath = ""
        topic1 = OnlineHelpTopic(id, title, path, parentPath)
        self.onlinehelp['topic1'] = topic1

        id = 'topic1_1'
        title = 'Topic1_1'
        parentPath = 'topic1'
        topic1_1 = OnlineHelpTopic(id, title, path, parentPath)
        topic1['topic1_1']  = topic1_1

        id = 'topic1_1_1'
        title = 'Topic1_1_1'
        parentPath = 'topic1/topic1_1'
        topic1_1_1 = OnlineHelpTopic(id, title, path, parentPath)
        topic1_1['topic1_1_1']  = topic1_1_1

        id = 'topic2'
        title = 'Topic2'
        parentPath = ""
        topic2 = OnlineHelpTopic(id, title, path, parentPath)
        self.onlinehelp['topic2'] = topic2
        
        view = OnlineHelpTopicTreeView
        treeView = view(self.rootFolder, TestRequest()).getTopicTree
        check_xml(treeView(), util.read_output('test2.xml'))
示例#7
0
 def test_simple_tree_view_2(self):
     """This test includes cyrillic letters."""
     context = self.rootFolder['folder2']['folder2_1']['folder2_1_1']
     request = TestRequest()
     view = SimpleJSONTreeView(context, request)
     view.update()
     ultree = view.tree
     check_xml(ultree, util.read_output('tree_2.txt'))
示例#8
0
 def test_simple_tree_view_3(self):
     """This test includes cyrillic letters and maxItems."""
     context = self.rootFolder['folder1']
     for i in range(55):
         context[str(i)] = Folder()
     
     subFolder = context['1']
     request = TestRequest()
     view = SimpleJSONTreeView(subFolder, request)
     view.update()
     ultree = view.tree
     check_xml(ultree, util.read_output('tree_3.txt'))
    def test_batches_and_formatting(self):
        # DTML test 3: batches and formatting:
        pass # for unittest
        """
          <html><head><title>Test of documentation templates</title></head>
          <body>
          <!--#if args-->
            The arguments were:
            <!--#in args size=size end=end-->
                <!--#if previous-sequence-->
                   (<!--#var previous-sequence-start-arg-->-
                    <!--#var previous-sequence-end-arg-->)
                <!--#/if previous-sequence-->
                <!--#if sequence-start-->
                   <dl>
                <!--#/if sequence-start-->
                <dt><!--#var sequence-arg-->.</dt>
                <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
                <!--#if next-sequence-->
                   (<!--#var next-sequence-start-arg-->-
                    <!--#var next-sequence-end-arg-->)
                <!--#/if next-sequence-->
            <!--#/in args-->
            </dl>
          <!--#else args-->
            No arguments were given.<p>
          <!--#/if args-->
          And I\'m 100% sure!
          </body></html>
        """
        tal = util.read_input('dtml3.html')
        self.t.write(tal)

        aa = util.argv(('one', 'two', 'three', 'four', 'five',
                        'six', 'seven', 'eight', 'nine', 'ten',
                        'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
                        'sixteen', 'seventeen', 'eighteen', 'nineteen',
                        'twenty',
                        ))
        from zope.pagetemplate.tests import batch
        o = self.t(content=aa, batch=batch.batch(aa.args, 5))

        expect = util.read_output('dtml3.html')
        util.check_xml(expect, o)
示例#10
0
    def test_template_usage(self):
        tal = util.read_input('template_usage.html')
        self.t.write(tal)

        o = self.t(template_usage=u"test")
        expect = util.read_output('template_usage1.html')
        util.check_xml(expect, o)

        o = self.t(template_usage=u"retest")
        expect = util.read_output('template_usage2.html')
        util.check_xml(expect, o)

        o = self.t(template_usage=u"other")
        expect = util.read_output('template_usage3.html')
        util.check_xml(expect, o)

        o = self.t(template_usage=u"")
        expect = util.read_output('template_usage4.html')
        util.check_xml(expect, o)
    def test_virtualhost_support(self):

        # we have to add a virtual host subsite
        folder1 = self.rootFolder['folder1']
        subsite = Folder()
        sm = LocalSiteManager(folder1)
        subsite.setSiteManager(sm)
        folder1['subsite'] = subsite

        # add some more folder to the subsite
        subfolder1 = Folder()
        subsite['subfolder1'] = subfolder1
        subfolder2 = Folder()
        subfolder2_1 = Folder()
        subfolder2['subfolder2_1'] = subfolder2_1
        subsite['subfolder2'] = subfolder2

        # set the virtualhost on the request
        request = TestRequest()
        request._vh_root = subsite

        # test virtual host root
        vh = request.getVirtualHostRoot()
        self.assertEquals(vh, subsite)

        rcxov = ReadContainerXmlObjectView
        treeView = rcxov(subsite, request).singleBranchTree
        check_xml(treeView(), util.read_output('test6.xml'))

        rcxov = ReadContainerXmlObjectView
        treeView = rcxov(subfolder1, request).singleBranchTree
        check_xml(treeView(), util.read_output('test7.xml'))

        rcxov = ReadContainerXmlObjectView
        treeView = rcxov(subfolder2_1, request).singleBranchTree
        check_xml(treeView(), util.read_output('test8.xml'))
示例#12
0
 def test_onlinehelp(self):
     view = OnlineHelpTopicTreeView
     treeView = view(self.rootFolder, TestRequest()).getTopicTree
     check_xml(treeView(), util.read_output('test1.xml'))
示例#13
0
 def test_onlinehelp(self):
     view = OnlineHelpTopicTreeView
     treeView = view(self.rootFolder, TestRequest()).getTopicTree
     check_xml(treeView(), util.read_output('test1.xml'))
    def testXMLTreeViews(self):
        rcxov = ReadContainerXmlObjectView
        treeView = rcxov(self.folder1, TestRequest()).singleBranchTree
        check_xml(treeView(), util.read_output('test1.xml'))

        treeView = rcxov(self.folder1, TestRequest()).children
        check_xml(treeView(), util.read_output('test2.xml'))

        treeView = rcxov(self.folder1_1_1, TestRequest()).children
        check_xml(treeView(), util.read_output('test3.xml'))

        treeView = rcxov(self.rootFolder, TestRequest()).children
        check_xml(treeView(), util.read_output('test4.xml'))

        file1 = File()
        self.folder1_1_1["file1"] = file1
        self.file1 = traverse(self.rootFolder,
                              '/folder1/folder1_1/folder1_1_1/file1')

        class ReadContainerView(ReadContainerXmlObjectView):
            implements(IBrowserPublisher)
            def browserDefault(self, request):
                return self, ()
            def publishTraverse(self, request, name):
                raise NotFound(self, name, request)
            def __call__(self):
                return self.singleBranchTree()

        ztapi.browserView(IReadContainer, 'singleBranchTree.xml',
                          ReadContainerView)

        treeView = rcxov(self.folder1_1_1, TestRequest()).singleBranchTree
        check_xml(treeView(), util.read_output('test5.xml'))

        treeView = XmlObjectView(self.file1, TestRequest()).singleBranchTree
        check_xml(treeView(), util.read_output('test5.xml'))