Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ruth Netser <[email protected]>
Co-authored-by: Miles Dunn <[email protected]>
  • Loading branch information
3 people committed Jan 18, 2024
1 parent 2994035 commit 479afa5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
5 changes: 1 addition & 4 deletions cli/objects/failure_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,5 @@ def matches_failure(self, failure: Failure) -> bool:
return (
hasattr(self, "step")
and fnmatch.fnmatch(failure.step, self.step)
and (
(failure.failure_type == self.failure_type)
or self.failure_type == "all"
)
and failure.failure_type in (self.failure_type, "all")
)
8 changes: 3 additions & 5 deletions cli/objects/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import itertools
import json
import os
from typing import Any
Expand Down Expand Up @@ -324,13 +323,12 @@ def _find_failures(self, logs_dir: str, junit_dir: str) -> Optional[list[Failure
unique_steps_with_failures = set()

# Combine lists into one list
for failure in itertools.chain(test_failures, pod_failures):
for failure in test_failures + pod_failures:
if failure.step not in unique_steps_with_failures:
unique_steps_with_failures.update([failure.step])
unique_steps_with_failures.add(failure.step)
if self.firewatch_config.failure_rules:
for rule in self.firewatch_config.failure_rules:
if rule.matches_failure(failure) and rule.ignore:
failure.ignore = True
failure.ignore = rule.matches_failure(failure) and rule.ignore
failures_list.append(failure)

if len(failures_list) > 0:
Expand Down
18 changes: 9 additions & 9 deletions tests/unittests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from cli.objects.job import Job
from cli.report import Report

_logger = simple_logger.logger.get_logger(__name__)
LOGGER = simple_logger.logger.get_logger(__name__)

BUILD_ID_ENV_VAR = "BUILD_ID"
FIREWATCH_DEFAULT_JIRA_PROJECT_ENV_VAR = "FIREWATCH_DEFAULT_JIRA_PROJECT"
Expand Down Expand Up @@ -88,15 +88,15 @@ class MockIssue:
key: str = "LPTOCPCI-MOCK"

def create_jira_issue(*args, **kwargs):
_logger.info("Patching Report.create_jira_issue")
_logger.info(
LOGGER.info("Patching Report.create_jira_issue")
LOGGER.info(
f"Attempted call Report.create_issue with the following keywords: \n{pprint.pformat(kwargs)}",
)
return MockIssue()

def add_duplicate_comment(*args, **kwargs):
_logger.info("Patching Report.add_duplicate_comment")
_logger.info(
LOGGER.info("Patching Report.add_duplicate_comment")
LOGGER.info(
f"Attempted to call Report.add_duplicate_comment with the following keywords: \n{pprint.pformat(kwargs)}",
)
return
Expand Down Expand Up @@ -128,12 +128,12 @@ def __post_init__(self):
cap = CapJira()

def create_jira_issue(*args, **kwargs):
_logger.info("Patching Report.create_jira_issue")
LOGGER.info("Patching Report.create_jira_issue")
cap.create_jira_issue.append(CapInputs(args, kwargs))
return MockIssue()

def add_duplicate_comment(*args, **kwargs):
_logger.info("Patching Report.add_duplicate_comment")
LOGGER.info("Patching Report.add_duplicate_comment")
cap.add_duplicate_comment.append(CapInputs(args, kwargs))

monkeypatch.setattr(Report, "create_jira_issue", create_jira_issue)
Expand All @@ -143,7 +143,7 @@ def add_duplicate_comment(*args, **kwargs):

@pytest.fixture
def patch_job_log_dir(monkeypatch, job_log_dir):
_logger.info("Patching Job log dir path")
LOGGER.info("Patching Job log dir path")

def _download_logs(*args, **kwargs):
return job_log_dir.as_posix()
Expand All @@ -153,7 +153,7 @@ def _download_logs(*args, **kwargs):

@pytest.fixture
def patch_job_junit_dir(monkeypatch, job_junit_dir):
_logger.info("Patching Job junit dir path")
LOGGER.info("Patching Job junit dir path")

def _download_junit(*args, **kwargs):
return job_junit_dir.as_posix()
Expand Down

0 comments on commit 479afa5

Please sign in to comment.