-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from uktrade/LTD-2533-oauth
Reverts back to previous API for user on MailServer
- Loading branch information
Showing
6 changed files
with
54 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
from dateutil.parser import parse | ||
from django.test import SimpleTestCase | ||
from parameterized import parameterized | ||
|
||
from mail.libraries.email_message_dto import * | ||
from mail.libraries.helpers import read_file, sort_dtos_by_date, to_mail_message_dto | ||
from mail.libraries.routing_controller import get_email_message_dtos | ||
from mail.servers import MailServer | ||
from mail.tests.libraries.client import LiteHMRCTestClient | ||
|
||
|
||
|
@@ -80,3 +84,21 @@ def test_multi_licence_message_from_spire(self): | |
mail_message = to_mail_message_dto(self.batched_licence_data_email) | ||
self.assertEqual(mail_message.run_number, 96838) | ||
self.assertEqual(mail_message.receiver, "[email protected]") | ||
|
||
|
||
class TestGetEmailMessagesDTOs(SimpleTestCase): | ||
@patch("mail.libraries.routing_controller.get_message_iterator") | ||
def test_get_email_message_dtos(self, mock_get_message_iterator): | ||
mock_mail_server = Mock(spec=MailServer) | ||
mock_emails = [Mock(), Mock()] | ||
mock_get_message_iterator.return_value = mock_emails | ||
|
||
emails = get_email_message_dtos(mock_mail_server) | ||
|
||
self.assertEqual(emails, mock_emails) | ||
mock_mail_server.connect_to_pop3.assert_called_once_with() | ||
mock_get_message_iterator.assert_called_once_with( | ||
mock_mail_server.connect_to_pop3(), | ||
mock_mail_server.user, | ||
) | ||
mock_mail_server.quit_pop3_connection.assert_called_once_with() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters