From 795ac19f61d20a1403d048792d4d89688aba9111 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 22 Nov 2024 16:22:17 -0800 Subject: [PATCH] Explicitly rebuild models on init to troubleshoot unit test failure --- neon_data_models/models/api/mq/users.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/neon_data_models/models/api/mq/users.py b/neon_data_models/models/api/mq/users.py index 3d7b1cb..2867e21 100644 --- a/neon_data_models/models/api/mq/users.py +++ b/neon_data_models/models/api/mq/users.py @@ -33,6 +33,11 @@ class CreateUserRequest(MQContext): + def __init__(self, **kwargs): + # `User` may be rebuilt upon init, so make sure this model is too + self.model_rebuild() + MQContext.__init__(self, **kwargs) + operation: Literal["create"] = "create" user: User = Field(description="User object to create") @@ -60,6 +65,11 @@ def validate_params(self) -> 'ReadUserRequest': class UpdateUserRequest(MQContext): + def __init__(self, **kwargs): + # `User` may be rebuilt upon init, so make sure this model is too + self.model_rebuild() + MQContext.__init__(self, **kwargs) + operation: Literal["update"] = "update" user: User = Field(description="Updated User object to write to database") auth_username: str = Field( @@ -85,6 +95,11 @@ def get_auth_username(self) -> 'UpdateUserRequest': class DeleteUserRequest(MQContext): + def __init__(self, **kwargs): + # `User` may be rebuilt upon init, so make sure this model is too + self.model_rebuild() + MQContext.__init__(self, **kwargs) + operation: Literal["delete"] = "delete" user: User = Field(description="Exact User object to remove from the " "database")