def test_resolve_notification_task(self, send_message_notification):
        """Test resolve notification task."""
        user = mocks.create_user()
        institution = mocks.create_institution()
        notification_type = self.get_notification_type()

        message = create_message(
            sender_key=user.key,
            current_institution_key=institution.key,
            receiver_institution_key=institution.key,
            sender_institution_key=institution.key,
        )

        notification = Notification(message=message,
                                    entity_key=institution.key.urlsafe(),
                                    notification_type=notification_type,
                                    receiver_key=user.key.urlsafe())

        num_tasks = self.queue.fetch_statistics().tasks
        self.assertEqual(num_tasks, 0, 'num_tasks must be equal to 0')

        id_notification = NotificationsQueueManager.create_notification_task(
            notification)

        num_tasks = self.queue.fetch_statistics().tasks
        self.assertEqual(num_tasks, 1, 'num_tasks must be equal to 1')

        NotificationsQueueManager.resolve_notification_task(id_notification)

        send_message_notification.assert_called_with(
            **notification.format_notification())
        num_tasks = self.queue.fetch_statistics().tasks
        self.assertEqual(num_tasks, 0, 'num_tasks must be equal to 0')
    def test_resolve_notification_task_with_invalid_id(self):
        """Test resolve notification task with invalid id."""
        with self.assertRaises(QueueException) as raises_context:
            NotificationsQueueManager.resolve_notification_task(
                '03-jksahdjkasjksahdshadkjsdhjksakjdhsajhkdhsajkdhas')

        self.assertEqual(str(raises_context.exception), 'Task not found.',
                         'Exception message must be equal to Task not found.')

        with self.assertRaises(QueueException) as raises_context:
            NotificationsQueueManager.resolve_notification_task(
                'ab-jksahdjkasjksahdshadkjsdhjksakjdhsajhkdhsajkdhas')

        self.assertEqual(
            str(raises_context.exception), 'Invalid task key.',
            'Exception message must be equal to Invalid task key.')