示例#1
0
    def check(self, dirdata, file_tree, links, errors=[]):
        page_text = self.genedir(**dirdata)

        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        with CaptureStdIO() as stdio:
            page_html = gene_html(page_text, page_path, _debug=True)
        stderr = stdio.read_stderr()

        for key in dirdata['data'].split():
            td_tag = '<td>{0}</td>'.format(key)
            num_td = page_html.count(td_tag)
            num_data = len(filter(lambda d: key in d, file_tree.itervalues()))
            eq_(
                num_td, num_data,
                "there must be #{0} of '{2}'. #{1} exists".format(
                    num_data, num_td, td_tag))

        for link in links:
            assert '{0}</a>'.format(link) in page_html

        for error in errors:
            assert escape(error, True) in page_html
            assert error in stderr
        if not errors:
            assert not stderr
示例#2
0
文件: test_wiki.py 项目: tkf/neorg
    def check(self, dirdata, file_tree, links, errors=[]):
        page_text = self.genedir(**dirdata)

        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        with CaptureStdIO() as stdio:
            page_html = gene_html(page_text, page_path, _debug=True)
        stderr = stdio.read_stderr()

        for key in dirdata['data'].split():
            td_tag = '<td>{0}</td>'.format(key)
            num_td = page_html.count(td_tag)
            num_data = len(filter(lambda d: key in d,
                                  file_tree.itervalues()))
            eq_(num_td, num_data,
                "there must be #{0} of '{2}'. #{1} exists".format(
                    num_data, num_td, td_tag))

        for link in links:
            assert '{0}</a>'.format(link) in page_html

        for error in errors:
            assert escape(error, True) in page_html
            assert error in stderr
        if not errors:
            assert not stderr
示例#3
0
    def check(self, page_text, file_tree, stats):
        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        page_html = gene_html(page_text, page_path)

        for (key, val) in stats.iteritems():
            eq_(page_html.count(key), val,
                "page_html must contains %d of '%s'" % (val, key))
示例#4
0
文件: test_wiki.py 项目: tkf/neorg
    def check(self, page_text, file_tree, stats):
        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        page_html = gene_html(page_text, page_path)

        for (key, val) in stats.iteritems():
            eq_(page_html.count(key), val,
                "page_html must contains %d of '%s'" % (val, key))
示例#5
0
    def check(self, page_text, file_tree, dictdiff, links):
        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        page_html = gene_html(page_text, page_path)

        for key in dictdiff:
            assert key in page_html

        if links:
            for link in links:
                assert '%s</a>' % link in page_html
        elif links == []:
            assert 'link(s)' not in page_html
示例#6
0
文件: test_wiki.py 项目: tkf/neorg
    def check(self, page_text, file_tree, dictdiff, links):
        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        page_html = gene_html(page_text, page_path)

        for key in dictdiff:
            assert key in page_html

        if links:
            for link in links:
                assert '%s</a>' % link in page_html
        elif links == []:
            assert 'link(s)' not in page_html
示例#7
0
    def check(self, dirdata, file_tree, links, errors=[]):
        page_text = self.genedir(**dirdata)

        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        with CaptureStdIO() as stdio:
            page_html = gene_html(page_text, page_path, _debug=True)
        stderr = stdio.read_stderr()

        for key in dirdata['data'].split():
            td_tag = '<td>{0}</td>'.format(key)
            assert td_tag in page_html

        for link in links:
            assert '{0}</a>'.format(link) in page_html

        for error in errors:
            assert escape(error, True) in page_html
            assert error in stderr
        if not errors:
            assert not stderr
示例#8
0
文件: test_wiki.py 项目: tkf/neorg
    def check(self, dirdata, file_tree, links, errors=[]):
        page_text = self.genedir(**dirdata)

        page_path = 'it does not depend on the page_path'
        web = MockWeb()
        DictTable = MockDictTable.new_mock(file_tree)
        glob_list = Mock(return_value=sorted(file_tree))
        setup_wiki(web=web, DictTable=DictTable, glob_list=glob_list)
        with CaptureStdIO() as stdio:
            page_html = gene_html(page_text, page_path, _debug=True)
        stderr = stdio.read_stderr()

        for key in dirdata['data'].split():
            td_tag = '<td>{0}</td>'.format(key)
            assert td_tag in page_html

        for link in links:
            assert '{0}</a>'.format(link) in page_html

        for error in errors:
            assert escape(error, True) in page_html
            assert error in stderr
        if not errors:
            assert not stderr