def test_grid_template_override(): item = Markdown("First") override = Markdown("Second") template = ReactTemplate() template.main[0, 0] = item template.main[0, 0] = override objs = list(template._render_items.values())[3:] assert len(objs) == 1 ((obj, tags),) = objs assert obj.object == "Second" assert tags == ['main']
def test_react_template(document, comm): tmplt = ReactTemplate(title='BasicTemplate', header_background='blue', header_color='red') tvars = tmplt._render_variables assert tvars['app_title'] == 'BasicTemplate' assert tvars['header_background'] == 'blue' assert tvars['header_color'] == 'red' assert tvars['nav'] == False assert tvars['busy'] == True assert tvars['header'] == False assert tvars['rowHeight'] == tmplt.row_height assert tvars['breakpoints'] == tmplt.breakpoints assert tvars['cols'] == tmplt.cols markdown = Markdown('# Some title') tmplt.main[:4, :6] = markdown markdown2 = Markdown('# Some title') tmplt.main[:4, 6:] = markdown2 assert tvars['layouts'] == { 'lg': [{ 'h': 4, 'i': '1', 'w': 6, 'x': 0, 'y': 0 }, { 'h': 4, 'i': '2', 'w': 6, 'x': 6, 'y': 0 }], 'md': [{ 'h': 4, 'i': '1', 'w': 6, 'x': 0, 'y': 0 }, { 'h': 4, 'i': '2', 'w': 6, 'x': 6, 'y': 0 }] }
def test_constructor_grid_spec(): item = Markdown("Hello World") grid = GridSpec(ncols=12) grid[0:2, 3:4]=item ReactTemplate(main=grid)