mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 17:08:30 +01:00
faae37b6bc
* Update base templates based on the parter user * Update template * Fix missing check * Check if the user is set * Hide flag usage
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from app.db import Session
|
|
from app.models import Alias, Mailbox, AliasMailbox, User
|
|
from tests.utils import create_new_user, random_email
|
|
|
|
|
|
def test_duplicated_mailbox_is_returned_only_once():
|
|
user = create_new_user()
|
|
other_mailbox = Mailbox.create(user_id=user.id, email=random_email(), verified=True)
|
|
alias = Alias.create_new_random(user)
|
|
AliasMailbox.create(mailbox_id=other_mailbox.id, alias_id=alias.id)
|
|
AliasMailbox.create(mailbox_id=user.default_mailbox_id, alias_id=alias.id)
|
|
Session.flush()
|
|
alias_mailboxes = alias.mailboxes
|
|
assert len(alias_mailboxes) == 2
|
|
alias_mailbox_id = [mailbox.id for mailbox in alias_mailboxes]
|
|
assert user.default_mailbox_id in alias_mailbox_id
|
|
assert other_mailbox.id in alias_mailbox_id
|
|
|
|
|
|
def test_alias_create_from_partner_flags_also_the_user():
|
|
user = create_new_user()
|
|
Session.flush()
|
|
email = random_email()
|
|
alias = Alias.create(
|
|
user_id=user.id,
|
|
email=email,
|
|
mailbox_id=user.default_mailbox_id,
|
|
flags=Alias.FLAG_PARTNER_CREATED,
|
|
flush=True,
|
|
)
|
|
assert alias.user.flags & User.FLAG_CREATED_ALIAS_FROM_PARTNER > 0
|