Skip to content

Commit

Permalink
Adjust comments to match the code
Browse files Browse the repository at this point in the history
  • Loading branch information
foursixnine committed Jan 31, 2024
1 parent 32b24f1 commit 091b1cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions openqabot/types/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/test_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 091b1cf

Please sign in to comment.