示例#1
0
    def qmlink_to_rest(self, parent, artifacts):

        self.items = []

        def sortkey_for(art):
            
            # Arrange for stmt requirements to come first, before decision and
            # mcdc. Work from locations, which contain the explicit ordering
            # requests in the names (numeric prefixes like 1_).
            
            return str(art.location).replace("/stmt", "/a")
            
        artifacts.sort(key=sortkey_for)
        
        for art in artifacts:
            self.handle(art=art, depth=0)

        pdf_table = writer.csv_table(
            self.items,
            headers=["Kind", "Identification", "Description"],
            latex_format=\
            '|p{0.05\linewidth}|p{0.47\linewidth}||p{0.37\linewidth}|')

        html_table = writer.csv_table(
            self.items,
            headers=["Kind", "Ref"],
            widths=[5, 47, 37])

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

        output += "\n\n"

        return output, []
示例#2
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, []
示例#3
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
示例#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
示例#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
示例#6
0
    def qmlink_to_rest(self, parent, artifacts):
        """
        Returns a matrix of traceability between
        lrm section artifact and thi associated test cases
        and requirements.
        chosen format was dicussed in MB23-001.

        :param parent: the artifact calling the qmlink
        :type parent: artifact
        :param artifacts: the list of artifacts listed in qmlink
        :type artifacts: list of artifacts
        """
        REQ_NAME_PREFIX = "/TOR/Ada"
        pdf_items = []
        html_items = []
        output = ""
        language_version = None

        for a in artifacts:
            if is_lrm_section(a):

                if not language_version:
                    language_version = a.attributes['language'].strip()

                ref = {}
                for children in a.derived_to:
                    for child in children.all:
                        if is_tc(child):
                            parent = get_first_req_relative(child).full_name

                            if parent not in ref.keys():
                                ref[parent] = []

                            ref[parent].append([child.full_name,
                                                child.full_name.replace(
                                                    parent, '')])

                pdf_tc_list = ""
                html_tc_list = ""
                pdf_comment = ""
                html_comment = ""

                for req in ref.keys():

                    pdf_other_tcs = ""
                    html_tcs = ""

                    if len(ref[req]) > 1:
                        pdf_other_tcs = "%s + %d other tests" % \
                            (writer.role("raw-latex", r'\newline'),
                             (len(ref[req]) - 1))

                    html_tcs = writer.role("raw-html", r'<br>').join(
                        [write_artifact_ref(k[0],
                                            label=k[1]) for k in ref[req]])

                    requirement_str = "Req: %s" %  \
                        write_artifact_ref(req,
                                           req.replace(REQ_NAME_PREFIX,
                                                       '')).strip()
                    first_tc_str = "* TC: %s" % \
                        write_artifact_ref(ref[req][0][0],
                                           label=ref[req][0][1]).strip()

                    pdf_tc_list += "%s %s %s %s %s " % (
                        requirement_str,
                        writer.role("raw-latex", r'\newline'),
                        first_tc_str,
                        pdf_other_tcs,
                        writer.role("raw-latex", r'\newline'))

                    html_tc_list += "%s %s  * TC: %s %s " % (
                        requirement_str,
                        writer.role("raw-html", r'<br>'),
                        html_tcs,
                        writer.role("raw-html", r'<br>'))

                applicable = a.attributes['relevance'].strip()
                if pdf_tc_list != "":
                    if applicable == "no" or applicable == "partial":
                        relevance = applicable
                        comment = a.attributes['comment'].strip()

                        pdf_comment = comment + ' ' + \
                            writer.role("raw-latex", r'\newline') + ' '
                        html_comment = comment + ' ' + \
                            writer.role("raw-html", r'<br>') + ' '

                    elif applicable == "yes":
                        relevance = "yes"
                    elif applicable == "no*":
                        relevance = "no"
                        comment = "Section does not require SCA-related " + \
                            "tests, but some are supplied "

                        pdf_comment = comment + \
                            writer.role("raw-latex", r'\newline') + ' '
                        html_comment = comment +  \
                            writer.role("raw-html", r'<br>') + ' '
                    else:
                        relevance = "unexpected value %s" % applicable

                    if relevance != "no":
                        # when applicable is set to no, the list of
                        # tc must be ommitted.
                        # otherwise it is added to the comment column
                        # see N102-011  Feb 8, 2014
                        pdf_comment += pdf_tc_list
                        html_comment += html_tc_list

                else:
                    if applicable == "no":
                        relevance = "no"
                        comment = a.attributes['comment'].strip()

                        pdf_comment = comment
                        html_comment = comment + ' ' + \
                            writer.role("raw-html", r'<br>') + ' '

                    elif applicable == "partial":
                        relevance = "PARTIAL but not covered"
                        comment = a.attributes['comment'].strip()

                        pdf_comment = comment
                        html_comment = comment + ' ' + \
                            writer.role("raw-html", r'<br>') + ' '

                    elif applicable == "yes":
                        relevance = "YES but not covered"
                    elif applicable == "no*":
                        relevance = "NO but"
                        comment = "Indicated as no* in matrix." + \
                            " Some test should be provided."

                        pdf_comment = comment
                        html_comment = comment + ' '

                    else:
                        relevance = "unexpected value %s" % applicable

                pdf_items.append(["%s" % a.full_name.replace('/', ''),
                                  a.attributes['title'].strip(),
                                  relevance,
                                  pdf_comment])

                html_items.append(["%s" % a.full_name.replace('/', ''),
                                   a.attributes['title'].strip(),
                                   relevance,
                                   html_comment])

        pdf_table = writer.csv_table(
            pdf_items,
            title="TOR/LRM Traceability Matrix for Ada %s" % language_version,
            headers=["Section", "Title", "Applicable", "Comment"],
            latex_format='|p{0.08\linewidth}|p{0.20\linewidth}|' +
            'p{0.10\linewidth}|p{0.50\linewidth}|')

        html_table = writer.csv_table(
            html_items,
            headers=["Section", "Title", "Applicable", "Comment"],
            widths=[8, 20, 10, 50])

        output += writer.paragraph(
            "This particular table is established for **Ada %s**." %
            language_version +
            "\n\The requirement identifiers in this table were shortened by "
            "removing the *%s* common prefix.\n\n" % REQ_NAME_PREFIX) + \
            writer.only(pdf_table, "latex") + \
            writer.only(html_table, "html")

        output += "\n\n"

        return output, []