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
53
54
55
56
57
58
59
60
61
|
#
# 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.tag import Tag
class TestTag(unittest.TestCase):
def test_leap_recent_flag_is_translated_to_inbox_tag(self):
tag = Tag.from_flag('\\Recent')
self.assertEquals(Tag('inbox'), tag)
def test_leap_deleted_flag_is_translated_to_trash_tag(self):
tag = Tag.from_flag('\\Deleted')
self.assertEquals(Tag('trash'), tag)
def test_leap_draft_flag_is_translated_to_draft_tag(self):
tag = Tag.from_flag('\\Draft')
self.assertEquals(Tag('drafts'), tag)
def test_leap_flags_that_are_custom_tags_are_handled(self):
tag = Tag.from_flag('tag_work')
self.assertEquals(Tag('work'), tag)
def test_custom_tags_containing_our_prefix_are_handled(self):
tag = Tag.from_flag('tag_tag_work_tag_')
self.assertEquals(Tag('tag_work_tag_'), tag)
def test_bulk_conversion(self):
tags = Tag.from_flags(['\\Answered', '\\Seen', '\\Recent', 'tag_a_custom', 'List'])
self.assertEquals(set([Tag('inbox'), Tag('a_custom')]), tags)
def test_inbox_tag_is_translated_to_leap_recent_flag(self):
flag = Tag('inbox').to_flag()
self.assertEquals('\\Recent', flag)
def test_trash_tag_is_translated_to_leap_deleted_flag(self):
flag = Tag('trash').to_flag()
self.assertEquals('\\Deleted', flag)
def test_drafts_tag_is_translated_to_leap_draft_flag(self):
flag = Tag('drafts').to_flag()
self.assertEquals('\\Draft', flag)
def test_custom_tag_has_prefix_when_translated_to_flag(self):
flag = Tag('work').to_flag()
self.assertEquals('tag_work', flag)
|