From b61a4ab99492dc2cfe111111897b12cefa5a9284 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 6 Jul 2022 08:51:35 -0700 Subject: [PATCH] Adds tests for unnotify --- bookwyrm/tests/models/test_notification.py | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/bookwyrm/tests/models/test_notification.py b/bookwyrm/tests/models/test_notification.py index 0c16741e1..3d6025a5f 100644 --- a/bookwyrm/tests/models/test_notification.py +++ b/bookwyrm/tests/models/test_notification.py @@ -137,3 +137,47 @@ class Notification(TestCase): self.assertEqual(notification.related_users.count(), 1) self.assertEqual(notification.related_users.first(), self.remote_user) self.assertEqual(notification.related_list_items.count(), 2) + + def test_unnotify(self): + """Remove a notification""" + models.Notification.notify( + self.local_user, + self.remote_user, + notification_type=models.Notification.FAVORITE, + ) + self.assertTrue(models.Notification.objects.exists()) + + models.Notification.unnotify( + self.local_user, + self.remote_user, + notification_type=models.Notification.FAVORITE, + ) + self.assertFalse(models.Notification.objects.exists()) + + def test_unnotify_multiple_users(self): + """Remove a notification""" + models.Notification.notify( + self.local_user, + self.remote_user, + notification_type=models.Notification.FAVORITE, + ) + models.Notification.notify( + self.local_user, + self.another_user, + notification_type=models.Notification.FAVORITE, + ) + self.assertTrue(models.Notification.objects.exists()) + + models.Notification.unnotify( + self.local_user, + self.remote_user, + notification_type=models.Notification.FAVORITE, + ) + self.assertTrue(models.Notification.objects.exists()) + + models.Notification.unnotify( + self.local_user, + self.another_user, + notification_type=models.Notification.FAVORITE, + ) + self.assertFalse(models.Notification.objects.exists())