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

1import bcrypt 

2 

3class Base: 

4 # Dynamically get attribute 

5 def __init__(self, **kwargs): 

6 self._data = kwargs 

7 

8 def to_json(self): 

9 return self._data 

10 

11 def __getattr__(self, name): 

12 return self._data.get(name) 

13 

14 def __getitem__(self, key): 

15 return self._data.get(key) 

16 

17 def get_user(self): 

18 return self 

19 

20class User(Base): 

21 pass 

22 

23class Class(Base): 

24 pass 

25 

26class Suggestion(Base): 

27 pass 

28 

29 

30 @staticmethod 

31 def hash_password(password: str) -> str: 

32 return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')