diff --git a/openqabot/types/incident.py b/openqabot/types/incident.py index 6d01d5c..59a9cbf 100644 --- a/openqabot/types/incident.py +++ b/openqabot/types/incident.py @@ -157,7 +157,6 @@ def has_failures(self, token) -> bool: failed_jobs = [res for res in results if res["status"] != "passed"] if failed_jobs: log.info("Found %s failed jobs for incident %s:", len(failed_jobs), self.id) - # if debug is enabled, print all failed jobs if log.isEnabledFor(LOG_DEBUG_LEVEL): log_debug = lambda job_id: log.debug( "Job %s is not marked as acceptable for incident %s", @@ -171,7 +170,5 @@ def has_failures(self, token) -> bool: "Job setting %s not found for incident" % (str(self.id)) ) - # Return true if there are any failed jobs, so if results is not empty - # and there is at least one failed job, return true, any() returns false - # if the iterable is empty + # we only need to check if there are any failed jobs return any(failed_jobs) diff --git a/tests/test_incident.py b/tests/test_incident.py index 34b50de..86e103f 100644 --- a/tests/test_incident.py +++ b/tests/test_incident.py @@ -171,8 +171,8 @@ def test_inc_has_failures(caplog, mock_good, monkeypatch): caplog.set_level(logging.INFO) caplog.clear() - # Assert that the method returns True since there is a failed job inc.has_failures("token") + # Check that the log only has one message, and that it matches our incident assert caplog.records[0].message == "Found 1 failed jobs for incident 24618:" assert len(caplog.records) == 1