Skip to content

Commit

Permalink
Add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Feb 8, 2024
1 parent 550adc4 commit 7fa36b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Empty file.
44 changes: 44 additions & 0 deletions tests/core/service/email/test_container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from unittest.mock import create_autospec

import pytest
from redmail import EmailSender

from core.service.email.container import Email


@pytest.fixture
def container() -> Email:
email = Email()
email.config.from_dict(
{
"server": "test_server.com",
"port": 587,
"username": "username",
"password": "password",
"sender": "[email protected]",
}
)
return email


def test_emailer(container: Email):
emailer = container.emailer()
assert isinstance(emailer, EmailSender)
assert emailer.host == "test_server.com"
assert emailer.port == 587
assert emailer.username == "username"
assert emailer.password == "password"


def test_send_email(container: Email):
mock_emailer = create_autospec(EmailSender)
container.emailer.override(mock_emailer)
container.send_email(subject="subject", receivers=["[email protected]", "[email protected]"])
mock_emailer.send.assert_called_once_with(
subject="subject",
sender="[email protected]",
receivers=["[email protected]", "[email protected]"],
text=None,
html=None,
attachments=None,
)

0 comments on commit 7fa36b4

Please sign in to comment.