Exemplo n.º 1
0
def test_layout_vertical(page):
    page.root_node = components.Upload(
        name="test_upload",
        label="test_upload_label",
        height="250",
        width="250",
        mandatory=True,
        layout_vertical=True,
    )
    page.handle_transaction()

    compo = page.root_node
    assert_outer_div(compo, height="250", width="250", mandatory=True)
    assert_file_input(compo, name="test_upload")
    assert_no_dropzone(compo)
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input")

    compo_html = etree.fromstring(compo.render())
    row_divs = compo_html.findall("div[@class='row']")
    assert len(row_divs) == 2, "not all row divs found in layout vertical"

    for row_div in row_divs:
        cols = row_div.findall("div")
        assert len(cols) == 1, "not all row divs have correct col divs"
        assert "col-sm-12" in cols[0].attrib.get("class",
                                                 None), "col divs wrong size"
Exemplo n.º 2
0
def test_change_dropzone_fileinput(page):
    page.root_node = components.Upload(name="test_upload",
                                       label="test_upload_label",
                                       height="250",
                                       width="250",
                                       show_drop_zone=True)
    page.handle_transaction()

    compo = page.root_node

    assert_outer_div(compo, height="250", width="250")
    assert_file_input(compo, name="test_upload")
    assert_dropzone(compo)
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input")

    compo.handle_change(IMAGE_BASE_64_BROWSER)
    compo.render_cache = None

    assert_image(compo, src=IMAGE_BASE_64_BROWSER)
    assert compo.get_value() == IMAGE_BASE_64_BROWSER, "Wrong Value"
    assert base64.b64encode(compo.get_as_binary(
    )) == IMAGE_BASE_64_SERVER, "get as binary wrong result"

    assert_remove_icon(compo)

    compo.handle_remove_icon()
    compo.render_cache = None

    assert_no_remove_icon(compo)
    assert_no_image(compo)

    assert compo.get_value() == None, "value not correct reseted"
    assert compo.get_as_binary() == None, "get as binary not correct reseted"
Exemplo n.º 3
0
def test_validation_error(page):
    page.root_node = components.Upload(
        name="test_upload",
        label="test_upload_label",
        height="250",
        width="250",
        mandatory=True,
        validation_error="AAHHH SOMETHING IS WRONG !!!")
    page.handle_transaction()

    compo = page.root_node
    assert_outer_div(compo, height="250", width="250", mandatory=True)
    assert_file_input(compo, name="test_upload")
    assert_no_dropzone(compo)
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input")

    compo_html = etree.fromstring(compo.render())
    error_div = compo_html.find("div")
    assert "has-error" in error_div.attrib.get(
        "class", None), "error class not set correct"

    error_text = compo_html.find(".//small")
    assert error_text.text == "AAHHH SOMETHING IS WRONG !!!", "error text is not correct"
    assert "help-block" in error_text.get("class",
                                          None), "wrong class in error text"
Exemplo n.º 4
0
def test_no_options(page):
    page.root_node = components.Upload()
    page.handle_transaction()

    compo = page.root_node

    assert_outer_div(compo)
    assert_file_input(compo)
    assert_no_label(compo)
    assert_no_dropzone(compo)
Exemplo n.º 5
0
def test_dropzone_simple(page):
    page.root_node = components.Upload(name="test_upload",
                                       label="test_upload_label",
                                       height="250",
                                       width="250",
                                       show_drop_zone=True)
    page.handle_transaction()

    compo = page.root_node

    assert_outer_div(compo, height="250", width="250")
    assert_file_input(compo)
    assert_dropzone(compo)
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input")
Exemplo n.º 6
0
def test_simple_options(page):
    page.root_node = components.Upload(
        name="test_upload",
        label="test_upload_label",
        height="250",
        width="250",
        mandatory=True,
        label_col=4,
    )
    page.handle_transaction()

    compo = page.root_node
    assert_outer_div(compo, height="250", width="250", mandatory=True)
    assert_file_input(compo, name="test_upload")
    assert_no_dropzone(compo)
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input",
                 label_col=4)
Exemplo n.º 7
0
def test_dropzone_with_options(page):
    page.root_node = components.Upload(
        name="test_upload",
        label="test_upload_label",
        height="250",
        width="250",
        show_drop_zone=True,
        plus_icon_size="lg",
        drop_zone_add_text="drop zone test text",
        drop_zone_add_position_top="1337")
    page.handle_transaction()

    compo = page.root_node

    assert_outer_div(compo, height="250", width="250")
    assert_file_input(compo, name="test_upload")
    assert_dropzone(compo,
                    drop_zone_add_position_top="1337",
                    drop_zone_add_text="drop zone test text")
    assert_label(compo,
                 label_text="test_upload_label",
                 label_for="root_node_input")