mealie/tests/utils/factories.py
Michael Genson 754e77c9cb
feat: extend Apprise JSON notification functionality with programmatic data (#1355)
* Fixed incorrect generic deleted notification text

* Added custom "event_source" header for json notifs

* Added internal reference data to event notifs

* Added event listeners to shopping list items

* Fixed type issues

* moved JSON event source k:v pairs to message body

* added hook for all supported custom endpoints
fixed bug that excluded non-custom notification types

* created event_source class to replace loosely-typed dict

* fixed silent error when dispatching a null task

* moved url updates to static function

* added unit tests for event_source url manipulation

* removed array from event bus (it's unsupported)
2022-06-15 11:49:42 -08:00

32 lines
937 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(),
password="fake-password",
password_confirm="fake-password",
advanced=advanced or random_bool(),
private=private or random_bool(),
)