def test_all_required(self):
     """ Test all required arguments are provided. """
     namespace = commandlineargs.parse()
     self.assertEqual("project", namespace.project)
     self.assertEqual("report", namespace.report)
     self.assertEqual("WARNING", namespace.log)
     self.assertFalse(namespace.failure_exit_code)
     self.assertTrue(namespace.frontend)
Beispiel #2
0
        filesystem.write_file(dates, filename, mode='w', encoding=None)

    @classmethod
    def __save_metric_long_history(cls, metric, report_dir):
        filename = report_dir / 'json' / '{stable_id}.txt'.format(
            stable_id=metric.normalized_stable_id())
        filesystem.write_file(",".join(
            str(i) if i is not None else '' for i in metric.long_history()),
                              filename,
                              mode='w',
                              encoding=None)

    @staticmethod
    def __format_and_write_report(quality_report, report_formatter, filename,
                                  mode, encoding, **kwargs):
        """ Format the report using the formatter and write it to the specified file. """
        formatted_report = report_formatter(**kwargs).process(quality_report)
        filesystem.write_file(formatted_report, filename, mode, encoding)


if __name__ == '__main__':
    # pylint: disable=invalid-name
    args = commandlineargs.parse()
    log.init_logging(args.log)
    logging.info("%s v%s starting quality report", NAME, VERSION)
    report = Reporter(args.project).create_report(args.report,
                                                  args.frontend != 'no')
    logging.info("%s v%s done with quality report", NAME, VERSION)
    sys.exit(
        2 if args.failure_exit_code and report.direct_action_needed() else 0)
Beispiel #3
0
            filename = report_dir / 'chart' / '{0!s}.svg'.format(metric.id_string())
            filesystem.write_file(image, filename, mode='wb', encoding=None)
            cls.__save_metric_long_history(metric, report_dir)
            if not dates:
                dates = metric.get_long_history_dates()

        filename = report_dir / 'json' / 'dates.txt'
        filesystem.write_file(dates, filename, mode='w', encoding=None)

    @classmethod
    def __save_metric_long_history(cls, metric, report_dir):
        filename = report_dir / 'json' / '{stable_id}.txt'.format(stable_id=metric.normalized_stable_id())
        filesystem.write_file(",".join(str(i) if i is not None else '' for i in metric.long_history()),
                              filename, mode='w', encoding=None)

    @staticmethod
    def __format_and_write_report(quality_report, report_formatter, filename, mode, encoding, **kwargs):
        """ Format the report using the formatter and write it to the specified file. """
        formatted_report = report_formatter(**kwargs).process(quality_report)
        filesystem.write_file(formatted_report, filename, mode, encoding)


if __name__ == '__main__':
    # pylint: disable=invalid-name
    args = commandlineargs.parse()
    log.init_logging(args.log)
    logging.info("%s v%s starting quality report", NAME, VERSION)
    report = Reporter(args.project).create_report(args.report, args.frontend != 'no')
    logging.info("%s v%s done with quality report", NAME, VERSION)
    sys.exit(2 if args.failure_exit_code and report.direct_action_needed() else 0)