Skip to content

Commit

Permalink
fix(tests): update SMTP unit tests (#179)
Browse files Browse the repository at this point in the history
This commit adds the reset_connection fixture
to some tests that were broken in the ATS CI step.

The reason they were broken is because the order of
the tests being ran was hiding this issue of reusing the
existing SMTP connection across tests.

Signed-off-by: joseph-sentry <[email protected]>
  • Loading branch information
joseph-sentry authored Nov 14, 2023
1 parent a873c92 commit 0a1f963
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions services/tests/test_smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ def reset_connection_at_start():


class TestSMTP(object):
def test_correct_init(self, mocker, mock_configuration, set_username_and_password):
def test_correct_init(
self,
mocker,
mock_configuration,
set_username_and_password,
reset_connection_at_start,
):
mocker.patch("smtplib.SMTP")

m = mocker.patch("ssl.create_default_context", return_value=MagicMock())
Expand Down Expand Up @@ -147,7 +153,12 @@ def test_smtp_active(self, mocker, mock_configuration, dbsession):
assert smtp.active() == False

def test_smtp_disconnected(
self, mocker, mock_configuration, dbsession, set_username_and_password
self,
mocker,
mock_configuration,
dbsession,
set_username_and_password,
reset_connection_at_start,
):
m = MagicMock()
m.configure_mock(**{"noop.side_effect": SMTPServerDisconnected()})
Expand Down

0 comments on commit 0a1f963

Please sign in to comment.