diff options
author | Anike Arni <anikarni@gmail.com> | 2017-04-20 18:40:34 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 18:40:34 -0300 |
commit | 7375316b2d3bc61eeb84e7d59c61ac937bf232a8 (patch) | |
tree | aba9d514de07f3523e907d99fcc65119f6e8f7f3 | |
parent | 1a725d7dd2ae8d8bff41de0570c1d4e62ebd027e (diff) | |
parent | 93621607efc7b907fd30b06b000afb9430ccecfe (diff) |
Merge pull request #1058 from pixelated/recovery-code-email-template
[#927] Uses internal email date method for consistency
-rw-r--r-- | service/pixelated/account_recovery.py | 7 | ||||
-rw-r--r-- | service/test/unit/test_account_recovery.py | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/service/pixelated/account_recovery.py b/service/pixelated/account_recovery.py index f84aea1a..58242a7d 100644 --- a/service/pixelated/account_recovery.py +++ b/service/pixelated/account_recovery.py @@ -16,13 +16,13 @@ import pkg_resources import binascii +from email import message_from_string from twisted.internet.defer import inlineCallbacks, returnValue from twisted.logger import Logger from twisted.mail import smtp -from email import message_from_string -from email.utils import formatdate +from pixelated.support import date log = Logger() @@ -71,6 +71,7 @@ class AccountRecovery(object): raise e def _get_recovery_mail(self, code, sender, backup_email): + email_date = date.mail_date_now() recovery_mail = pkg_resources.resource_filename( 'pixelated.assets', 'recovery.mail.%s' % (self._language)) @@ -81,4 +82,4 @@ class AccountRecovery(object): recovery_code=binascii.hexlify(code), backup_email=backup_email, sender=sender, - date=formatdate(localtime=True))) + date=email_date)) diff --git a/service/test/unit/test_account_recovery.py b/service/test/unit/test_account_recovery.py index 4dc9621f..2a185347 100644 --- a/service/test/unit/test_account_recovery.py +++ b/service/test/unit/test_account_recovery.py @@ -85,13 +85,13 @@ class AccountRecoveryTest(unittest.TestCase): mock_resource.assert_called_once_with('pixelated.assets', 'recovery.mail.pt-BR') - @patch('pixelated.account_recovery.formatdate') + @patch('pixelated.account_recovery.date.mail_date_now') @patch('pixelated.account_recovery.smtp.sendmail') @patch('pixelated.account_recovery.pkg_resources.resource_filename') @defer.inlineCallbacks - def test_send_recovery_code_by_email(self, mock_resource, mock_sendmail, mock_formatdate): + def test_send_recovery_code_by_email(self, mock_resource, mock_sendmail, mock_date): mock_sendmail.return_value = defer.succeed(None) - mock_formatdate.return_value = 'Sat, 21 Mar 2015 19:30:09 -0300' + mock_date.return_value = 'Sat, 21 Mar 2015 19:30:09 -0300' sender = 'team@{}'.format(self.domain) mock_file_content = '{backup_email}, {sender}, {date}, {domain}, {recovery_code}' |