summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
Diffstat (limited to 'service/test')
-rw-r--r--service/test/integration/test_mark_as_read_unread.py29
-rw-r--r--service/test/support/integration/app_test_client.py10
2 files changed, 27 insertions, 12 deletions
diff --git a/service/test/integration/test_mark_as_read_unread.py b/service/test/integration/test_mark_as_read_unread.py
index 18c3ddc2..c01deefc 100644
--- a/service/test/integration/test_mark_as_read_unread.py
+++ b/service/test/integration/test_mark_as_read_unread.py
@@ -30,32 +30,40 @@ class MarkAsReadUnreadTest(SoledadTestBase):
mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertNotIn('read', mails[0].status)
- yield self.app_test_client.mark_many_as_read([mail.ident])
+ response, first_request = yield self.app_test_client.get('/', as_json=False)
+ session = first_request.getSession()
+ yield self.app_test_client.mark_many_as_read([mail.ident], session)
mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertIn('read', mails[0].status)
@defer.inlineCallbacks
def test_mark_single_as_unread(self):
+ response, first_request = yield self.app_test_client.get('/', as_json=False)
+ session = first_request.getSession()
+
input_mail = MailBuilder().build_input_mail()
mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- yield self.app_test_client.mark_many_as_read([mail.ident])
+ yield self.app_test_client.mark_many_as_read([mail.ident], session)
- yield self.app_test_client.mark_many_as_unread([mail.ident])
+ yield self.app_test_client.mark_many_as_unread([mail.ident], session)
result = (yield self.app_test_client.get_mails_by_tag('inbox'))[0]
self.assertNotIn('read', result.status)
@defer.inlineCallbacks
def test_mark_many_mails_as_unread(self):
+ response, first_request = yield self.app_test_client.get('/', as_json=False)
+ session = first_request.getSession()
+
input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail()
input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail()
mail1 = yield self.app_test_client.add_mail_to_inbox(input_mail)
mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
- yield self.app_test_client.mark_many_as_read([mail1.ident, mail2.ident])
+ yield self.app_test_client.mark_many_as_read([mail1.ident, mail2.ident], session)
- yield self.app_test_client.mark_many_as_unread([mail1.ident, mail2.ident])
+ yield self.app_test_client.mark_many_as_unread([mail1.ident, mail2.ident], session)
mails = yield self.app_test_client.get_mails_by_tag('inbox')
@@ -75,7 +83,9 @@ class MarkAsReadUnreadTest(SoledadTestBase):
self.assertNotIn('read', mails[0].status)
self.assertNotIn('read', mails[1].status)
- yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident])
+ response, first_request = yield self.app_test_client.get('/', as_json=False)
+ session = first_request.getSession()
+ yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident], session)
mails = yield self.app_test_client.get_mails_by_tag('inbox')
@@ -84,12 +94,15 @@ class MarkAsReadUnreadTest(SoledadTestBase):
@defer.inlineCallbacks
def test_mark_mixed_status_as_read(self):
+ response, first_request = yield self.app_test_client.get('/', as_json=False)
+ session = first_request.getSession()
+
input_mail = MailBuilder().with_subject('first').build_input_mail()
input_mail2 = MailBuilder().with_subject('second').build_input_mail()
yield self.app_test_client.add_mail_to_inbox(input_mail)
mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
- yield self.app_test_client.mark_many_as_read([mail2.ident])
+ yield self.app_test_client.mark_many_as_read([mail2.ident], session)
mails = yield self.app_test_client.get_mails_by_tag('inbox')
@@ -98,7 +111,7 @@ class MarkAsReadUnreadTest(SoledadTestBase):
self.assertEquals(1, len(unread_mails))
self.assertEquals(1, len(read_mails))
- yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident])
+ yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident], session)
mails = yield self.app_test_client.get_mails_by_tag('inbox')
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index f04f67fd..e5d42505 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -405,12 +405,14 @@ class AppTestClient(object):
res, req = self.post("/mails/delete", json.dumps({'idents': idents}), csrf=csrf, session=session)
return res
- def mark_many_as_unread(self, idents):
- res, req = self.post('/mails/unread', json.dumps({'idents': idents}))
+ def mark_many_as_unread(self, idents, session):
+ csrf = IPixelatedSession(session).get_csrf_token()
+ res, req = self.post('/mails/unread', json.dumps({'idents': idents}), csrf=csrf, session=session)
return res
- def mark_many_as_read(self, idents):
- res, req = self.post('/mails/read', json.dumps({'idents': idents}))
+ def mark_many_as_read(self, idents, session):
+ csrf = IPixelatedSession(session).get_csrf_token()
+ res, req = self.post('/mails/read', json.dumps({'idents': idents}), csrf=csrf, session=session)
return res
def get_contacts(self, query):