def assemble(self): home = self.define_view('/', title='Hello') home.set_page(HTML5Page.factory().use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots()))) home.set_slot('main', P.factory(text='Hello world')) home.set_slot('footer', P.factory(text='I am the footer'))
def page_layout_content_layout(fixture): """A PageLayout can be given a Layout it should use to lay out its contents Div.""" contents_layout = Layout() widget = HTML5Page(fixture.view).use_layout( PageLayout(contents_layout=contents_layout)) vassert(widget.layout.contents.layout is contents_layout)
def header_and_footer_slots(fixture): """PageLayout adds a Slot for Header and Footer.""" page = HTML5Page(fixture.view).use_layout(PageLayout()) header, contents_div, footer = page.layout.document.children vassert('header' in header.available_slots) vassert('footer' in footer.available_slots)
def test_page_layout_content_layout(web_fixture): """A PageLayout can be given a Layout it should use to lay out its contents Div.""" fixture = web_fixture contents_layout = Layout() widget = HTML5Page(fixture.view).use_layout( PageLayout(contents_layout=contents_layout)) assert widget.layout.contents.layout is contents_layout
def test_header_and_footer_slots(web_fixture): """PageLayout adds a Slot for Header and Footer.""" fixture = web_fixture page = HTML5Page(fixture.view).use_layout(PageLayout()) header, contents_div, footer = page.layout.document.children assert 'header' in header.available_slots assert 'footer' in footer.available_slots
def page_layout_basics(fixture): """A PageLayout adds a Div to the body of its page (the page's document), containing a header, footer with a div inbetween the two for page contents.""" layout = PageLayout() widget = HTML5Page(fixture.view).use_layout(layout) vassert([layout.document] == widget.body.children[:-1]) header, contents_div, footer = layout.document.children vassert(isinstance(header, Header)) vassert(isinstance(contents_div, Div)) vassert(isinstance(footer, Footer))
def test_page_layout_basics(web_fixture): """A PageLayout adds a Div to the body of its page (the page's document), containing a header, footer with a div inbetween the two for page contents.""" fixture = web_fixture layout = PageLayout() widget = HTML5Page(fixture.view).use_layout(layout) assert [layout.document] == widget.body.children[1:-1] header, contents_div, footer = layout.document.children assert isinstance(header, Header) assert isinstance(contents_div, Div) assert isinstance(footer, Footer)
def page_layout_convenience_features(fixture): """A PageLayout exposes useful methods to get to its contents, and adds ids to certain elements for convenience in CSS.""" layout = PageLayout() widget = HTML5Page(fixture.view).use_layout(layout) header, contents_div, footer = layout.document.children vassert(layout.document.css_id == 'doc') vassert(header.css_id == 'hd') vassert(footer.css_id == 'ft') vassert(contents_div.css_id == 'bd') vassert(contents_div.get_attribute('role') == 'main') vassert(layout.header is header) vassert(layout.contents is contents_div) vassert(layout.footer is footer)
def assemble(self): self.define_view('/', title='Hello', page=HTML5Page.factory().use_layout( fixture.MyLayout()))
def assemble(self): self.define_view( '/', title='Hello', page=HTML5Page.factory(use_layout=layout_for_widget))
def assemble(self): home = self.define_view('/', title='Hello') home.set_page(HTML5Page.factory().use_layout(BasicPageLayout())) home.set_slot('main', P.factory(text='Hello world')) home.set_slot('footer', P.factory(text='I am the footer'))