def test_dropdown_with_content_as_list_and_input_as_list_of_multiple_str_with_option_true( self): div = HtmlDiv() drop = div.dropdown('abc', ['A', 'B', 'C', 'D'], var_input=['B', 'C'], multiple=True) assert '<option value="B" selected="selected">B</option>' in str(drop) assert '<option value="C" selected="selected">C</option>' in str(drop)
def test_get_parent_form_3up(self): """test recursive search of form""" div = HtmlDiv() form = div.form(id_html="1level") div_1sub = form.div() div_2sub = div_1sub.div() div_3sub = div_2sub.div() assert div_3sub.get_form() == form
def test_constructor_without_valid_parentform(self, content_as_dicts): # if no form with an unique id is present, an error has to be raised div = HtmlDiv() rl = div.result_choice(content=content_as_dicts, listing_index='column_1', row_selected=None) with pytest.raises(Exception): rl.compose()
def test_dropdown_with_content_as_dict_and_optgroup(self): div = HtmlDiv() optgroups = {'AB': ['A', 'B'], 'CD': ['C', 'D']} drop = div.dropdown('abc', { 'A': 'Code A', 'B': 'Code B', 'C': 'Code C', 'D': 'Code D' }, optgroups=optgroups) assert '<option value="A">Code A</option>' in str(drop) assert '<option value="B">Code B</option>' in str(drop) assert '<option value="C">Code C</option>' in str(drop) assert '<option value="D">Code D</option>' in str(drop)
def test_checkbox_without_minimum_params(self): div = HtmlDiv() div.checkbox(name="check_test", value=1, label='label') assert '<input type="checkbox" name="check_test" value="1"/>' in str(div)
def test_textinput_with_class(self): div = HtmlDiv() div.textinput(name="test", var_input=123, class_html="my_class") assert 'my_class' in str(div)
def test_textinput_with_alignment(self): div = HtmlDiv() div.textinput(name="test", var_input=123, alignment="right") assert 'style="text-align: right"' in str(div)
def test_get_form_with_no_parent(self): div = HtmlDiv() assert div.get_form() is None
def test_dropdown_with_content_as_list(self): div = HtmlDiv() drop = div.dropdown('abc', ['A', 'B']) assert '<option value="A">A</option>' in str(drop) assert '<option value="B">B</option>' in str(drop)
def test_string_composition(self): div = HtmlDiv() assert str(div).startswith('<div>') # no blank in tag div = HtmlDiv(id_html='id') assert str(div).startswith('<div id="id">') # one blank in tag
def test_rendering_constructor_with_content_and_href(self): div = HtmlDiv() link = div.link("my_link", href="destination") assert str(link).replace("\n", "") == '<a href="destination" target="_blank">my_link</a>'
def test_constructor_with_id(self): id_name = "my_id" div = HtmlDiv(id_html=id_name) assert div.id_html == id_name assert 'id' in div.tag_content assert div.tag_content['id'] == id_name
def test_dropdown_with_content_as_dict(self): div = HtmlDiv() drop = div.dropdown('abc', {'A': 'Code A', 'B': 'Code B'}) assert '<option value="A">Code A</option>' in str(drop) assert '<option value="B">Code B</option>' in str(drop)
def test_dropdown_with_content_as_list_and_input_as_list_of_dicttype(self): div = HtmlDiv() request_dict = {'abc': 'B', 'def': 'A'} drop = div.dropdown('abc', ['A', 'B', 'C', 'D'], var_input=request_dict) assert '<option value="B" selected="selected">B</option>' in str(drop)
def test_dropdown_with_content_as_list_and_input_as_list_of_str(self): div = HtmlDiv() drop = div.dropdown('abc', ['A', 'B', 'C', 'D'], var_input=['B']) assert '<option value="B" selected="selected">B</option>' in str(drop)
def test_containter_return_added_objects(self): div = HtmlDiv() cell = HtmlCell() return_value = div.add(cell) assert cell == return_value
def test_containter_return_themselfs_if_string_added(self): div = HtmlDiv() return_value = div.add('abc') assert div == return_value
def test_rendering_constructor_with_only_content(self): div = HtmlDiv() link = div.link("my_link") assert str(link).replace("\n", "") == '<a href="my_link" target="_blank">my_link</a>'
def test_get_parent_form_1up(self): div = HtmlDiv() form = div.form(id_html="1level") div_sub = form.div() assert div_sub.get_form() == form
def test_rendering_with_forid(self): div = HtmlDiv() div.label(content="test", for_id="input_id") assert '<label for="input_id">test</label>' in str(div).replace( "\n", "")
def test_indents(self): div = HtmlDiv() div2 = HtmlDiv() div.add(div2)
def test_get_form_with_no_parent_form(self): div_outer = HtmlDiv('outer_div') div = div_outer.div() assert div.get_form() is None