2021-09-09 08:51:29 -08:00
|
|
|
import random
|
|
|
|
import string
|
|
|
|
|
|
|
|
from mealie.schema.user.registration import CreateUserRegistration
|
|
|
|
|
|
|
|
|
|
|
|
def random_string(length=10) -> str:
|
|
|
|
return "".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length)).strip()
|
|
|
|
|
|
|
|
|
|
|
|
def random_email(length=10) -> str:
|
|
|
|
return "".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length)) + "@fake.com"
|
|
|
|
|
|
|
|
|
2021-09-19 15:31:34 -08:00
|
|
|
def random_bool() -> bool:
|
|
|
|
return bool(random.getrandbits(1))
|
|
|
|
|
|
|
|
|
2022-03-15 17:34:53 -08:00
|
|
|
def user_registration_factory(advanced=None, private=None) -> CreateUserRegistration:
|
2021-09-09 08:51:29 -08:00
|
|
|
return CreateUserRegistration(
|
|
|
|
group=random_string(),
|
|
|
|
email=random_email(),
|
|
|
|
username=random_string(),
|
|
|
|
password="fake-password",
|
|
|
|
password_confirm="fake-password",
|
2022-03-15 17:34:53 -08:00
|
|
|
advanced=advanced or random_bool(),
|
|
|
|
private=private or random_bool(),
|
2021-09-09 08:51:29 -08:00
|
|
|
)
|