def user_factory(troubleshooter=False, superuser=False, backoffice=False, password=None):
fake = Faker('en-US')
u = User(username=fake.user_name(),
firstname=fake.first_name(),
lastname=fake.last_name(),
is_active=True,
is_superuser=superuser,
is_backoffice_user=backoffice,
is_troubleshooter=troubleshooter)
u.set_password(password or fake.password())
if troubleshooter:
u.auth_token = get_random_string(32)
u.save()
return u
评论列表
文章目录