From 6202f768b15b7311bb3024da2b7f182c25f57043 Mon Sep 17 00:00:00 2001 From: Jefferson Stachelski Date: Wed, 29 Apr 2015 17:30:14 -0300 Subject: #337 Created a validation to just open file that the file name starts with 'mbox' and ends with a number --- service/test/unit/maintenance/test_commands.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'service/test/unit/maintenance') diff --git a/service/test/unit/maintenance/test_commands.py b/service/test/unit/maintenance/test_commands.py index 6c881cb9..2c47da40 100644 --- a/service/test/unit/maintenance/test_commands.py +++ b/service/test/unit/maintenance/test_commands.py @@ -16,7 +16,7 @@ import unittest import email -from pixelated.maintenance import delete_all_mails, load_mails +from pixelated.maintenance import delete_all_mails, load_mails, is_mail_file_name_valid from pixelated.bitmask_libraries.session import LeapSession from leap.mail.imap.account import SoledadBackedAccount from leap.soledad.client import Soledad @@ -80,7 +80,7 @@ class TestCommands(unittest.TestCase): def test_load_mails_adds_mails(self): mail_root = join(dirname(__file__), '..', 'fixtures', 'mailset') - foo = load_mails(self.args, [mail_root]) + load_mails(self.args, [mail_root]) self.assertTrue(self.mailbox.addMessage.called) self.mailbox.addMessage.assert_any_call(self._mail_content(join(mail_root, 'mbox00000000')), flags=("\\RECENT",), notify_on_disk=False) @@ -90,3 +90,10 @@ class TestCommands(unittest.TestCase): with open(mail_file, 'r') as fp: m = email.message_from_file(fp) return m.as_string() + + def test_the_filter_should_validate_right_file_naming(self): + file_name = 'mbox00000' + + validation = is_mail_file_name_valid(file_name) + + self.assertTrue(validation) -- cgit v1.2.3