Exemplo n.º 1
0
def render_test_report_standalone(serialno,
                                  devicetype,
                                  suites,
                                  outfolder=None):

    if serialno is None:
        raise TypeError("serialno cannot be None")

    if devicetype is None:
        raise TypeError("devicetype cannot be None")

    if suites is None:
        raise TypeError("suites cannot be None")

    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')

    template = os.path.join('testing', 'test_report_template.tex')
    outpath = os.path.join(outfolder, 'TEST-REPORT-' + serialno + '.pdf')

    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    graphs = []
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            graphs.extend(test.graphs)
            graphs.extend(test.histograms)
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {
        'suites': [x.render_dox() for x in suites],
        'sno': serialno,
        'testdate': max([x.ts for x in suites]).format(),
        'devicetype': devicetype,
        'desc': gcf.description(devicetype),
        'svnrevision': vcs.get_path_revision(projectfolder),
        'svnrepo': vcs.get_path_repository(projectfolder),
        'graphs': graphs,
        'instruments': instruments
    }

    return render_pdf(stage, template, outpath)
Exemplo n.º 2
0
def render_test_report_standalone(serialno, devicetype, suites, outfolder=None):

    if serialno is None:
        raise TypeError("serialno cannot be None")

    if devicetype is None:
        raise TypeError("devicetype cannot be None")

    if suites is None:
        raise TypeError("suites cannot be None")

    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')

    template = os.path.join('testing', 'test_report_template.tex')
    outpath = os.path.join(outfolder,
                           'TEST-REPORT-' + serialno + '.pdf')

    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    graphs = []
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            graphs.extend(test.graphs)
            graphs.extend(test.histograms)
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {'suites': [x.render_dox() for x in suites],
             'sno': serialno,
             'testdate': max([x.ts for x in suites]).format(),
             'devicetype': devicetype,
             'desc': gcf.description(devicetype),
             'svnrevision': vcs.get_path_revision(projectfolder),
             'svnrepo': vcs.get_path_repository(projectfolder),
             'graphs': graphs,
             'instruments': instruments
             }

    return render_pdf(stage, template, outpath)
Exemplo n.º 3
0
def render_test_report(serialno=None, outfolder=None, session=None):
    """
    Renders the latest test results marked against the specified ``serialno``.

    Since this function is defined against the database, all arguments should
    be keyword arguments.

    :param serialno: The serial number of the device.
    :type serialno: :class:`str` or :class:`tendril.entityhub.db.SerialNumber`
    :param outfolder: The folder in which the output file should be created.
    :type outfolder: str
    :param session: The database session. If None, the function will make
                    it's own.
    :return: The output file path.

    .. rubric:: Template Used

    ``tendril/dox/templates/testing/test_report_template.tex``
    (:download:`Included version
    <../../tendril/dox/templates/testing/test_report_template.tex>`)

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``sno``
          - Serial number of the device.
        * - ``testdate``
          - The timestamp of the latest test suite.
        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being a list of tuples of
            (graphpath, graphtitle)
        * - ``instruments``
          - A list of instrument ident strings, one for each unique
            instrument used in the suites.
        * - ``suites``
          - A list of instances of
            :class:`tendril.testing.testbase.TestSuiteBase` or its subclasses.

    Note that the ``suites`` provided to the template are typically
    expected to be offline test suites which are reconstructed from the
    database.

    .. seealso:: :func:`tendril.testing.analysis.get_test_suite_objects`

    """
    if serialno is None:
        raise ValueError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = sno_controller.get_serialno_object(sno=serialno,
                                                      session=session)
    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')

    template = os.path.join('testing', 'test_report_template.tex')
    outpath = os.path.join(outfolder,
                           'TEST-REPORT-' + serialno.sno + '.pdf')

    devicetype = serialnos.get_serialno_efield(sno=serialno.sno,
                                               session=session)
    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    suites = analysis.get_test_suite_objects(serialno=serialno.sno,
                                             session=session)
    graphs = []
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            graphs.extend(test.graphs)
            graphs.extend(test.histograms)
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {'suites': [x.render_dox() for x in suites],
             'sno': serialno.sno,
             'testdate': max([x.ts for x in suites]).format(),
             'devicetype': devicetype,
             'desc': gcf.description(devicetype),
             'svnrevision': vcs.get_path_revision(projectfolder),
             'svnrepo': vcs.get_path_repository(projectfolder),
             'graphs': graphs,
             'instruments': instruments
             }

    return render_pdf(stage, template, outpath)
Exemplo n.º 4
0
def render_device_summary(devicetype, include_failed=False, outfolder=None):
    """
    Renders a summary of all of the latest test results marked against the
    serial numbers of the specified ``devicetype``.

    :param devicetype: The type of device for which a summary is desired.
    :type devicetype: str
    :param outfolder: The folder in which the output file should be created.
    :type outfolder: str
    :param include_failed: Whether failed test results should be included in
                      the graphs and the statistical analysis. Default False.
    :type include_failed: bool
    :return: The output file path.

    .. rubric:: Template Used

    ``tendril/dox/templates/testing/test_device_summary_template.tex``
    (:download:`Included version
    <../../tendril/dox/templates/testing/test_device_summary_template.tex>`)

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being a list of tuples of
            (graphpath, graphtitle)
        * - ``collector``
          - An instance of :class:`tendril.testing.analysis.ResultCollector`,
            containing the collated test results.

    .. seealso:: :func:`tendril.testing.analysis.get_device_test_summary`

    """
    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')
    template = os.path.join('testing', 'test_device_summary_template.tex')
    outpath = os.path.join(outfolder,
                           'TEST-DEVICE-SUMMARY-' + devicetype + '.pdf')

    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    summary = analysis.get_device_test_summary(devicetype=devicetype,
                                               include_failed=include_failed)
    graphs = summary.graphs

    stage = {'devicetype': devicetype,
             'desc': gcf.description(devicetype),
             'svnrevision': vcs.get_path_revision(projectfolder),
             'svnrepo': vcs.get_path_repository(projectfolder),
             'graphs': graphs,
             'collector': summary
             }

    return render_pdf(stage, template, outpath)
Exemplo n.º 5
0
def render_test_report(serialno=None, outfolder=None, session=None):
    """
    Renders the latest test results marked against the specified ``serialno``.

    Since this function is defined against the database, all arguments should
    be keyword arguments.

    :param serialno: The serial number of the device.
    :type serialno: :class:`str` or :class:`tendril.entityhub.db.SerialNumber`
    :param outfolder: The folder in which the output file should be created.
    :type outfolder: str
    :param session: The database session. If None, the function will make
                    it's own.
    :return: The output file path.

    .. rubric:: Template Used

    ``tendril/dox/templates/testing/test_report_template.tex``
    (:download:`Included version
    <../../tendril/dox/templates/testing/test_report_template.tex>`)

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``sno``
          - Serial number of the device.
        * - ``testdate``
          - The timestamp of the latest test suite.
        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being a list of tuples of
            (graphpath, graphtitle)
        * - ``instruments``
          - A list of instrument ident strings, one for each unique
            instrument used in the suites.
        * - ``suites``
          - A list of instances of
            :class:`tendril.testing.testbase.TestSuiteBase` or its subclasses.

    Note that the ``suites`` provided to the template are typically
    expected to be offline test suites which are reconstructed from the
    database.

    .. seealso:: :func:`tendril.testing.analysis.get_test_suite_objects`

    """
    if serialno is None:
        raise ValueError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = sno_controller.get_serialno_object(sno=serialno,
                                                      session=session)
    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')

    template = os.path.join('testing', 'test_report_template.tex')
    outpath = os.path.join(outfolder, 'TEST-REPORT-' + serialno.sno + '.pdf')

    devicetype = serialnos.get_serialno_efield(sno=serialno.sno,
                                               session=session)
    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    suites = analysis.get_test_suite_objects(serialno=serialno.sno,
                                             session=session)
    graphs = []
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            graphs.extend(test.graphs)
            graphs.extend(test.histograms)
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {
        'suites': [x.render_dox() for x in suites],
        'sno': serialno.sno,
        'testdate': max([x.ts for x in suites]).format(),
        'devicetype': devicetype,
        'desc': gcf.description(devicetype),
        'svnrevision': vcs.get_path_revision(projectfolder),
        'svnrepo': vcs.get_path_repository(projectfolder),
        'graphs': graphs,
        'instruments': instruments
    }

    return render_pdf(stage, template, outpath)
Exemplo n.º 6
0
def render_device_summary(devicetype, include_failed=False, outfolder=None):
    """
    Renders a summary of all of the latest test results marked against the
    serial numbers of the specified ``devicetype``.

    :param devicetype: The type of device for which a summary is desired.
    :type devicetype: str
    :param outfolder: The folder in which the output file should be created.
    :type outfolder: str
    :param include_failed: Whether failed test results should be included in
                      the graphs and the statistical analysis. Default False.
    :type include_failed: bool
    :return: The output file path.

    .. rubric:: Template Used

    ``tendril/dox/templates/testing/test_device_summary_template.tex``
    (:download:`Included version
    <../../tendril/dox/templates/testing/test_device_summary_template.tex>`)

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being a list of tuples of
            (graphpath, graphtitle)
        * - ``collector``
          - An instance of :class:`tendril.testing.analysis.ResultCollector`,
            containing the collated test results.

    .. seealso:: :func:`tendril.testing.analysis.get_device_test_summary`

    """
    if outfolder is None:
        outfolder = os.path.join(INSTANCE_ROOT, 'scratch', 'testing')
    template = os.path.join('testing', 'test_device_summary_template.tex')
    outpath = os.path.join(outfolder,
                           'TEST-DEVICE-SUMMARY-' + devicetype + '.pdf')

    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    summary = analysis.get_device_test_summary(devicetype=devicetype,
                                               include_failed=include_failed)
    graphs = summary.graphs

    stage = {
        'devicetype': devicetype,
        'desc': gcf.description(devicetype),
        'svnrevision': vcs.get_path_revision(projectfolder),
        'svnrepo': vcs.get_path_repository(projectfolder),
        'graphs': graphs,
        'collector': summary
    }

    return render_pdf(stage, template, outpath)
Exemplo n.º 7
0
def get_test_report(serialno=None, session=None):
    """
    Constructs and returns the stage components for the latest test results
    marked against the specified ``serialno``.

    Since this function is defined against the database, all arguments should
    be keyword arguments.

    :param serialno: The serial number of the device.
    :type serialno: :class:`str` or :class:`tendril.entityhub.db.SerialNumber`
    :param session: The database session. If None, the function will make
                    it's own.
    :return: The output file path.

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``sno``
          - Serial number of the device.
        * - ``testdate``
          - The timestamp of the latest test suite.
        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being the htmlcontent generated
            by python-nvd3.
        * - ``instruments``
          - A list of instrument ident strings, one for each unique
            instrument used in the suites.
        * - ``suites``
          - A list of instances of
            :class:`tendril.testing.testbase.TestSuiteBase` or its subclasses.

    Note that the ``suites`` provided to the template are typically
    expected to be offline test suites which are reconstructed from the
    database.

    .. seealso:: :func:`tendril.testing.analysis.get_test_suite_objects`

    .. todo:: Move this function into :mod:`tendril.testing.analysis` and
              have :func:`tendril.dox.testing.render_test_report` use the
              same infrastructure.

    """
    if serialno is None:
        raise ValueError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = sno_controller.get_serialno_object(sno=serialno,
                                                      session=session)

    devicetype = serialnos.get_serialno_efield(sno=serialno.sno,
                                               session=session)
    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    suites = analysis.get_test_suite_objects(serialno=serialno.sno,
                                             session=session)
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {
        'suites': [x.render_dox() for x in suites],
        'sno': serialno.sno,
        'testdate': max([x.ts for x in suites]).format(),
        'devicetype': devicetype,
        'desc': gcf.description(devicetype),
        'svnrevision': vcs.get_path_revision(projectfolder),
        'svnrepo': vcs.get_path_repository(projectfolder),
        'instruments': instruments
    }

    return stage
Exemplo n.º 8
0
def get_test_report(serialno=None, session=None):
    """
    Constructs and returns the stage components for the latest test results
    marked against the specified ``serialno``.

    Since this function is defined against the database, all arguments should
    be keyword arguments.

    :param serialno: The serial number of the device.
    :type serialno: :class:`str` or :class:`tendril.entityhub.db.SerialNumber`
    :param session: The database session. If None, the function will make
                    it's own.
    :return: The output file path.

    .. rubric:: Stage Keys Provided
    .. list-table::

        * - ``sno``
          - Serial number of the device.
        * - ``testdate``
          - The timestamp of the latest test suite.
        * - ``devicetype``
          - The device type.
        * - ``desc``
          - The device description.
        * - ``svnrevision``
          - The VCS revision of the project config file.
        * - ``svnrepo``
          - The VCS repository containing the project
        * - ``graphs``
          - A list of graphs, each graph being the htmlcontent generated
            by python-nvd3.
        * - ``instruments``
          - A list of instrument ident strings, one for each unique
            instrument used in the suites.
        * - ``suites``
          - A list of instances of
            :class:`tendril.testing.testbase.TestSuiteBase` or its subclasses.

    Note that the ``suites`` provided to the template are typically
    expected to be offline test suites which are reconstructed from the
    database.

    .. seealso:: :func:`tendril.testing.analysis.get_test_suite_objects`

    .. todo:: Move this function into :mod:`tendril.testing.analysis` and
              have :func:`tendril.dox.testing.render_test_report` use the
              same infrastructure.

    """
    if serialno is None:
        raise ValueError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = sno_controller.get_serialno_object(sno=serialno,
                                                      session=session)

    devicetype = serialnos.get_serialno_efield(sno=serialno.sno,
                                               session=session)
    projectfolder = projects.cards[devicetype]
    gcf = ConfigsFile(projectfolder)

    suites = analysis.get_test_suite_objects(serialno=serialno.sno,
                                             session=session)
    instruments = {}
    for suite in suites:
        for test in suite._tests:
            if test._inststr is not None and \
                    test._inststr not in instruments.keys():
                instruments[test._inststr] = len(instruments.keys()) + 1

    stage = {'suites': [x.render_dox() for x in suites],
             'sno': serialno.sno,
             'testdate': max([x.ts for x in suites]).format(),
             'devicetype': devicetype,
             'desc': gcf.description(devicetype),
             'svnrevision': vcs.get_path_revision(projectfolder),
             'svnrepo': vcs.get_path_repository(projectfolder),
             'instruments': instruments
             }

    return stage