summaryrefslogtreecommitdiff
path: root/service/test/unit/adapter
diff options
context:
space:
mode:
authorkaeff <hi@kaeff.net>2015-09-04 18:24:38 +0200
committerkaeff <hi@kaeff.net>2015-09-04 18:34:27 +0200
commit5421b5aab20daa59bc378191522db009a557aa68 (patch)
tree7ea0e9e3de4fe1f2a82f06ae4085dfebd7eade76 /service/test/unit/adapter
parentd044a34e9b5a0c341581daae03ba40fc72005170 (diff)
Prepare removing SoledadQuerier from Mail
Discovered that Mail#save was still using SoledadQuerier. There were 3 methods using it: - update_tags: Covered by MailService -> moved test & fixed impl - mark_as_read: Already implemented on MailService -> removed - mark_as_unread: Still needs to be moved - remove_all_tags: Unused -> deleted - mark_as_not_recent: Unused -> deleted Issue: #432
Diffstat (limited to 'service/test/unit/adapter')
-rw-r--r--service/test/unit/adapter/test_mail.py22
-rw-r--r--service/test/unit/adapter/test_mail_service.py11
2 files changed, 11 insertions, 22 deletions
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 03a37c1f..79039b75 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -91,28 +91,6 @@ class TestPixelatedMail(unittest.TestCase):
self.assertEqual(mail.headers['Date'], date_expected)
- @defer.inlineCallbacks
- def test_update_tags_return_a_set_with_the_current_tags(self):
- soledad_docs = test_helper.leap_mail(extra_headers={'X-tags': '["custom_1", "custom_2"]'})
- pixelated_mail = PixelatedMail.from_soledad(*soledad_docs, soledad_querier=self.querier)
-
- current_tags = yield pixelated_mail.update_tags({'custom_1', 'custom_3'})
- self.assertEquals({'custom_3', 'custom_1'}, current_tags)
-
- def test_mark_as_read(self):
- mail = PixelatedMail.from_soledad(*test_helper.leap_mail(flags=[]), soledad_querier=self.querier)
-
- mail.mark_as_read()
-
- self.assertEquals(mail.fdoc.content['flags'], ['\\Seen'])
-
- def test_mark_as_not_recent(self):
- mail = PixelatedMail.from_soledad(*test_helper.leap_mail(flags=['\\Recent']), soledad_querier=self.querier)
-
- mail.mark_as_not_recent()
-
- self.assertEquals(mail.fdoc.content['flags'], [])
-
def test_get_for_save_adds_from(self):
InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
headers = {'Subject': 'The subject',
diff --git a/service/test/unit/adapter/test_mail_service.py b/service/test/unit/adapter/test_mail_service.py
index 677745f2..7dd68706 100644
--- a/service/test/unit/adapter/test_mail_service.py
+++ b/service/test/unit/adapter/test_mail_service.py
@@ -138,3 +138,14 @@ class TestMailService(unittest.TestCase):
attachment = yield self.mail_service.attachment('some attachment id')
self.assertEqual(attachment_dict, attachment)
+
+ @defer.inlineCallbacks
+ def test_update_tags_return_a_set_with_the_current_tags(self):
+ mail = LeapMail(1, 'INBOX', tags={'custom_1', 'custom_2'})
+ when(self.mail_store).get_mail(1, include_body=True).thenReturn(mail)
+ when(self.search_engine).tags(query='', skip_default_tags=True).thenReturn([])
+
+ updated_mail = yield self.mail_service.update_tags(1, {'custom_1', 'custom_3'})
+
+ verify(self.mail_store).update_mail(mail)
+ self.assertEqual({'custom_1', 'custom_3'}, updated_mail.tags)