summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Ferraz <tiago.ferraz@gmail.com>2015-03-24 12:26:56 -0300
committerTiago Ferraz <tiago.ferraz@gmail.com>2015-03-24 12:26:56 -0300
commit520cd217ed34fc541c0234c6add78a093569a082 (patch)
tree776316a4e4260d0303608dff95811005b0e852f8
parent507934e8d9c9c156c51a31cd2fa87a4adb6088d4 (diff)
Fix pep8 errors of lambda functions
Altered lambda function to def in order to fix pep8 E371 errors
-rw-r--r--service/test/support/test_helper.py4
-rw-r--r--service/test/unit/adapter/test_mail.py21
2 files changed, 14 insertions, 11 deletions
diff --git a/service/test/support/test_helper.py b/service/test/support/test_helper.py
index 0f42e433..c37c1408 100644
--- a/service/test/support/test_helper.py
+++ b/service/test/support/test_helper.py
@@ -15,6 +15,7 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
import io
+from twisted.web.test.test_web import DummyRequest
from pixelated.adapter.model.mail import InputMail, PixelatedMail
@@ -88,9 +89,6 @@ class TestRequest:
self.json = json
-from twisted.web.test.test_web import DummyRequest
-
-
class PixRequestMock(DummyRequest):
def __init__(self, path):
DummyRequest.__init__(self, path)
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 1b83f79e..c7910b7f 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -335,8 +335,8 @@ class TestPixelatedMail(unittest.TestCase):
mail.as_dict()
-class InputMailTest(unittest.TestCase):
- mail_dict = lambda x: {
+def simple_mail_dict():
+ return {
'body': 'Este \xe9 o corpo',
'header': {
'cc': ['cc@pixelated.org', 'anothercc@pixelated.org'],
@@ -348,7 +348,9 @@ class InputMailTest(unittest.TestCase):
'tags': ['sent']
}
- multipart_mail_dict = lambda x: {
+
+def multipart_mail_dict():
+ return {
'body': [{'content-type': 'plain', 'raw': 'Hello world!'},
{'content-type': 'html', 'raw': '<p>Hello html world!</p>'}],
'header': {
@@ -361,10 +363,13 @@ class InputMailTest(unittest.TestCase):
'tags': ['sent']
}
+
+class InputMailTest(unittest.TestCase):
+
def test_to_mime_multipart_should_add_blank_fields(self):
pixelated.support.date.iso_now = lambda: 'date now'
- mail_dict = self.mail_dict()
+ mail_dict = simple_mail_dict()
mail_dict['header']['to'] = ''
mail_dict['header']['bcc'] = ''
mail_dict['header']['cc'] = ''
@@ -380,24 +385,24 @@ class InputMailTest(unittest.TestCase):
def test_to_mime_multipart(self):
pixelated.support.date.iso_now = lambda: 'date now'
- mime_multipart = InputMail.from_dict(self.mail_dict()).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(simple_mail_dict()).to_mime_multipart()
self.assertRegexpMatches(mime_multipart.as_string(), "\nTo: to@pixelated.org, anotherto@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nCc: cc@pixelated.org, anothercc@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nBcc: bcc@pixelated.org, anotherbcc@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nDate: date now\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nSubject: Oi\n")
- self.assertRegexpMatches(mime_multipart.as_string(), base64.b64encode(self.mail_dict()['body']))
+ self.assertRegexpMatches(mime_multipart.as_string(), base64.b64encode(simple_mail_dict()['body']))
def test_smtp_format(self):
InputMail.FROM_EMAIL_ADDRESS = 'pixelated@org'
- smtp_format = InputMail.from_dict(self.mail_dict()).to_smtp_format()
+ smtp_format = InputMail.from_dict(simple_mail_dict()).to_smtp_format()
self.assertRegexpMatches(smtp_format, "\nFrom: pixelated@org")
def test_to_mime_multipart_handles_alternative_bodies(self):
- mime_multipart = InputMail.from_dict(self.multipart_mail_dict()).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(multipart_mail_dict()).to_mime_multipart()
part_one = 'Content-Type: text/plain; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\nHello world!'
part_two = 'Content-Type: text/html; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\n<p>Hello html world!</p>'