def test_with_json_min_report(self, tmpdir, monkeypatch, caplog):
     monkeypatch.chdir(tmpdir)
     coverage_path = os.path.join(COVERAGE_FILES_DIR,
                                  'HealthCheckAnalyzeLargeInvestigations')
     temp_cover_file = tmpdir.join('.coverage')
     copy_file(coverage_path, temp_cover_file)
     fix_file_path(temp_cover_file, PYTHON_FILE_PATH)
     cov_report = CoverageReport(report_dir=str(tmpdir),
                                 report_type='json,json-min',
                                 coverage_file=temp_cover_file)
     with caplog.at_level(logging.INFO, logger='demisto-sdk'):
         cov_report.coverage_report()
     # assert re.fullmatch(self.patern('json-min', 'coverage-min', 'json'), caplog.records[2].msg)
     assert os.path.exists(tmpdir.join('coverage-min.json'))
 def test_files(self, tmpdir, monkeypatch):
     monkeypatch.chdir(tmpdir)
     coverage_path = os.path.join(COVERAGE_FILES_DIR,
                                  'HealthCheckAnalyzeLargeInvestigations')
     temp_coverage_path = tmpdir.join('.coverage')
     copy_file(coverage_path, temp_coverage_path)
     fix_file_path(temp_coverage_path, PYTHON_FILE_PATH)
     cov_report = CoverageReport(coverage_file=temp_coverage_path)
     cov_report._cov = get_coverage_obj(coverage_file=temp_coverage_path,
                                        report_dir=None,
                                        load_old=True)
     file_path, cover = list(cov_report.files.items())[0]
     assert os.path.abspath(file_path) == PYTHON_FILE_PATH
     assert isinstance(cover, float)
 def test_get_report_str(self, tmpdir, monkeypatch):
     monkeypatch.chdir(tmpdir)
     coverage_path = os.path.join(COVERAGE_FILES_DIR,
                                  'HealthCheckAnalyzeLargeInvestigations')
     temp_coverage_path = tmpdir.join('.coverage')
     copy_file(coverage_path, temp_coverage_path)
     fix_file_path(temp_coverage_path, PYTHON_FILE_PATH)
     cov_report = CoverageReport(coverage_file=temp_coverage_path)
     cov_report._cov = get_coverage_obj(coverage_file=temp_coverage_path,
                                        report_dir=None,
                                        load_old=True)
     report_str = cov_report.report_str
     assert report_str.split('\n')[2].split() == [
         PYTHON_FILE_PATH, '38', '10', '73.68%'
     ]
    def test_with_export_report_function(self, tmpdir, monkeypatch, caplog):
        monkeypatch.chdir(tmpdir)
        coverage_path = os.path.join(COVERAGE_FILES_DIR,
                                     'HealthCheckAnalyzeLargeInvestigations')
        temp_cover_file = tmpdir.join('.coverage')
        copy_file(coverage_path, temp_cover_file)
        fix_file_path(temp_cover_file, PYTHON_FILE_PATH)
        cov_report = CoverageReport(report_dir=str(tmpdir),
                                    report_type='html,json,xml',
                                    coverage_file=temp_cover_file)
        with caplog.at_level(logging.INFO, logger='demisto-sdk'):
            cov_report.coverage_report()

        assert re.fullmatch(self.patern('html', 'html/index', 'html'),
                            caplog.records[1].msg)
        assert re.fullmatch(self.patern('xml', 'coverage', 'xml'),
                            caplog.records[2].msg)
        assert re.fullmatch(self.patern('json', 'coverage', 'json'),
                            caplog.records[3].msg)
        assert len(caplog.records) == 4