Skip to content

Commit

Permalink
fix: add correction to tests mock patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspary committed May 18, 2023
1 parent ae62301 commit bd39b3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions tests/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def test_setter_name_sender(self):
assert sender_name in self.adapter.sender
assert sender_email in self.adapter.sender

@mock.patch("src.adapters.EmailMIMEAdapter.attach")
@mock.patch("src.adapters.EmailMIMEAdapter._EmailMIMEAdapter__set_attatchment")
@mock.patch("src.adapters.MIMEText")
@mock.patch("email_hub_sdk.adapters.EmailMIMEAdapter.attach")
@mock.patch("email_hub_sdk.adapters.EmailMIMEAdapter._EmailMIMEAdapter__set_attatchment")
@mock.patch("email_hub_sdk.adapters.MIMEText")
def test_as_string(self, mime_text_mock, set_attatchment_mock, attach_mock):
set_attatchment_mock.return_value = None
attach_mock.return_value = None
Expand All @@ -57,8 +57,8 @@ def test_as_string(self, mime_text_mock, set_attatchment_mock, attach_mock):
assert isinstance(payload, list)
assert len(payload) == 0

@mock.patch("src.adapters.EmailMIMEAdapter.attach")
@mock.patch("src.adapters.MIMEBase")
@mock.patch("email_hub_sdk.adapters.EmailMIMEAdapter.attach")
@mock.patch("email_hub_sdk.adapters.MIMEBase")
def test_set_attatchment(self, mime_base_mock, attach_mock):
attach_mock.return_value = None
mime_base_mock.set_payload.return_value = None
Expand Down
12 changes: 6 additions & 6 deletions tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_initialization(self):
assert self.client._password == PASSWORD_MOCK
assert self.client._client is None

@mock.patch("src.clients.BaseEmailClient._client")
@mock.patch("src.clients.BaseEmailClient.__enter__")
@mock.patch("email_hub_sdk.clients.BaseEmailClient._client")
@mock.patch("email_hub_sdk.clients.BaseEmailClient.__enter__")
def test_the_with_statement(self, enter_mock, client_mock):
enter_mock.return_value = self.client
client_mock.close.return_value = None
Expand All @@ -51,7 +51,7 @@ def test_initialization(self):
assert self.client._password == PASSWORD_MOCK
assert self.client._client is None

@mock.patch("src.clients.smtplib.SMTP_SSL")
@mock.patch("email_hub_sdk.clients.smtplib.SMTP_SSL")
def test_smtp(self, smtp_mock):
smtp_mock.login.return_value = None

Expand All @@ -60,7 +60,7 @@ def test_smtp(self, smtp_mock):
assert smtp_mock.called_once_with(ServerSMTP.GMAIL.value, PortSMTP.GMAIL.value)
assert smtp_mock.login.called_once_with(ACCOUNT_MOCK, PASSWORD_MOCK)

@mock.patch("src.clients.GmailClient._client")
@mock.patch("email_hub_sdk.clients.GmailClient._client")
def test_send_mail(self, client_mock):
client_mock.sendmail.return_value = None
result = self.client.send_email(
Expand All @@ -85,7 +85,7 @@ def test_initialization(self):
assert self.client._password == PASSWORD_MOCK
assert self.client._client is None

@mock.patch("src.clients.smtplib.SMTP")
@mock.patch("email_hub_sdk.clients.smtplib.SMTP")
def test_smtp(self, smtp_mock):
smtp_mock.login.return_value = None
smtp_mock.starttls.return_value = None
Expand All @@ -96,7 +96,7 @@ def test_smtp(self, smtp_mock):
assert smtp_mock.login.called_once_with(ACCOUNT_MOCK, PASSWORD_MOCK)
assert smtp_mock.starttls.called_once

@mock.patch("src.clients.OutlookClient._client")
@mock.patch("email_hub_sdk.clients.OutlookClient._client")
def test_send_mail(self, client_mock):
client_mock.sendmail.return_value = None
result = self.client.send_email(
Expand Down
12 changes: 6 additions & 6 deletions tests/test_facades.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
ATTATCHMENTS_MOCK = [(b"", "filename.txt")]


@mock.patch("src.facades.GmailClient")
@mock.patch("src.facades.send_email")
@mock.patch("email_hub_sdk.facades.GmailClient")
@mock.patch("email_hub_sdk.facades.send_email")
def test_send_email_with_gmail(send_email_mock, gmail_client_mock):
send_email_with_gmail(
account=ACCOUNT_MOCK,
Expand All @@ -38,8 +38,8 @@ def test_send_email_with_gmail(send_email_mock, gmail_client_mock):
assert gmail_client_mock.called_once_with(ACCOUNT_MOCK, PASSWORD_MOCK)


@mock.patch("src.facades.OutlookClient")
@mock.patch("src.facades.send_email")
@mock.patch("email_hub_sdk.facades.OutlookClient")
@mock.patch("email_hub_sdk.facades.send_email")
def test_send_email_with_outlook(send_email_mock, outlook_client_mock):
send_email_with_outlook(
account=ACCOUNT_MOCK,
Expand All @@ -64,8 +64,8 @@ def test_send_email_with_outlook(send_email_mock, outlook_client_mock):
assert outlook_client_mock.called_once_with(ACCOUNT_MOCK, PASSWORD_MOCK)


@mock.patch("src.facades.EmailMIMEAdapter")
@mock.patch("src.facades.EmailService")
@mock.patch("email_hub_sdk.facades.EmailMIMEAdapter")
@mock.patch("email_hub_sdk.facades.EmailService")
def test_send_email(email_mime_mock, email_service_mock):
client_obj = mock.Mock()
send_email(
Expand Down

0 comments on commit bd39b3f

Please sign in to comment.