diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-22 10:49:25 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-22 10:58:27 -0300 |
commit | ed5520b54a7885f446671440d6a8a7bd3e05ea0b (patch) | |
tree | ceb6e84ca7a54d1a7f04e25512e923b1bb91ffc8 | |
parent | f8b0bc06ee661eff29f4b15f495823f1c6aca873 (diff) |
PixelatedMailbox to call mail#mark_as_deleted on removing mail (feature
envy removal)
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 4 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 3 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailboxes.py | 1 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mail_test.py | 9 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mailbox_test.py | 7 |
5 files changed, 14 insertions, 10 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index 29dbdaa3..4ec9a7cd 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -96,6 +96,10 @@ class PixelatedMail: return set(tags) return set(json.loads(tags)) + def mark_as_deleted(self): + self.remove_all_tags() + self.leap_mail.setFlags((Status.PixelatedStatus.DELETED,), 1) + def remove_all_tags(self): self.update_tags(set([])) diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index fc28c733..4d558ea3 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -71,7 +71,8 @@ class PixelatedMailbox: return self.leap_mailbox.messages.add_msg(raw) def remove(self, mail): - mail.leap_mail.setFlags((Status.PixelatedStatus.DELETED,), 1) + mail.mark_as_deleted() + self.leap_mailbox.expunge() @classmethod diff --git a/service/pixelated/adapter/pixelated_mailboxes.py b/service/pixelated/adapter/pixelated_mailboxes.py index 850db9d9..ad88d438 100644 --- a/service/pixelated/adapter/pixelated_mailboxes.py +++ b/service/pixelated/adapter/pixelated_mailboxes.py @@ -43,7 +43,6 @@ class PixelatedMailBoxes(): return new_mail def move_to_trash(self, mail): - mail.remove_all_tags() origin_mailbox = mail.mailbox_name new_mail_id = self.trash().add(mail) diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py index c9f5e67d..0a103cce 100644 --- a/service/test/adapter/pixelated_mail_test.py +++ b/service/test/adapter/pixelated_mail_test.py @@ -147,12 +147,15 @@ class TestPixelatedMail(unittest.TestCase): self.assertEquals(mail.leap_mail.setFlags.call_args[0], (('\\Recent',), -1)) - def test_remove_all_tags(self): - mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(extra_headers={'X-Tags': '["skinka", "altoids"]'}), Mock()) + def test_mark_as_deleted(self): + mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(extra_headers={'X-Tags': '["skinka", "altoids"]'}, flags=[]), Mock()) + self.assertEquals(set(['skinka', 'altoids']), mail.tags) - mail.remove_all_tags() + mail.mark_as_deleted() + self.assertEquals(set([]), mail.tags) + self.assertEquals(mail.leap_mail.setFlags.call_args[0], ((u'\\Deleted',), 1)) def test_update_tags_notifies_tag_service(self): db_path = '/tmp/test_update_tags_notifies_tag_service' diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index 8bff7e68..847ce20c 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -62,13 +62,10 @@ class PixelatedMailboxTest(unittest.TestCase): verify(leap_mailbox_messages).add_msg('smtp format mail') def test_remove_message_from_mailbox(self): - mail = PixelatedMail.from_dict(test_helper.mail_dict()) - mail.raw_message = lambda: 'the mail in smtp format' - - mail.leap_mail = mock() + mail = mock() self.mailbox.leap_mailbox = mock() self.mailbox.remove(mail) - verify(mail.leap_mail).setFlags((Status.PixelatedStatus.DELETED,), 1) + verify(mail).mark_as_deleted() verify(self.mailbox.leap_mailbox).expunge() |