Unit test user app

* adds unit test for User model and forms
* refactors functions from user_checks.py into User class and drops user_checks.py
This commit is contained in:
2023-09-13 09:49:40 +02:00
parent 21db8227f8
commit d9046eb2b9
14 changed files with 263 additions and 70 deletions

View File

@@ -60,6 +60,29 @@ class User(AbstractUser):
name=ETS_GROUP
).exists()
def is_default_group_only(self) -> bool:
""" Checks if the user is only part of the default group
Args:
Returns:
bool
"""
return not self.in_group(ZB_GROUP) and not self.in_group(ETS_GROUP)
def in_group(self, group: str) -> bool:
""" Checks if the user is part of a group
Args:
group (str): The group's name
Returns:
bool
"""
return self.groups.filter(
name=group
)
def send_mail_shared_access_removed(self, obj_identifier, obj_title, municipals_names):
""" Sends a mail to the user in case of removed shared access