def test_dismiss(self): user = factory.make_User() handler = NotificationHandler(user, {}, None) notification = factory.make_Notification(user=user) self.assertThat(notification, Not(HasBeenDismissedBy(user))) handler.dismiss({"id": str(notification.id)}) self.assertThat(notification, HasBeenDismissedBy(user))
def test_dismiss_multiple(self): user = factory.make_User() handler = NotificationHandler(user, {}, None) notifications = [ factory.make_Notification(user=user), factory.make_Notification(users=True), ] self.assertThat(notifications, AllMatch(Not(HasBeenDismissedBy(user)))) handler.dismiss({"id": [str(ntfn.id) for ntfn in notifications]}) self.assertThat(notifications, AllMatch(HasBeenDismissedBy(user)))