def test_user_not_permitted_to_map_if_already_locked_tasks(self, mock_project, mock_user_tasks): # Arrange mock_project.return_value = Project() mock_user_tasks.return_value = [] #Act / Assert with self.assertRaises(NotFound): ProjectService.get_task_for_logged_in_user(1, 1)
def get(self, project_id): """ Gets any locked task on the project from logged in user --- tags: - mapping produces: - application/json parameters: - in: header name: Authorization description: Base64 encoded session token required: true type: string default: Token sessionTokenHere== - name: project_id in: path description: The ID of the project the task is associated with required: true type: integer default: 1 responses: 200: description: Task user is working on 401: description: Unauthorized - Invalid credentials 404: description: User is not working on any tasks 500: description: Internal Server Error """ try: locked_tasks = ProjectService.get_task_for_logged_in_user( project_id, tm.authenticated_user_id) return locked_tasks.to_primitive(), 200 except NotFound: return {"Error": "User has no locked tasks"}, 404 except Exception as e: error_msg = f'HasUserTaskOnProject - unhandled error: {str(e)}' current_app.logger.critical(error_msg) return {"Error": error_msg}, 500