def run(self, project: Project, version: ProjectVersion, detector_run: DetectorRun, potential_hits: PotentialHits, version_compile: VersionCompile, detector: Detector): logger = logging.getLogger("tasks.publish_findings.version") logger.info("Publishing findings of %s in %s on %s for upload to %s...", detector, self.experiment_id, version, self.review_site_url) if detector_run.is_success(): logger.info("Uploading %s potential hits.", len(potential_hits.findings)) result = "success" elif detector_run.is_error(): logger.info("Detector produced an error.") result = "error" elif detector_run.is_timeout(): logger.info("Detector timed out.") result = "timeout" else: logger.info("Detector was not run.") result = "not run" run_info = detector_run.get_run_info() postable_potential_hits = [ self.__to_postable_potential_hit(potential_hit, version_compile, detector_run.findings_path, logger) for potential_hit in potential_hits.findings] try: for postable_potential_hits_slice in self.__slice_by_number_of_files_and_post_size(postable_potential_hits): file_paths = self.__get_file_paths(postable_potential_hits_slice) postable_data = self.__to_postable_data(run_info, result, postable_potential_hits_slice) self.__post(project, version, detector, postable_data, file_paths) except RequestException as e: raise PublishFailedException(e)
def test_skips_detect_if_previous_run_was_error(self, _): uut = DetectorRun(self.detector, self.version, self.findings_path) uut._execute = MagicMock() uut.is_outdated = lambda _: False uut.is_error = lambda: True uut.ensure_executed(self.detector_args, None, False, 0, 0, self.logger) uut._execute.assert_not_called()