def test_simple_document(self): # ARRANGE # section_contents = SectionContents([para('para in contents')], []) populator = utils.ComplexElementPopulator([ SingleParaPopulator('para from pop 1'), SingleParaPopulator('para from pop 2') ]) document_setup = sut.DocumentSetup('page title', footer_populator=populator) # ACT # output_file = io.StringIO() DOCUMENT_RENDERER.apply(output_file, document_setup, section_contents) actual = output_file.getvalue() # ASSERT # expected = (DOCTYPE_XHTML1_0 + '<html>' '<head>' '<title>page title</title>' '</head>' '<body>' '<p>para in contents</p>' '<p>para from pop 1</p>' '<p>para from pop 2</p>' '</body>' '</html>') self.assertEqual(expected, actual)
def test_simple_document(self): # ARRANGE # section_contents = SectionContents([para('para 0')], [ Section(StringText('header 1'), SectionContents([para('para 1'), para('')], [])) ]) document_setup = sut.DocumentSetup('page title') # ACT # output_file = io.StringIO() DOCUMENT_RENDERER.apply(output_file, document_setup, section_contents) actual = output_file.getvalue() # ASSERT # expected = (DOCTYPE_XHTML1_0 + '<html>' '<head>' '<title>page title</title>' '</head>' '<body>' '<p>para 0</p>' '<section>' '<header>' '<h1>header 1</h1>' '</header>' '<p>para 1</p>' '<p></p>' '</section>' '</body>' '</html>') self.assertEqual(expected, actual)
def test_footer_populator(self): # ARRANGE # section_contents = SectionContents([para('main contents')], []) footer_populator = SingleParaPopulator('footer contents') document_setup = sut.DocumentSetup('page title', footer_populator=footer_populator) # ACT # output_file = io.StringIO() DOCUMENT_RENDERER.apply(output_file, document_setup, section_contents) actual = output_file.getvalue() # ASSERT # expected = (DOCTYPE_XHTML1_0 + '<html>' '<head>' '<title>page title</title>' '</head>' '<body>' '<p>main contents</p>' '<p>footer contents</p>' '</body>' '</html>') self.assertEqual(expected, actual)
def _page_setup() -> doc_rendering.DocumentSetup: head_populator = page_setup.StylePopulator(page_setup.ELEMENT_STYLES) return doc_rendering.DocumentSetup( page_setup.PAGE_TITLE, head_populator=head_populator, header_populator=page_setup.HEADER_POPULATOR)