Skip to content

Commit

Permalink
Add check to ensure HanaToken is defined for User object with uni…
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Nov 20, 2024
1 parent 7c0da8f commit bf941ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions neon_data_models/models/user/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ class TokenConfig(BaseModel):


class User(BaseModel):
def __init__(self, **kwargs):
# Ensure `HanaToken` is populated from the import space
self.model_rebuild()
BaseModel.__init__(self, **kwargs)

username: str
password_hash: Optional[str] = None
user_id: str = Field(default_factory=lambda: str(uuid4()))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_import_user(self):
from neon_data_models.models.user import User
from neon_data_models.models.user.database import User as _User
self.assertEqual(User, _User)
user = User(username="test_user", password_hash="test_pass")
self.assertIsInstance(user, User)

def test_import_subclasses(self):
# Addressing circular import noted in users service unit tests
Expand Down

0 comments on commit bf941ca

Please sign in to comment.