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-06-15 14:49:42 -05:00
|
|
|
def random_int(min=-4294967296, max=4294967296) -> int:
|
|
|
|
return random.randint(min, max)
|
|
|
|
|
|
|
|
|
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(),
|
2024-08-22 10:14:32 -05:00
|
|
|
household=random_string(),
|
2021-09-09 08:51:29 -08:00
|
|
|
email=random_email(),
|
|
|
|
username=random_string(),
|
2024-03-11 08:28:54 -05:00
|
|
|
full_name=random_string(),
|
2021-09-09 08:51:29 -08:00
|
|
|
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
|
|
|
)
|