def test_achieve_not_existent_task(self):

        expected_response = messages.TASK_DOES_NOT_EXIST, 404
        actual_response = TaskDAO.complete_task(
            self.first_user.id, self.mentorship_relation_w_second_user.id,
            123123)

        self.assertEqual(expected_response, actual_response)
    def test_achieve_not_achieved_task(self):
        self.assertFalse(self.tasks_list_1.find_task_by_id(1).get("is_done"))

        expected_response = messages.TASK_WAS_ACHIEVED_SUCCESSFULLY, 200
        actual_response = TaskDAO.complete_task(
            self.first_user.id, self.mentorship_relation_w_second_user.id, 1)

        self.assertTrue(self.tasks_list_1.find_task_by_id(1).get("is_done"))
        self.assertEqual(expected_response, actual_response)
    def test_achieve_achieved_task(self):
        self.assertTrue(self.tasks_list_1.find_task_by_id(2).get("is_done"))

        expected_response = messages.TASK_WAS_ALREADY_ACHIEVED, 400
        actual_response = TaskDAO.complete_task(
            self.first_user.id, self.mentorship_relation_w_second_user.id, 2)

        self.assertTrue(self.tasks_list_1.find_task_by_id(2).get("is_done"))
        self.assertEqual(expected_response, actual_response)
    def put(cls, request_id, task_id):
        """
        Update a task to mark it as complate

        Input:
        1. Header: valid access token
        2. Path: ID of task (task_id) and ID of the associated mentorship
        relation (request_id). The user must be involved in this relation.
        3. Body:

        Returns:
        Success or failure message. The task is marked as complete if succesful.
        """

        # TODO check if user id is well parsed, if it is an integer

        user_id = get_jwt_identity()

        response = TaskDAO.complete_task(user_id=user_id,
                                         mentorship_relation_id=request_id,
                                         task_id=task_id)

        return response