def init_struct(self): self.node_list.extend([ components.Box(title='Edit note', node_list=[NoteForm(cid='note_form')]), components.Box(cid='notes_list_box', title='My notes tree', node_list=[ components.RecursiveTree( cid='notes_list', show_children=True, get_data='notes', disable_auto_update=True, data_interface={ 'id': None, 'label': 'title', 'show_children': None, 'icon_open': None, 'icon_close': None }) ]), components.LinkListLayout(cid="notes_link_list", slot='west', auto_update_children=True, show_pagination=False, show_search=False, get_data='notes', event_name='open_details', data_interface={ 'id': None, 'url': 'note/{id}', 'text': 'title' }) ])
def test_handle_click_label(page): page.root_node = components.RecursiveTree() page.handle_transaction() assert page.root_node.handle_click_label page.root_node.handle_click_label()
def test_handle_scroll(page): page.root_node = components.RecursiveTree() page.handle_transaction() page.root_node.handle_scroll(12345) assert page.root_node.scroll_position == 12345
class ExamplePage(epflpage.Page): model = ExampleModel root_node = components.RecursiveTree( get_data=['first', 'second', 'third'], data_interface=components.RecursiveTree.data_interface, )
def test_handle_click_icon(page): page.root_node = components.RecursiveTree() page.handle_transaction() old_show_children = page.root_node.show_children page.root_node.handle_click_icon() assert page.root_node.show_children is not old_show_children
class ExamplePageComplex(ExamplePage): root_node = components.RecursiveTree( get_data=['first', 'second', 'third'], data_interface=[ components.RecursiveTree.data_interface, components.RecursiveTree.data_interface, components.RecursiveTree.data_interface ])
class ExamplePage(epflpage.Page): """ By given 4 get_data elements and only one data_interface, it should be used for all 4. """ model = ExampleModel root_node = components.RecursiveTree( get_data=['first', 'second', 'third', 'fourth'], data_interface=components.RecursiveTree.data_interface, )
class ExamplePageComplex(ExamplePage): """ Mapping 4 get_data elements to 4 data_interface. """ root_node = components.RecursiveTree( get_data=['first', 'second', 'third', 'fourth'], data_interface=[ components.RecursiveTree.data_interface, components.RecursiveTree.data_interface, components.RecursiveTree.data_interface, components.RecursiveTree.data_interface, ] )
def test_label(page, bool_toggle): label = None if bool_toggle: label = 'some label' page.root_node = components.RecursiveTree(id=1, label=label) page.handle_transaction() if bool_toggle: assert '<span>some label (1)</span>' in page.root_node.render() else: assert '<span>some label (1)</span>' not in page.root_node.render()
def test_icon(page, bool_toggle): page.root_node = components.RecursiveTree( show_children=bool_toggle, icon_open='icon-open-class', icon_close='icon-close-class', ) page.handle_transaction() if bool_toggle: assert '<i class="fa fa-icon-close-class"></i>' in page.root_node.render() assert '<i class="fa fa-icon-open-class"></i>' not in page.root_node.render() else: assert '<i class="fa fa-icon-open-class"></i>' in page.root_node.render() assert '<i class="fa fa-icon-close-class"></i>' not in page.root_node.render()
def test_show_id(page, bool_toggle): show_id = False if bool_toggle: show_id = True page.root_node = components.RecursiveTree( id=1, label='some label', show_id=show_id, ) page.handle_transaction() if bool_toggle: assert '<span>some label (1)</span>' in page.root_node.render() else: assert '<span>some label</span>' in page.root_node.render()