From f43cbb106d81ba3f595f5f1c3540f21bcf204471 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Sat, 15 Mar 2008 20:24:46 +0000 Subject: Added new option --all to archive all messages in a mailbox. Updated documentation, and added a first simple unittest for this. Closes: #1764846. --- test_archivemail.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test_archivemail.py') diff --git a/test_archivemail.py b/test_archivemail.py index 86b6e78..9cf1986 100755 --- a/test_archivemail.py +++ b/test_archivemail.py @@ -722,6 +722,42 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir): super(TestArchiveMboxTimestamp, self).tearDown() +class TestArchiveMboxAll(TestCaseInTempdir): + def setUp(self): + super(TestArchiveMboxAll, self).setUp() + archivemail.options.quiet = 1 + archivemail.options.archive_all = 1 + + def testNew(self): + """archiving --all messages in a new mailbox""" + for execute in ("package", "system"): + self.mbox_name = make_mbox(messages=3, hours_old=(24 * 179)) + self.mbox_mode = os.stat(self.mbox_name)[stat.ST_MODE] + self.copy_name = tempfile.mkstemp()[1] + shutil.copyfile(self.mbox_name, self.copy_name) + if execute == "package": + archivemail.archive(self.mbox_name) + elif execute == "system": + run = "./archivemail.py --all --quiet %s" % self.mbox_name + self.assertEqual(os.system(run), 0) + else: + sys.exit(1) + assert(os.path.exists(self.mbox_name)) + self.assertEqual(os.path.getsize(self.mbox_name), 0) + new_mode = os.stat(self.mbox_name)[stat.ST_MODE] + self.assertEqual(self.mbox_mode, new_mode) + archive_name = self.mbox_name + "_archive.gz" + assert(os.path.exists(archive_name)) + self.assertEqual(os.system("gzip -d %s" % archive_name), 0) + archive_name = self.mbox_name + "_archive" + assert(os.path.exists(archive_name)) + assert(filecmp.cmp(archive_name, self.copy_name, shallow=0)) + + def tearDown(self): + archivemail.options.quiet = 0 + archivemail.options.archive_all = 0 + super(TestArchiveMboxAll, self).tearDown() + class TestArchiveMboxPreserveStatus(TestCaseInTempdir): """make sure the 'preserve_unread' option works""" def setUp(self): -- cgit v1.2.3