[#927] Adds date to recovery code email
authorAnike Arni <aarni@thoughtworks.com>
Wed, 19 Apr 2017 16:51:47 +0000 (13:51 -0300)
committerAnike Arni <aarni@thoughtworks.com>
Wed, 19 Apr 2017 17:11:44 +0000 (14:11 -0300)
with @deniscostadsc

service/pixelated/account_recovery.py
service/pixelated/assets/recovery.mail.pt-BR
service/test/unit/test_account_recovery.py

index d2110bb..dae3da1 100644 (file)
@@ -22,6 +22,7 @@ from twisted.logger import Logger
 from twisted.mail import smtp
 
 from email import message_from_string
+from email.utils import formatdate
 
 from pixelated.resources.account_recovery_resource import AccountRecoveryResource
 
@@ -85,4 +86,4 @@ class AccountRecovery(object):
                 account_recovery_url=account_recovery_url,
                 backup_email=backup_email,
                 sender=sender,
-                date='Sat, 21 Mar 2015 19:30:09 -0300'))
+                date=formatdate(localtime=True)))
index 8ef07a8..7d0f2a5 100644 (file)
@@ -1,6 +1,6 @@
 From: {sender}
 Date: {date}
-Subject: Código de Recuperação
+Subject: Codigo de Recuperacao
 To: {backup_email}
 Content-Type: text/plain; charset=UTF-8
 
index e595fc5..cb5ed52 100644 (file)
@@ -85,11 +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.smtp.sendmail')
     @patch('pixelated.account_recovery.pkg_resources.resource_filename')
     @defer.inlineCallbacks
-    def test_send_recovery_code_by_email(self, mock_resource, mock_sendmail):
+    def test_send_recovery_code_by_email(self, mock_resource, mock_sendmail, mock_formatdate):
         mock_sendmail.return_value = defer.succeed(None)
+        mock_formatdate.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}, {account_recovery_url}'