diff options
author | Patrick Maia and Victor Shyba <pixelated-team+pmaia+vshyba@thoughtworks.com> | 2014-09-05 22:45:55 +0000 |
---|---|---|
committer | Patrick Maia <pmaia@thoughtworks.com> | 2014-09-05 22:46:17 +0000 |
commit | 3c79a54ab332e15f31a4a57a4a9baabf4b62e26a (patch) | |
tree | ce6b592049227da18b0500f4695b0feb490a944d /service/test/adapter/pixelated_mailbox_test.py | |
parent | d2cf8b51904420917a5f86986ce7c02e89935998 (diff) |
#51 - persists new tags globally (in a local file) and shows on tag list
Diffstat (limited to 'service/test/adapter/pixelated_mailbox_test.py')
-rw-r--r-- | service/test/adapter/pixelated_mailbox_test.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index 1047eed4..2944275f 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -14,28 +14,42 @@ # 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 +import os import test_helper from pixelated.adapter.tag import Tag +from pixelated.adapter.tag_index import TagIndex from pixelated.adapter.pixelated_mailbox import PixelatedMailbox class TestPixelatedMailbox(unittest.TestCase): - def test_retrieve_all_tags_from_mailbox(self): - leap_flags = ['\\Deleted', '\\Draft', '\\Recent', 'tag_custom', 'should_ignore_all_from_here', 'List'] - mailbox = PixelatedMailbox(test_helper.leap_mailbox(leap_flags=leap_flags)) - - self.assertEquals(set([Tag('trash'), Tag('inbox'), Tag('drafts'), Tag('custom')]), mailbox.all_tags()) + def setUp(self): + self.db_file_path = '/tmp/test_tags' - def test_new_tags_are_added_to_mailbox(self): - leap_flags = ['\\Deleted', 'tag_custom_one', 'tag_custom_two'] - leap_mailbox_mock = test_helper.leap_mailbox(leap_flags=leap_flags) - mailbox = PixelatedMailbox(leap_mailbox_mock) - tags = [Tag('custom_one'), Tag('custom_three')] - mailbox.update_tags(tags) + def tearDown(self): + os.remove(self.db_file_path + '.db') - expected = set(('\\Deleted', 'tag_custom_one', 'tag_custom_two', 'tag_custom_three')) - actual_args = set(leap_mailbox_mock.setFlags.call_args[0][0]) + def test_special_tags_always_exists(self): + mailbox = PixelatedMailbox(test_helper.leap_mailbox(), self.db_file_path) + self.assertEquals(mailbox.SPECIAL_TAGS, mailbox.all_tags()) - self.assertEquals(expected, actual_args) + def test_retrieve_all_tags_from_mailbox(self): + tag_index = TagIndex(self.db_file_path) + tag_index.set(Tag('one_tag')) + tag_index.set(Tag('two_tag')) + tag_index.close_db() + mailbox = PixelatedMailbox(test_helper.leap_mailbox(), self.db_file_path) + expected_tags = set([Tag('one_tag'), Tag('two_tag')]).union(mailbox.SPECIAL_TAGS) + self.assertEquals(expected_tags, mailbox.all_tags()) + + def test_notify_tags_updated_method_properly_changes_tags_state(self): + tag_index = TagIndex(self.db_file_path) + tag = Tag('one_tag') + tag.increment(12) + tag_index.set(tag) + tag_index.close_db() + mailbox = PixelatedMailbox(test_helper.leap_mailbox(), self.db_file_path) + self.assertEquals(0, mailbox.tag_index.get('inbox').total) + mailbox.notify_tags_updated(set(['inbox']), set(['one_tag']), 12) + self.assertEquals(1, mailbox.tag_index.get('inbox').total) |