Add testing helpers to create superuser

This commit is contained in:
Aurélien Delobelle 2018-01-22 21:38:01 +01:00
parent c239f28f17
commit bd89dce11d

View file

@ -9,7 +9,9 @@ def _create_user(username, is_cof=False, is_staff=False, attrs=None):
password = attrs.pop('password', username)
user_keys = ['first_name', 'last_name', 'email', 'is_staff']
user_keys = [
'first_name', 'last_name', 'email', 'is_staff', 'is_superuser',
]
user_attrs = {k: v for k, v in attrs.items() if k in user_keys}
profile_keys = [
@ -49,3 +51,11 @@ def create_member(username, attrs=None):
def create_staff(username, attrs=None):
return _create_user(username, is_cof=True, is_staff=True, attrs=attrs)
def create_root(username, attrs=None):
if attrs is None:
attrs = {}
attrs.setdefault('is_staff', True)
attrs.setdefault('is_superuser', True)
return _create_user(username, attrs=attrs)