def test_lookup_method_id_id_value(app, status, warning):
    app.builder.build_all()
    # parse test case document builds
    one_tree = xmlparse_testcase(app.outdir, "test_0001", "xmlexport")
    two_tree = xmlparse_testcase(app.outdir, "test_0002", "xmlexport")
    # check test case id values (generated based on doc name)
    assert one_tree.xpath('/testcases/testcase/@id') == ["0001"]
    assert two_tree.xpath('/testcases/testcase/@id') == ["0002"]
def test_lookup_method_id_id_value_missing(app, status, warning):
    app.builder.build_all()
    # parse test case document builds
    none_tree = xmlparse_testcase(app.outdir, "test_none", "xmlexport")
    noid_tree = xmlparse_testcase(app.outdir, "test_noid", "xmlexport")
    # check test case id values (generated based on doc name)
    assert none_tree.xpath('/testcases/testcase/@id') == []
    assert noid_tree.xpath('/testcases/testcase/@id') == []
Exemplo n.º 3
0
def test_xml_schema_validation(app, status, warning, xml_schema):
    app.builder.build_all()
    # parse test case document builds
    bar_tree = xmlparse_testcase(app.outdir, "test_bar", "xmlexport")
    baz_tree = xmlparse_testcase(app.outdir, "test_baz", "xmlexport")
    # validate the xml documents
    assert xml_schema.validate(bar_tree)
    assert xml_schema.validate(baz_tree)
def test_lookup_method_id_removal_of_id_field(app, status, warning):
    app.builder.build_all()
    # parse test case document builds
    one_tree = xmlparse_testcase(app.outdir, "test_0001", "xmlexport")
    two_tree = xmlparse_testcase(app.outdir, "test_0002", "xmlexport")
    # check that there is no id in custom field list (test case metadata)
    for tree in (one_tree, two_tree):
        val_xp = "/testcases/testcase/custom-fields/custom-field[@id='id']"
        assert tree.xpath(val_xp) == []
def test_lookup_method_id_properties(app, status, warning):
    app.builder.build_all()
    # parse test case document builds
    one_tree = xmlparse_testcase(app.outdir, "test_0001", "xmlexport")
    two_tree = xmlparse_testcase(app.outdir, "test_0002", "xmlexport")
    none_tree = xmlparse_testcase(app.outdir, "test_none", "xmlexport")
    noid_tree = xmlparse_testcase(app.outdir, "test_noid", "xmlexport")
    # check that properties are set as expected
    for tree in (one_tree, two_tree, noid_tree, none_tree):
        val_xp = "/testcases/properties/property[@name='lookup-method']/@value"
        assert tree.xpath(val_xp) == ["id"]
def test_lookup_method_custom_properties(app, status, warning, testroot):
    app.builder.build_all()
    # parse test case document builds
    foo_tree = xmlparse_testcase(app.outdir, "test_foo", "xmlexport")
    bar_tree = xmlparse_testcase(app.outdir, "test_bar", "xmlexport")
    one_tree = xmlparse_testcase(app.outdir, "foo/bar/test_one", "xmlexport")
    two_tree = xmlparse_testcase(app.outdir, "foo/bar/test_two", "xmlexport")
    # check that properties are set as expected
    for tree in (foo_tree, bar_tree, one_tree, two_tree):
        val_xp = "/testcases/properties/property[@name='lookup-method']/@value"
        assert tree.xpath(val_xp) == ["custom"]
def test_lookup_method_custom_id_value(app, status, warning, testroot):
    app.builder.build_all()
    # parse test case document builds
    foo_tree = xmlparse_testcase(app.outdir, "test_foo", "xmlexport")
    bar_tree = xmlparse_testcase(app.outdir, "test_bar", "xmlexport")
    one_tree = xmlparse_testcase(app.outdir, "foo/bar/test_one", "xmlexport")
    two_tree = xmlparse_testcase(app.outdir, "foo/bar/test_two", "xmlexport")
    # check test case id values (generated based on doc name)
    assert foo_tree.xpath('/testcases/testcase/@id') == ["/test_foo"]
    assert bar_tree.xpath('/testcases/testcase/@id') == ["/test_bar"]
    assert one_tree.xpath('/testcases/testcase/@id') == ["/foo/bar/test_one"]
    assert two_tree.xpath('/testcases/testcase/@id') == ["/foo/bar/test_two"]
def test_lookup_method_id_custom_hybrid(app, status, warning):
    app.builder.build_all()
    # parse test case document builds
    one_tree = xmlparse_testcase(app.outdir, "test_0001", "xmlexport")
    noid_tree = xmlparse_testcase(app.outdir, "test_noid", "xmlexport")
    # check test case id values (generated based on doc name)
    assert one_tree.xpath('/testcases/testcase/@id') == ["0001"]
    assert noid_tree.xpath('/testcases/testcase/@id') == ["/test_noid"]
    # check that properties are set as expected
    val_xp = "/testcases/properties/property[@name='lookup-method']/@value"
    assert one_tree.xpath(val_xp) == ["id"]
    assert noid_tree.xpath(val_xp) == ["custom"]
Exemplo n.º 9
0
def test_testcasemetadata_html_nested_multiple(app, status, warning, builder):
    app.builder.build_all()
    # get metadata
    one_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "foo/test_one", builder), builder)
    ten_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "foo/bar/test_ten", builder), builder)
    # check metadata defined in test_defaults of root index.rst file
    assert ('note', 'test') in one_meta
    assert ('note', 'test') in ten_meta
    # check metadata defined in test_defaults of foo/index.rst file
    assert ('component', 'foo') in one_meta
    assert ('component', 'foo') in ten_meta
    # check metadata defined in test_defaults of foo/bar/index.rst file
    assert ('subcomponent', 'bar') in ten_meta
Exemplo n.º 10
0
def test_requirementlist_present_testdefaults_html(app, status, warning):
    """
    Check that all requirements can be specified via testdefaults directive.
    """
    app.builder.build_all()
    # parse requirements overview document
    doc_tree = xmlparse_testcase(app.outdir, "requirements", "html")
    # get the requirement list (list of <li> elements)
    req_list = get_requirements_from_build(doc_tree, "html")
    # check that the list contains all requirements, in given order
    req_items = [i.text for i in req_list]
    req_items_expected = sorted([
        "FOO-ALL",
        "FOO-001",
        "FOO-002",
        ])
    assert req_items == req_items_expected
    # get test cases covering requirement FOO-ALL
    fooall_item = [i for i in req_list if i.text == "FOO-ALL"][0]
    fooall_case_list = fooall_item.xpath('h:ul/h:li', namespaces=NS)
    # check that all test cases are listed under FOO-ALL, in given order
    fooall_case_items = [''.join(i.itertext()) for i in fooall_case_list]
    fooall_case_items_expected = sorted([
        "/baz/test_one",
        "/baz/test_two",
        ])
    assert fooall_case_items == fooall_case_items_expected
Exemplo n.º 11
0
def test_testcasemetadata_html_flat_override(app, status, warning, builder):
    """
    Check that values from test_defaults directive can override
    values specified directly in a test case.
    """
    app.builder.build_all()
    # get metadata
    foo_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "test_foo", builder), builder)
    bar_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "test_bar", builder), builder)
    # check metadata overriden by testdefaults directive,
    # in index.rst file, we set/override 'component' to value 'actium'
    for meta in foo_meta, bar_meta:
        comp_list = [val for (key, val) in meta if key == 'component']
        assert len(comp_list) == 1
        assert comp_list[0] == 'actium'
Exemplo n.º 12
0
def test_testcasemetadata_html_flat(app, status, warning, builder):
    app.builder.build_all()
    # parse test case document builds
    foo_tree = xmlparse_testcase(app.outdir, "test_foo", builder)
    bar_tree = xmlparse_testcase(app.outdir, "test_bar", builder)
    # get metadata
    foo_meta = get_metadata_from_build(foo_tree, builder)
    bar_meta = get_metadata_from_build(bar_tree, builder)
    # check metadata directly included in the files
    assert ('author', '*****@*****.**') in foo_meta
    assert ('author', '*****@*****.**') in bar_meta
    # check metadata added by test_defaults directive (in index.rst file)
    assert ('component', 'foobar') in foo_meta
    assert ('importance', 'high') in foo_meta
    assert ('component', 'foobar') in bar_meta
    assert ('importance', 'high') in bar_meta
    # there are no other metadata
    assert len(foo_meta) == 3
    assert len(bar_meta) == 3
Exemplo n.º 13
0
def test_testcasemetadata_html_nested_multiple_override(
        app, status, warning, builder):
    app.builder.build_all()
    # get metadata
    two_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "foo/test_two", builder), builder)
    ten_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "foo/bar/test_ten", builder), builder)
    elewen_meta = get_metadata_from_build(
        xmlparse_testcase(app.outdir, "foo/bar/test_elewen", builder), builder)
    # check metadata defined both in test_defaults of root index.rst file and
    # the test case itself, default value should be used
    assert ('note', 'test') in two_meta
    # check metadata defined both in test_defaults of bar's index.rst file and
    # the test case itself, default value should be used
    assert ('subcomponent', 'bar') in elewen_meta
    # check metadata defined both in test_defaults of bar's and foo's index.rst
    # file default value from foo's index.rst file should be used
    assert ('type', 'functional') in ten_meta
    assert ('type', 'functional') in elewen_meta
Exemplo n.º 14
0
def test_testcasemetadata_html_nested(app, status, warning, builder):
    """
    Given 2 directories with test cases (foo and bar), check that
    all test cases inside has component metadata value set properly,
    as defined in index.rst file (via test_defaults directive).
    """
    app.builder.build_all()
    for tc_name in ("foo/test_one", "foo/test_two", "bar/test_ten",
                    "bar/test_elewen"):
        meta = get_metadata_from_build(
            xmlparse_testcase(app.outdir, tc_name, builder), builder)
        component = tc_name.split("/")[0]
        assert ("component", component) in meta
Exemplo n.º 15
0
def test_requirementlist_url_flat_html(app, status, warning):
    """
    Check that url or rhbz role can be used as a requirement.
    """
    app.builder.build_all()
    # parse requirements overview document
    doc_tree = xmlparse_testcase(app.outdir, "requirements", "html")
    # get the requirement list (list of <li> elements)
    req_list = get_requirements_from_build(doc_tree, "html")
    # TODO: check that the requirements are represented via links
    req_links = [i.xpath('h:a', namespaces=NS) for i in req_list]
    assert len(req_links) == 2
    assert len(req_links[0]) == 1
    assert len(req_links[1]) == 1
Exemplo n.º 16
0
def test_requirementlist_caselinking_nested_html(app, status, warning):
    app.builder.build_all()
    # parse requirements overview document
    doc_tree = xmlparse_testcase(
        app.outdir, "requirements/requirements", "html")
    # get the requirement list
    req_list = get_requirements_from_build(doc_tree, "html")
    # get references/links of test cases covering requirement FOO-111
    req_item = [i for i in req_list if i.text == "FOO-111"][0]
    case_ref_list = req_item.xpath('h:ul/h:li/h:a', namespaces=NS)
    # there should be just one such requirement
    assert len(case_ref_list) == 1
    # and it should link to /baz/test_one document correctly (wrt the location
    # of document with the requirementlist directive)
    case_ref = case_ref_list[0]
    assert case_ref.get('href') == "../baz/test_one.html"