Ejemplo n.º 1
0
    def qmlink_to_rest(self, parent, artifacts):

        items = []
        header = ""

        req = len([a for a in artifacts if class_to_string(a) == 'rq'])
        reqg = len([a for a in artifacts if class_to_string(a) == 'rqg'])
        tcg = len([a for a in artifacts if class_to_string(a) == 'tcg'])
        tc = len([a for a in artifacts if class_to_string(a) == 'tc'])

        for a in artifacts:

            name = a.name
            items.append([class_to_string(a),
                          name,
                          writer.qmref(a.full_name)])

        # in the html, the title is adapted to the content of the table
        header = ("Requirements and Groups" if (req > 0 and reqg > 0) else
                  ("Requirements Group" if (req == 0 and reqg == 1) else
                   ("Requirements Groups" if (req == 0 and reqg > 1) else
                    ("Requirement" if (req == 1 and reqg == 0) else
                     ("Requirements" if (req > 1 and reqg == 0) else
                      ("Testcases and Groups" if (tc > 0 and tcg > 0) else
                       ("Testcases" if (tc > 0 and tcg == 0) else
                        ("Testcases Groups" if (tc == 0 and tcg > 0) else
                         ("")))))))))

        output = writer.csv_table(
            items,
            headers=["", "%s" % header, "Description"],
            widths=[3, 25, 65])

        return output, []
Ejemplo n.º 2
0
    def qmlink_to_rest(self, parent, artifacts):

        items = []
        html_top_index = ""

        for a in artifacts:

            items.append([writer.strong(a.name), writer.qmref(a.full_name)])

            if a.name == "Ada":

                def key(a):
                    d = {'stmt': 1, 'decision': 2, 'mcdc': 3}
                    for k in d:
                        if k in a.name:
                            return d[k]

                selected = [k for k in a.relatives if not is_source(k)]
                selected.sort(key=key)

            else:
                selected = a.relatives

            for suba in selected:
                items.append(
                    ["`..` %s" % suba.name,
                     writer.qmref(suba.full_name)])

        html_top_index += writer.csv_table(items,
                                           headers=["Chapter", "Description"],
                                           widths=[30, 70])

        output = writer.only(html_top_index, "html")

        links = [(a, qm.rest.DefaultImporter()) for a in artifacts
                 if "Index/.+" not in a.full_name]

        output += writer.toctree([
            '/%s/content' % artifact_hash(*l)
            for l in links if not is_tc_or_set(l[0])
        ],
                                 hidden=True)

        return output, links
Ejemplo n.º 3
0
def relative_links_for(artifact):
    """
    :param artifact: the artifact
    :type artifact: artifact
    """
    output = ""

    req = get_first_req_relative(artifact)
    if req:
        output += writer.paragraph(
            "**Parent Requirement**: %s\n\n" % writer.qmref(req.full_name))

    ancestor = artifact.relative_to
    if ancestor and ancestor != req:
        output += writer.paragraph(
            "**Parent %s**: %s\n\n" %
            (short_kind_of(ancestor), write_artifact_ref(ancestor.full_name)))

    return output
Ejemplo n.º 4
0
    def to_rest(self, artifact):

        reference = "\n\n.. _%s:\n" % artifact.full_name.replace('/', '_')[1:]

        result_pdf = '**TEST CASE**:  %s\n\n' % artifact.full_name
        result_html = '%s\n%s\n' % (artifact.full_name,
                                    '=' * len(artifact.full_name))

        result_pdf += qm.rest.DefaultImporter().to_rest(artifact) + '\n\n'
        result_html += qm.rest.DefaultImporter().to_rest(artifact) + '\n\n'

        result = reference + writer.only(result_pdf, "latex")
        result += writer.only(result_html, "html")

        self.log_missing_TR(artifact)

        # Create a navigation links from this TC up to its requirement
        # and group if any:

        result += relative_links_for(artifact)

        # Managing the list of the sources

        driver_list = []
        driver_list_qmref = []
        func_list = []
        func_list_qmref = []
        helper_list = []
        helper_list_qmref = []

        consolidation_list = []
        consolidation_list_qmref = []

        for item in self.get_sources(artifact):

            if is_consolidation(item):

                consolidation_list += [item.name]
                consolidation_list_qmref += [writer.qmref
                                             (item.full_name,
                                              item.name)]

                continue

            for key in item.contents_keys:
                if len(item.contents(key)) > 0:

                    for resource in item.contents(key):

                        if is_driver(resource):
                            driver_list += [resource.basename]
                            driver_list_qmref += [writer.qmref
                                                  (item.full_name,
                                                   resource.basename)]
                            continue

                        if is_functional(resource):
                            func_list += [resource.basename]
                            func_list_qmref += [writer.qmref
                                                (item.full_name,
                                                 resource.basename)]
                            continue

                        helper_list += [resource.basename]
                        helper_list_qmref += [writer.qmref
                                              (item.full_name,
                                               resource.basename)]

        driver_list.sort()
        driver_list_qmref.sort()
        func_list.sort()
        func_list_qmref.sort()
        helper_list.sort()
        helper_list_qmref.sort()

        headers = ["Functional Sources", "Drivers Sources", "Helpers Sources"]

        if consolidation_list:
            headers += ["Consolidation Sources"]
            consolidation_list.sort()
            consolidation_list_qmref.sort()

            for_table_qmref = izip_longest(func_list_qmref,
                                           driver_list_qmref,
                                           helper_list_qmref,
                                           consolidation_list_qmref,
                                           fillvalue="")

            for_table = izip_longest(func_list,
                                     driver_list,
                                     helper_list,
                                     consolidation_list,
                                     fillvalue="")
        else:
            for_table_qmref = izip_longest(func_list_qmref,
                                           driver_list_qmref,
                                           helper_list_qmref,
                                           fillvalue="")

            for_table = izip_longest(func_list,
                                     driver_list,
                                     helper_list,
                                     fillvalue="")

        html_content = writer.csv_table([k for k in for_table_qmref],
                                        headers)

        latex_content = writer.csv_table([k for k in for_table],
                                         headers).strip()

        result += writer.only(html_content, "html")

        # result += writer.only(latex_content, "latex")

        output = '\n\n' + writer.minipage(result, r'\linewidth') + "|\n\n"

        return output
Ejemplo n.º 5
0
    def qmlink_to_rest(self, parent, artifacts):

        html_items = []
        pdf_items = []
        output = ""

        for a in artifacts:
            # Don't put sources in the tables
            if is_source(a):
                continue

            if is_tc_or_set(a):
                reference = write_artifact_ref(a.full_name,
                                               get_short_description(a))

            html_items.append([writer.strong(class_to_string(a)),
                               writer.strong(a.name),
                               reference])
            pdf_items.append([class_to_string(a),
                              a.name,
                              reference])
            for suba in self.get_recursive_relatives(a, 1):
                # We do include in the table children artifacts only
                # in html format.

                if is_tc(suba):
                    subref = write_artifact_ref(suba.full_name,
                                                get_short_description(suba))

                if is_tcset(suba):
                    subref = writer.qmref(suba.full_name)

                html_items.append([class_to_string(suba),
                                   "`..` %s" % suba.name,
                                   subref])

        html_table = writer.csv_table(
            html_items,
            headers=["", "TestCases", "Description"],
            widths=[3, 25, 65])

        pdf_table = writer.csv_table(
            pdf_items,
            headers=["", "TestCases", "Description"],
            widths=[3, 25, 65]).strip()

        output += writer.only(html_table, "html")
        output += writer.only(pdf_table, "latex").strip()
        output += "\n\n"

        links = []
        for a in artifacts:
            if is_tc(a):
                links.append((a, TestCaseImporter()))
            elif is_source(a):
                pass
            else:
                links.append((a, default_importer(a)))

        output += writer.toctree(
            ['/%s/content' % artifact_hash(*l)
             for l in links
             if not is_tc_or_set(l[0]) or is_tc_or_set(parent)],
            hidden=True)

        return output, links