chore(): small improvements

This commit is contained in:
ITQ
2026-02-23 23:29:03 +03:00
parent 85bed92364
commit ffd887dc39
11 changed files with 197 additions and 20 deletions
@@ -164,6 +164,33 @@ class NotificationEnqueueTest(TestCase):
self.assertEqual(len(logs_1), 1)
self.assertEqual(len(logs_2), 0)
def test_enqueue_respects_rule_rate_limit(self) -> None:
rule_create(
event_type=NotificationEventType.GUARDRAIL_TRIGGERED,
channel=self.channel,
rate_limit_window_seconds=60,
rate_limit_max_notifications=2,
)
payload = NotificationPayload(
title="Alert",
body="Error rate exceeded",
event_type=NotificationEventType.GUARDRAIL_TRIGGERED,
experiment_id=str(self.experiment.pk),
experiment_name=self.experiment.name,
)
logs_1 = notification_enqueue(
NotificationEventType.GUARDRAIL_TRIGGERED, payload
)
logs_2 = notification_enqueue(
NotificationEventType.GUARDRAIL_TRIGGERED, payload
)
logs_3 = notification_enqueue(
NotificationEventType.GUARDRAIL_TRIGGERED, payload
)
self.assertEqual(len(logs_1), 1)
self.assertEqual(len(logs_2), 1)
self.assertEqual(len(logs_3), 0)
def test_enqueue_no_matching_rules(self) -> None:
logs = notification_enqueue(
NotificationEventType.EXPERIMENT_STARTED,