summaryrefslogtreecommitdiff
path: root/service/test/adapter/test_helper.py
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-26 13:11:00 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-26 13:11:00 -0300
commit1082f233962953c0927b73e7acac2665d420857b (patch)
treee6bd8fef98930e5f1bb18041643da261a606fdc4 /service/test/adapter/test_helper.py
parentb4333d2d0955b3f5774bbd1ea97cfdabd5578fd1 (diff)
Fixing tests
Diffstat (limited to 'service/test/adapter/test_helper.py')
-rw-r--r--service/test/adapter/test_helper.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/service/test/adapter/test_helper.py b/service/test/adapter/test_helper.py
index ad39f343..c8593fc1 100644
--- a/service/test/adapter/test_helper.py
+++ b/service/test/adapter/test_helper.py
@@ -15,6 +15,7 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from mock import Mock
from datetime import datetime
+from pixelated.adapter.pixelated_mail import InputMail
LEAP_FLAGS = ['\\Seen',
'\\Answered',
@@ -41,16 +42,30 @@ def mail_dict():
}
-def leap_mail(uid=0, flags=LEAP_FLAGS, headers=DEFAULT_HEADERS, extra_headers={}, mbox='INBOX'):
- headers = dict(headers.items() + extra_headers.items())
- return Mock(getUID=Mock(return_value=uid),
- _mbox=mbox,
- getFlags=Mock(return_value=flags),
- bdoc=Mock(content={'raw': 'test'}),
- hdoc=Mock(content={'headers': headers}))
+def doc(content):
+ class TestDoc:
+ def __init__(self, content):
+ self.content = content
+ return TestDoc(content)
+
+
+def leap_mail(uid=0, flags=LEAP_FLAGS, headers=DEFAULT_HEADERS, extra_headers={}, mbox='INBOX', body='body',
+ chash='chash'):
+ fdoc = doc({'flags': flags, 'mbox': mbox, 'type': 'flags', 'uid': uid, 'chash': chash})
+
+ headers['headers'] = extra_headers
+ hdoc = doc(headers)
+
+ bdoc = doc({'raw': body, 'type': 'cnt'})
+
+ return (fdoc, hdoc, bdoc)
+
+
+def input_mail():
+ mail = InputMail()
+ mail.fdoc = doc({})
+ mail._chash = "123"
+ mail.as_dict = lambda: None
+ return mail
-def leap_mailbox(messages=[leap_mail(uid=6)], mailbox_name='INBOX'):
- return Mock(_get_mbox_doc=Mock(return_value=None),
- mbox=mailbox_name,
- messages=messages)