summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-29 09:55:53 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-29 09:59:19 -0300
commit34df7f4dde3f481ff9c50dbb2338507ab70b04dd (patch)
tree860bb7e22d051ef609978319d73a59acdba14279
parent363196b8f860fb2ed487a07c5b7c36aa6cec9268 (diff)
fixing tests and pep8
-rw-r--r--service/pixelated/adapter/pixelated_mail.py1
-rw-r--r--service/test/adapter/mail_service_test.py6
-rw-r--r--service/test/adapter/pixelated_mail_test.py5
-rw-r--r--service/test/adapter/pixelated_mailboxes_test.py5
-rw-r--r--service/test/adapter/test_helper.py10
-rw-r--r--service/test/user_agent_test.py4
6 files changed, 17 insertions, 14 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py
index 2f00e6e8..89320b75 100644
--- a/service/pixelated/adapter/pixelated_mail.py
+++ b/service/pixelated/adapter/pixelated_mail.py
@@ -52,7 +52,6 @@ class InputMail:
def from_dict(mail_dict):
return input_mail_from_dict(mail_dict)
-
@property
def _mime_multipart(self):
if self._mime:
diff --git a/service/test/adapter/mail_service_test.py b/service/test/adapter/mail_service_test.py
index 38542cac..7912241d 100644
--- a/service/test/adapter/mail_service_test.py
+++ b/service/test/adapter/mail_service_test.py
@@ -26,13 +26,17 @@ class TestMailService(unittest.TestCase):
pixelated.adapter.soledad_querier.get_soledad_querier_instance = lambda x, y: self.querier
self.mailboxes = mock()
+ self.mailboxes.drafts = lambda: mock()
+ self.mailboxes.trash = lambda: mock()
+ self.mailboxes.sent = lambda: mock()
+
self.mail_sender = mock()
self.mail_service = MailService(self.mailboxes, self.mail_sender)
def test_send_mail(self):
mail = "mail"
- self.mail_service.send(mail)
+ self.mail_service.send(1, mail)
verify(self.mail_sender).sendmail(mail)
diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py
index 4e579cb7..28f70afa 100644
--- a/service/test/adapter/pixelated_mail_test.py
+++ b/service/test/adapter/pixelated_mail_test.py
@@ -24,6 +24,7 @@ from pixelated.adapter.tag_index import TagIndex
from pixelated.adapter.tag import Tag
from mockito import *
+
class TestPixelatedMail(unittest.TestCase):
def setUp(self):
@@ -82,6 +83,7 @@ class TestPixelatedMail(unittest.TestCase):
os.remove(db_path + '.db')
+
class InputMailTest(unittest.TestCase):
mail_dict = lambda x: {
'body': 'Este \xe9 o corpo',
@@ -95,7 +97,6 @@ class InputMailTest(unittest.TestCase):
'tags': ['sent']
}
-
def test_to_mime_multipart_should_add_blank_fields(self):
pixelated.support.date.iso_now = lambda: 'date now'
@@ -112,7 +113,6 @@ class InputMailTest(unittest.TestCase):
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nCc: \n")
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nSubject: \n")
-
def test_to_mime_multipart(self):
pixelated.support.date.iso_now = lambda: 'date now'
@@ -125,7 +125,6 @@ class InputMailTest(unittest.TestCase):
self.assertRegexpMatches(mime_multipart.as_string(), "\nSubject: Oi\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nEste \xe9 o corpo")
-
def test_smtp_format(self):
PixelatedMail.from_email_address = 'pixelated@org'
diff --git a/service/test/adapter/pixelated_mailboxes_test.py b/service/test/adapter/pixelated_mailboxes_test.py
index b13c7c33..dc7243f2 100644
--- a/service/test/adapter/pixelated_mailboxes_test.py
+++ b/service/test/adapter/pixelated_mailboxes_test.py
@@ -14,15 +14,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import unittest
+
from test.adapter import test_helper
from mockito import *
-
import pixelated.adapter.soledad_querier
+
querier = mock()
global querier
pixelated.adapter.soledad_querier.get_soledad_querier_instance = lambda x, y: querier
-from pixelated.adapter.pixelated_mail import PixelatedMail
from pixelated.adapter.pixelated_mail import InputMail
from pixelated.adapter.pixelated_mailbox import PixelatedMailbox
from pixelated.adapter.pixelated_mailboxes import PixelatedMailBoxes
@@ -66,4 +66,3 @@ class PixelatedMailboxesTest(unittest.TestCase):
inorder.verify(self.drafts_mailbox).add(mail)
inorder.verify(self.drafts_mailbox).remove(mail.ident)
-
diff --git a/service/test/adapter/test_helper.py b/service/test/adapter/test_helper.py
index 86552008..af0fed95 100644
--- a/service/test/adapter/test_helper.py
+++ b/service/test/adapter/test_helper.py
@@ -27,6 +27,7 @@ LEAP_FLAGS = ['\\Seen',
DEFAULT_HEADERS = {'date': str(datetime.now())}
+
def mail_dict():
return {
'header': {
@@ -40,16 +41,20 @@ def mail_dict():
'tags': []
}
+
class TestDoc:
def __init__(self, content):
self.content = content
+
def leap_mail(uid=0, flags=LEAP_FLAGS, headers=None, extra_headers={}, mbox='INBOX', body='body',
chash='chash'):
fdoc = TestDoc({'flags': flags, 'mbox': mbox, 'type': 'flags', 'uid': uid, 'chash': chash})
- if headers is None: headers = {}
- if not (headers.get('received') or headers.get('date')): headers.update(DEFAULT_HEADERS)
+ if headers is None:
+ headers = {}
+ if not (headers.get('received') or headers.get('date')):
+ headers.update(DEFAULT_HEADERS)
headers['headers'] = extra_headers
hdoc = TestDoc(headers)
@@ -64,4 +69,3 @@ def input_mail():
mail._chash = "123"
mail.as_dict = lambda: None
return mail
-
diff --git a/service/test/user_agent_test.py b/service/test/user_agent_test.py
index d5432cbd..d0cfc5a9 100644
--- a/service/test/user_agent_test.py
+++ b/service/test/user_agent_test.py
@@ -47,7 +47,7 @@ class UserAgentTest(unittest.TestCase):
self.app.post('/mails', data='{"ident":1}', content_type="application/json")
- verify(self.mail_service).send_draft(self.input_mail)
+ verify(self.mail_service).send(1, self.input_mail)
def test_update_draft(self):
self.input_mail = self.draft()
@@ -58,7 +58,5 @@ class UserAgentTest(unittest.TestCase):
verify(self.mail_service).update_draft(1, self.input_mail)
-
-
def draft(self):
return test_helper.input_mail()