useless cache removal

This commit is contained in:
HgO 2022-08-08 00:36:39 +02:00
parent f381eac689
commit 4e50ddf5bb
2 changed files with 4 additions and 18 deletions

View file

@ -128,7 +128,6 @@ async def create_alert(
if alert.firing:
cache.set(event.event_id, alert.fingerprint, expire=config.cache_expire_time)
else:
cache.delete(event.event_id)
cache.delete(alert.fingerprint)

View file

@ -133,13 +133,9 @@ class WebhookApplicationTestCase(aiohttp.test_utils.AioHTTPTestCase):
"fingerprint1",
expire=self.fake_config.cache_expire_time,
)
self.assertEqual(3, self.fake_cache.delete.call_count)
self.assertEqual(2, self.fake_cache.delete.call_count)
self.fake_cache.delete.assert_has_calls(
[
call("fingerprint1"),
call(fake_send_text_to_room.return_value.event_id),
call("fingerprint2"),
]
[call("fingerprint1"), call("fingerprint2")]
)
@patch.object(matrix_alertbot.webhook, "send_text_to_room")
@ -187,10 +183,7 @@ class WebhookApplicationTestCase(aiohttp.test_utils.AioHTTPTestCase):
"fingerprint1",
expire=self.fake_config.cache_expire_time,
)
self.assertEqual(2, self.fake_cache.delete.call_count)
self.fake_cache.delete.assert_has_calls(
[call(fake_send_text_to_room.return_value.event_id), call("fingerprint2")]
)
self.fake_cache.delete.assert_called_once_with("fingerprint2")
@patch.object(matrix_alertbot.webhook, "send_text_to_room")
async def test_post_alerts_with_alertmanager_error(
@ -238,13 +231,7 @@ class WebhookApplicationTestCase(aiohttp.test_utils.AioHTTPTestCase):
notice=False,
)
self.fake_cache.set.assert_not_called()
self.assertEqual(2, self.fake_cache.delete.call_count)
self.fake_cache.delete.assert_has_calls(
[
call(fake_send_text_to_room.return_value.event_id),
call("fingerprint2"),
]
)
self.fake_cache.delete.assert_called_once_with("fingerprint2")
@patch.object(matrix_alertbot.webhook, "send_text_to_room")
async def test_post_alerts_in_unauthorized_room(