summaryrefslogtreecommitdiff
path: root/service/test/adapter/pixelated_mail_test.py
blob: b0e2f9d25fad548996f59c274bba28be324711d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 unittest

from pixelated.adapter.pixelated_mail import PixelatedMail
from pixelated.tags import Tag
from pixelated.tags import Tags
import test_helper


class TestPixelatedMail(unittest.TestCase):

    def test_leap_recent_flag_is_translated_to_inbox_tag(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Recent']))
        self.assertIn(Tag('inbox'), pixelated_mail.tags)

    def test_leap_deleted_flag_is_translated_to_trash_tag(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Deleted']))
        self.assertIn(Tag('trash'), pixelated_mail.tags)

    def test_leap_draft_flag_is_translated_to_draft_tag(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Draft']))
        self.assertIn(Tag('drafts'), pixelated_mail.tags)

    def test_leap_seen_flag_is_translated_to_read_status(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Seen']))
        self.assertIn('read', pixelated_mail.status)

    def test_leap_answered_flag_is_translated_to_replied_status(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Answered']))
        self.assertIn('replied', pixelated_mail.status)

    def test_leap_flags_that_are_custom_tags_are_handled(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(extra_flags=['tag_work']))
        self.assertIn(Tag('work'), pixelated_mail.tags)

    def test_custom_tags_containing_our_prefix_are_handled(self):
        pixelated_mail = PixelatedMail(test_helper.leap_mail(extra_flags=['tag_tag_work_tag_']))
        self.assertIn(Tag('tag_work_tag_'), pixelated_mail.tags)