summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnike Arni <aarni@thoughtworks.com>2017-04-20 16:24:47 -0300
committerAnike Arni <aarni@thoughtworks.com>2017-04-20 16:24:47 -0300
commit93621607efc7b907fd30b06b000afb9430ccecfe (patch)
treeaba9d514de07f3523e907d99fcc65119f6e8f7f3
parent014dde1cf661d2cc43dda79dcfa94ddc6a6b5ed0 (diff)
[#927] Uses internal email date method for consistency
with @deniscostadsc
-rw-r--r--service/pixelated/account_recovery.py7
-rw-r--r--service/test/unit/test_account_recovery.py6
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}'