mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 21:27:10 +01:00
b61a171de3
* Add tests that all events have all the info we need * Reorder * Fix import
33 lines
792 B
Python
33 lines
792 B
Python
from app.events.event_dispatcher import Dispatcher
|
|
from app.models import PartnerUser, User
|
|
from app.proton.utils import get_proton_partner
|
|
from tests.utils import create_new_user, random_token
|
|
from typing import Tuple
|
|
|
|
|
|
class OnMemoryDispatcher(Dispatcher):
|
|
def __init__(self):
|
|
self.memory = []
|
|
|
|
def send(self, event: bytes):
|
|
self.memory.append(event)
|
|
|
|
def clear(self):
|
|
self.memory = []
|
|
|
|
|
|
def _create_unlinked_user() -> User:
|
|
return create_new_user()
|
|
|
|
|
|
def _create_linked_user() -> Tuple[User, PartnerUser]:
|
|
user = _create_unlinked_user()
|
|
partner_user = PartnerUser.create(
|
|
partner_id=get_proton_partner().id,
|
|
user_id=user.id,
|
|
external_user_id=random_token(10),
|
|
flush=True,
|
|
)
|
|
|
|
return user, partner_user
|