Skip to content

Commit

Permalink
Rename method as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Feb 13, 2024
1 parent 35d0b2a commit da9987c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/argus/notificationprofile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def is_empty(self):
and self.is_event_type_empty()
)

def incident_fits_tristates(self, incident) -> Dict[str, TriState]:
def get_incident_tristate_checks(self, incident) -> Dict[str, TriState]:
if self.are_tristates_empty():
return {}
fits_tristates = {}
Expand Down Expand Up @@ -282,7 +282,7 @@ def incident_fits(self, incident: Incident):
checks = {}
checks["source"] = self.source_system_fits(incident, data)
checks["tags"] = self.tags_fit(incident, data)
tristate_checks = self.filter_wrapper.incident_fits_tristates(incident)
tristate_checks = self.filter_wrapper.get_incident_tristate_checks(incident)
for tristate, result in tristate_checks.items():
checks[tristate] = result
checks["max_level"] = self.filter_wrapper.incident_fits_maxlevel(incident)
Expand Down
22 changes: 11 additions & 11 deletions tests/notificationprofile/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,62 +79,62 @@ class FilterWrapperIncidentFitsTristatesTests(unittest.TestCase):
# A tristate must be one of True, False, None
# "None" is equivalent to the tristate not being mentioned in the filter at all

def test_incident_fits_tristates_no_tristates_set(self):
def test_get_incident_tristate_checks_no_tristates_set(self):
incident = Mock()
empty_filter = FilterWrapper({})
result = empty_filter.incident_fits_tristates(incident)
result = empty_filter.get_incident_tristate_checks(incident)
self.assertEqual(result, {})

@override_settings(ARGUS_FALLBACK_FILTER={"acked": True})
def test_incident_fits_tristates_no_tristates_set_with_fallback(self):
def test_get_incident_tristate_checks_no_tristates_set_with_fallback(self):
incident = Mock()
# Shouldn't match
incident.acked = False
empty_filter = FilterWrapper({})
result = empty_filter.incident_fits_tristates(incident)
result = empty_filter.get_incident_tristate_checks(incident)
self.assertEqual(result["open"], None)
self.assertEqual(result["acked"], False)
self.assertEqual(result["stateful"], None)
# Should match
incident.acked = True
empty_filter = FilterWrapper({})
result = empty_filter.incident_fits_tristates(incident)
result = empty_filter.get_incident_tristate_checks(incident)
self.assertNotIn(False, result.values())
self.assertEqual(result["open"], None)
self.assertEqual(result["acked"], True)
self.assertEqual(result["stateful"], None)

def test_incident_fits_tristates_is_true(self):
def test_get_incident_tristate_checks_is_true(self):
incident = Mock()
incident.open = True
incident.acked = False
incident.stateful = True
filter = FilterWrapper({"open": True, "acked": False})
result = filter.incident_fits_tristates(incident)
result = filter.get_incident_tristate_checks(incident)
self.assertTrue(set(result.values())) # all True!
self.assertEqual(result["open"], True)
self.assertEqual(result["acked"], True)
self.assertEqual(result["stateful"], None)

def test_incident_fits_tristates_is_false(self):
def test_get_incident_tristate_checks_is_false(self):
incident = Mock()
incident.open = True
incident.acked = False
incident.stateful = True
filter = FilterWrapper({"open": False, "acked": False})
result = filter.incident_fits_tristates(incident)
result = filter.get_incident_tristate_checks(incident)
self.assertIn(False, result.values())
self.assertEqual(result["open"], False)
self.assertEqual(result["acked"], True)
self.assertEqual(result["stateful"], None)

@override_settings(ARGUS_FALLBACK_FILTER={"acked": True})
def test_incident_fits_tristates_fallback_should_not_override(self):
def test_get_incident_tristate_checks_fallback_should_not_override(self):
incident = Mock()
# Should match
incident.acked = False
filter = FilterWrapper({"acked": False})
result = filter.incident_fits_tristates(incident)
result = filter.get_incident_tristate_checks(incident)
self.assertEqual(result["acked"], True)
self.assertNotIn(False, result.values())
self.assertEqual(result["open"], None)
Expand Down

0 comments on commit da9987c

Please sign in to comment.