mealie/tests/utils/factories.py
Michael Genson 403038a5b2
feat: First Time Setup Wizard (#3204)
* extract user registration form into a composable

* added base wizard component

* added partial setup implementation

* removed unused attrs

* added setup bypass

* made setup page more readable

* add checkbox hints to autoform

* added common settings pages and initial submit logic

* bypass setup in demo

* add full name to user registration

* added fullname and pw handling to setup

* fixed wizard indentation

* added post-setup suggestions

* added tests for backend changes

* renamed Wizard to BaseWizard

* lint fixes

* pass hardcoded default password instead of backend nonsense

* removed old test

* fix e2e

* added setup skip to e2e testing for all admin users

---------

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
2024-03-11 13:28:54 +00:00

34 lines
972 B
Python

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"
def random_bool() -> bool:
return bool(random.getrandbits(1))
def random_int(min=-4294967296, max=4294967296) -> int:
return random.randint(min, max)
def user_registration_factory(advanced=None, private=None) -> CreateUserRegistration:
return CreateUserRegistration(
group=random_string(),
email=random_email(),
username=random_string(),
full_name=random_string(),
password="fake-password",
password_confirm="fake-password",
advanced=advanced or random_bool(),
private=private or random_bool(),
)