Added test to create mailbox without sending an email

This commit is contained in:
Adrià Casajús 2024-08-02 14:32:30 +02:00
parent b0849bff6d
commit ea138070fd
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
2 changed files with 21 additions and 0 deletions

View File

@ -70,8 +70,14 @@ def create_mailbox(
if verified: if verified:
LOG.i(f"User {user} as created a pre-verified mailbox with {email}") LOG.i(f"User {user} as created a pre-verified mailbox with {email}")
return new_mailbox return new_mailbox
LOG.i(f"User {user} has created mailbox with {email}") LOG.i(f"User {user} has created mailbox with {email}")
activation = generate_activation_code(new_mailbox, use_digit_code=use_digit_codes) activation = generate_activation_code(new_mailbox, use_digit_code=use_digit_codes)
if not send_email:
LOG.i(f"Skipping sending validation email for mailbox {new_mailbox}")
return new_mailbox
send_verification_email( send_verification_email(
user, user,
new_mailbox, new_mailbox,

View File

@ -101,6 +101,21 @@ def test_create_mailbox_with_digits():
assert mail_sent.envelope_to == email assert mail_sent.envelope_to == email
@mail_sender.store_emails_test_decorator
def test_create_mailbox_without_verification_email():
email = random_email()
mailbox_utils.create_mailbox(user, email, use_digit_codes=True, send_email=False)
mailbox = Mailbox.get_by(email=email)
assert mailbox is not None
assert not mailbox.verified
activation = MailboxActivation.get_by(mailbox_id=mailbox.id)
assert activation is not None
assert activation.tries == 0
assert len(activation.code) == 6
assert 0 == len(mail_sender.get_stored_emails())
@mail_sender.store_emails_test_decorator @mail_sender.store_emails_test_decorator
def test_send_verification_email(): def test_send_verification_email():
email = random_email() email = random_email()