def test_invalidate_all_sets_counters_correctly(self): # Act ValidatorService.invalidate_all_tasks(self.test_project.id, self.test_user.id) # Assert self.assertEqual(0, self.test_project.tasks_mapped) self.assertEqual(0, self.test_project.tasks_validated)
def test_mapped_by_and_validated_by_are_null_after_invalidating_all(self): ValidatorService.validate_all_tasks(self.test_project.id, self.test_user.id) ValidatorService.invalidate_all_tasks(self.test_project.id, self.test_user.id) for task in self.test_project.tasks: self.assertIsNone(task.mapped_by) self.assertIsNone(task.validated_by)
def post(self, project_id): """ Invalidate all mapped tasks on a project --- tags: - tasks 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: Unique project ID required: true type: integer default: 1 responses: 200: description: All mapped tasks invalidated 401: description: Unauthorized - Invalid credentials 403: description: Forbidden 500: description: Internal Server Error """ try: authenticated_user_id = token_auth.current_user() ProjectAdminService.is_user_action_permitted_on_project( authenticated_user_id, project_id) except ValueError as e: error_msg = f"TasksActionsInvalidateAllAPI POST: {str(e)}" return {"Error": error_msg}, 403 try: ValidatorService.invalidate_all_tasks(project_id, authenticated_user_id) return {"Success": "All tasks invalidated"}, 200 except Exception as e: error_msg = f"TasksActionsInvalidateAllAPI POST - unhandled error: {str(e)}" current_app.logger.critical(error_msg) return {"Error": "Unable to invalidate all tasks"}, 500