Exemplo n.º 1
0
 def test_export_report(self, caplog, mocker):
     foo_mock = mocker.patch.object(self, 'foo')
     with caplog.at_level(logging.INFO, logger='demisto-sdk'):
         export_report(self.foo, 'the_format', 'the_path')
     foo_mock.assert_called_once()
     assert len(caplog.records) == 1
     assert caplog.records[
         0].msg == 'exporting the_format coverage report to the_path'
    def coverage_report(self):
        if not os.path.exists(self.cov.config.data_file):
            logger.debug(f'skipping coverage report {self.cov.config.data_file} file not found.')
            return

        logger.info(f'\n{self.report_str}')

        if 'text' in self.report_types:
            txt_file_path = os.path.join(self.report_dir, 'coverage.txt')
            logger.info(f'exporting txt coverage report to {txt_file_path}')
            with open(txt_file_path, 'w') as txt_file:
                txt_file.write(self.report_str)
        if 'html' in self.report_types:
            export_report(self.cov.html_report, 'html', os.path.join(self.cov.config.html_dir, 'index.html'))
        if 'xml' in self.report_types:
            export_report(self.cov.xml_report, 'xml', self.cov.config.xml_output)
        if 'json' in self.report_types:
            export_report(self.cov.json_report, 'json', self.cov.config.json_output)
        if 'json-min' in self.report_types:
            json_min_dir = os.path.join(self.report_dir, 'coverage-min.json')
            logger.info(f'exporting json-min coverage report to {json_min_dir}')
            CoverageSummary.create(self.cov.config.json_output, json_min_dir)
Exemplo n.º 3
0
 def test_export_report_with_error(self, caplog):
     with caplog.at_level(logging.WARNING, logger='demisto-sdk'):
         export_report(self.foo_raises, 'the_format', 'the_path')
     assert len(caplog.records) == 1
     assert caplog.records[0].msg == 'coverage.misc.CoverageException'