-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Fix notification splay #494
- Loading branch information
Showing
4 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,23 @@ def test_failed_user(self, mock_email): | |
self.assertCount(models.AlertError, 0, "No failed alerts") | ||
|
||
self.assertEqual(mock_email.call_count, 1, "Still called email") | ||
|
||
@override_settings(PROMGEN=tests.SETTINGS) | ||
@override_settings(CELERY_TASK_ALWAYS_EAGER=True) | ||
@mock.patch("promgen.notification.email.send_mail") | ||
def test_enabled(self, mock_email): | ||
one = models.Service.objects.get(pk=1) | ||
|
||
# This notification is direct and disabled | ||
NotificationEmail.create(obj=one, value="[email protected]", enabled=False) | ||
# Our parent notification is enabled | ||
NotificationUser.create(obj=one, value=one.owner.username) | ||
# But the child notifier is disabled and shouldn't fire | ||
NotificationEmail.create(obj=one.owner, value="[email protected]", enabled=False) | ||
|
||
response = self.fireAlert() | ||
self.assertRoute(response, rest.AlertReceiver, 202) | ||
self.assertCount(models.Alert, 1, "Alert Queued") | ||
self.assertCount(models.AlertError, 0, "No failed alerts") | ||
|
||
self.assertEqual(mock_email.call_count, 0, "Should not call email") |