diff options
Diffstat (limited to 'service/test/support/integration/soledad_test_base.py')
-rw-r--r-- | service/test/support/integration/soledad_test_base.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/service/test/support/integration/soledad_test_base.py b/service/test/support/integration/soledad_test_base.py new file mode 100644 index 00000000..2221679f --- /dev/null +++ b/service/test/support/integration/soledad_test_base.py @@ -0,0 +1,83 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# 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 pixelated.controllers import * +from test.support.integration.app_test_client import AppTestClient +from test.support.integration.model import ResponseMail + + +class SoledadTestBase(unittest.TestCase): + # these are so long because our CI is so slow at the moment. + DEFERRED_TIMEOUT = 120 + DEFERRED_TIMEOUT_LONG = 300 + + @classmethod + def setUpClass(cls): + from nose.twistedtools import threaded_reactor + + threaded_reactor() + + def setUp(self): + self.client = AppTestClient() + + def get_mails_by_tag(self, tag, page=1, window=100): + res, req = self.client.get("/mails", { + 'q': ['tag:%s' % tag], + 'w': [str(window)], + 'p': [str(page)] + }) + return [ResponseMail(m) for m in res['mails']] + + def post_mail(self, data): + res, req = self.client.post('/mails', data) + return ResponseMail(res) + + def get_attachment(self, ident, encoding): + res, req = self.client.get("/attachment/%s" % ident, {'encoding': [encoding]}, as_json=False) + return res + + def put_mail(self, data): + res, req = self.client.put('/mails', data) + return res['ident'] + + def post_tags(self, mail_ident, tags_json): + res, req = self.client.post("/mail/%s/tags" % mail_ident, tags_json) + return res + + def get_tags(self, **kwargs): + res, req = self.client.get('/tags', kwargs) + return res + + def delete_mail(self, mail_ident): + res, req = self.client.delete("/mail/%s" % mail_ident) + return req + + def mark_as_read(self, mail_ident): + res, req = self.client.post("/mail/%s/read" % mail_ident) + return req + + def mark_as_unread(self, mail_ident): + res, req = self.client.post("/mail/%s/unread" % mail_ident) + return req + + def mark_many_as_unread(self, idents): + res, req = self.client.post('/mails/unread', json.dumps({'idents': idents})) + return req + + def mark_many_as_read(self, idents): + res, req = self.client.post('/mails/read', json.dumps({'idents': idents})) + return req |