diff options
Diffstat (limited to 'service/test/integration')
-rw-r--r-- | service/test/integration/__init__.py | 15 | ||||
-rw-r--r-- | service/test/integration/delete_mail_test.py | 40 | ||||
-rw-r--r-- | service/test/integration/drafts_test.py | 62 | ||||
-rw-r--r-- | service/test/integration/mark_as_read_test.py | 38 | ||||
-rw-r--r-- | service/test/integration/tags_test.py | 52 |
5 files changed, 207 insertions, 0 deletions
diff --git a/service/test/integration/__init__.py b/service/test/integration/__init__.py new file mode 100644 index 00000000..2756a319 --- /dev/null +++ b/service/test/integration/__init__.py @@ -0,0 +1,15 @@ +# +# 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/>. diff --git a/service/test/integration/delete_mail_test.py b/service/test/integration/delete_mail_test.py new file mode 100644 index 00000000..3d4a6af7 --- /dev/null +++ b/service/test/integration/delete_mail_test.py @@ -0,0 +1,40 @@ +# +# 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 test.support.integration_helper import MailBuilder, SoledadTestBase + + +class DeleteMailTest(unittest.TestCase, SoledadTestBase): + + def setUp(self): + self.setup_soledad() + + def tearDown(self): + self.teardown_soledad() + + def test_move_mail_to_trash_when_deleting(self): + mail = MailBuilder().with_subject('Mail with tags').build_input_mail() + self.pixelated_mailboxes.inbox().add(mail) + + inbox_mails = self.get_mails_by_tag('inbox') + self.assertEquals(1, len(inbox_mails)) + + self.delete_mail(mail.ident) + + inbox_mails = self.get_mails_by_tag('inbox') + self.assertEquals(0, len(inbox_mails)) + trash_mails = self.get_mails_by_tag('trash') + self.assertEquals(1, len(trash_mails)) diff --git a/service/test/integration/drafts_test.py b/service/test/integration/drafts_test.py new file mode 100644 index 00000000..b70af3f5 --- /dev/null +++ b/service/test/integration/drafts_test.py @@ -0,0 +1,62 @@ +# +# 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 test.support.integration_helper import MailBuilder, SoledadTestBase + + +class DraftsTest(unittest.TestCase, SoledadTestBase): + + def setUp(self): + self.setup_soledad() + + def tearDown(self): + self.teardown_soledad() + + def test_post_creates_a_draft_when_data_has_no_ident(self): + mail = MailBuilder().with_subject('A new draft').build_json() + + self.post_mail(mail) + mails = self.get_mails_by_tag('drafts') + + self.assertEquals('A new draft', mails[0].subject) + + def test_post_sends_mail_and_deletes_previous_draft_when_data_has_ident(self): + first_draft = MailBuilder().with_subject('First draft').build_json() + first_draft_response = self.post_mail(first_draft) + first_draft_ident = first_draft_response.ident + + second_draft = MailBuilder().with_subject('Second draft').with_ident(first_draft_ident).build_json() + self.post_mail(second_draft) + + sent_mails = self.get_mails_by_tag('sent') + drafts = self.get_mails_by_tag('drafts') + + self.assertEquals(1, len(sent_mails)) + self.assertEquals('Second draft', sent_mails[0].subject) + self.assertEquals(0, len(drafts)) + + def test_update_draft(self): + draft = MailBuilder().with_subject('First draft').build_json() + create_draft_response = self.post_mail(draft) + draft_ident = create_draft_response.ident + + updated_draft = MailBuilder().with_subject('First draft edited').with_ident(draft_ident).build_json() + self.put_mail(updated_draft) + + drafts = self.get_mails_by_tag('drafts') + + self.assertEquals(1, len(drafts)) + self.assertEquals('First draft edited', drafts[0].subject) diff --git a/service/test/integration/mark_as_read_test.py b/service/test/integration/mark_as_read_test.py new file mode 100644 index 00000000..2c95ebc1 --- /dev/null +++ b/service/test/integration/mark_as_read_test.py @@ -0,0 +1,38 @@ +# +# 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 test.support.integration_helper import MailBuilder, SoledadTestBase + + +class MarkAsReadTest(unittest.TestCase, SoledadTestBase): + + def setUp(self): + self.setup_soledad() + + def tearDown(self): + self.teardown_soledad() + + def test_mark_as_read(self): + input_mail = MailBuilder().build_input_mail() + self.pixelated_mailboxes.inbox().add(input_mail) + + mails = self.get_mails_by_tag('inbox') + self.assertFalse('read' in mails[0].status) + + self.mark_as_read(input_mail.ident) + + mails = self.get_mails_by_tag('inbox') + self.assertTrue('read' in mails[0].status) diff --git a/service/test/integration/tags_test.py b/service/test/integration/tags_test.py new file mode 100644 index 00000000..e2ef1c0e --- /dev/null +++ b/service/test/integration/tags_test.py @@ -0,0 +1,52 @@ +# +# 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 json +import unittest +from test.support.integration_helper import MailBuilder, SoledadTestBase + + +class TagsTest(unittest.TestCase, SoledadTestBase): + + def setUp(self): + self.setup_soledad() + + def tearDown(self): + self.teardown_soledad() + + def _tags_json(self, tags): + return json.dumps({'newtags': tags}) + + def test_add_tag_to_an_inbox_mail_and_query(self): + mail = MailBuilder().with_subject('Mail with tags').build_input_mail() + self.pixelated_mailboxes.inbox().add(mail) + + self.post_tags(mail.ident, self._tags_json(['IMPORTANT'])) + + mails = self.get_mails_by_tag('inbox') + self.assertEquals({'important'}, set(mails[0].tags)) + + mails = self.get_mails_by_tag('important') + self.assertEquals('Mail with tags', mails[0].subject) + + def test_addition_of_reserved_tags_is_not_allowed(self): + mail = MailBuilder().with_subject('Mail with tags').build_input_mail() + self.pixelated_mailboxes.inbox().add(mail) + + response = self.post_tags(mail.ident, self._tags_json(['DRAFTS'])) + self.assertEquals("None of the following words can be used as tags: drafts", response) + + mail = self.pixelated_mailboxes.inbox().mail(mail.ident) + self.assertNotIn('drafts', mail.tags) |