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
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
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))
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
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