• Home
  • Raw
  • Download

Lines Matching +full:mock +full:- +full:tests

7 #      http://www.apache.org/licenses/LICENSE-2.0
14 """Tests for get_coverage.py"""
18 from unittest import mock
25 # pylint: disable=protected-access
35 INVALID_TARGET = 'not-a-fuzz-target'
43 """Tests _get_oss_fuzz_fuzzer_stats_dir_url."""
45 @mock.patch('http_utils.get_json_from_url',
48 'gs://oss-fuzz-coverage/systemd/fuzzer_stats/20210303'
51 """Tests that a project's coverage report can be downloaded and parsed.
59 'https://storage.googleapis.com/oss-fuzz-coverage/'
63 'https://storage.googleapis.com/oss-fuzz-coverage/systemd/fuzzer_stats/'
68 """Tests that passing a bad project returns None."""
70 get_coverage._get_oss_fuzz_fuzzer_stats_dir_url('not-a-proj'))
74 """Tests OSSFuzzCoverage.get_target_coverage."""
77 with mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
82 @mock.patch('http_utils.get_json_from_url', return_value={})
84 """Tests that a target's coverage report can be downloaded and parsed."""
88 'https://storage.googleapis.com/oss-fuzz-coverage/'
92 """Tests that passing an invalid target coverage report returns None."""
96 @mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
98 def test_invalid_project_json(self, _): # pylint: disable=no-self-use
99 """Tests an invalid project JSON results in None being returned."""
122 """Tests OSSFuzzCoverage.get_files_covered_by_target."""
125 with mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
131 """Tests that covered files can be retrieved from a coverage report."""
133 with mock.patch('get_coverage.OSSFuzzCoverage.get_target_coverage',
142 """Tests passing invalid fuzz target returns None."""
149 """Tests FilesystemCoverage.get_files_covered_by_target."""
163 """Tests that covered files can be retrieved from a coverage report."""
169 """Tests passing invalid fuzz target returns None."""
175 """Tests for is_file_covered."""
178 """Tests that is_file_covered returns True for a covered file."""
180 'filename': '/src/systemd/src/basic/locale-util.c',
193 """Tests that is_file_covered returns False for a not covered file."""
195 'filename': '/src/systemd/src/basic/locale-util.c',
209 """Tests that _get_oss_fuzz_latest_cov_report_info works as
213 LATEST_REPORT_INFO_URL = ('https://storage.googleapis.com/oss-fuzz-coverage/'
216 @mock.patch('logging.error')
217 @mock.patch('http_utils.get_json_from_url', return_value={'coverage': 1})
220 """Tests that _get_oss_fuzz_latest_cov_report_info works as intended."""
226 @mock.patch('logging.error')
227 @mock.patch('http_utils.get_json_from_url', return_value=None)
229 """Tests that _get_oss_fuzz_latest_cov_report_info works as intended when we