Coverage for app/models/user.py: 86%
21 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-05-02 02:49 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-05-02 02:49 +0000
1import bcrypt
3class Base:
4 # Dynamically get attribute
5 def __init__(self, **kwargs):
6 self._data = kwargs
8 def to_json(self):
9 return self._data
11 def __getattr__(self, name):
12 return self._data.get(name)
14 def __getitem__(self, key):
15 return self._data.get(key)
17 def get_user(self):
18 return self
20class User(Base):
21 pass
23class Class(Base):
24 pass
26class Suggestion(Base):
27 pass
30 @staticmethod
31 def hash_password(password: str) -> str:
32 return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')