def test_read( self, student_user: User, solution: Solution, ): assert len(list(notifications.get(student_user))) == 0 message_id = conftest.create_notification(student_user, solution) assert len(list(notifications.get(student_user))) == 1 unread = self.get_unread(student_user) assert len(list(unread)) == 1 notifications.read(id_=message_id) self.check_viewed_inbox(student_user) # Test by notification ID self.create_too_many_notifications(student_user, solution) assert (len(list( notifications.get(student_user))) == Notification.MAX_PER_USER) for notification in notifications.get(student_user): success = notifications.read(id_=notification.id) assert success self.check_full_inbox(student_user) # Still there self.check_viewed_inbox(student_user) # But already viewed # Test by user self.create_too_many_notifications(student_user, solution) assert (len(list( notifications.get(student_user))) == Notification.MAX_PER_USER) notifications.read(user=student_user) self.check_full_inbox(student_user) # Still there self.check_viewed_inbox(student_user) # But already viewed
def read_all_notification(): success_state = notifications.read(user=current_user) return jsonify({'success': success_state})