aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2008-09-30 13:31:54 +0200
committerNikolaus Schulz <microschulz@web.de>2010-07-19 01:13:25 +0200
commit41da26b655bea7cdfe5e4f246e7e193d74ac824c (patch)
treed39758d9ba853fef060e0fc4a15a88ec1db6df57
parent6d2e23ac806f7a9def231e201b48879d304c4cd6 (diff)
downloadarchivemail-41da26b655bea7cdfe5e4f246e7e193d74ac824c.tar.gz
archivemail-41da26b655bea7cdfe5e4f246e7e193d74ac824c.tar.bz2
archivemail-41da26b655bea7cdfe5e4f246e7e193d74ac824c.zip
test suite: cut down the test of the --size option
Don't do entire test archiving runs, just call archivemail.should_archive().
-rwxr-xr-xtest_archivemail.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/test_archivemail.py b/test_archivemail.py
index 519df72..44c7823 100755
--- a/test_archivemail.py
+++ b/test_archivemail.py
@@ -1042,41 +1042,28 @@ class TestArchiveMboxUncompressed(TestCaseInTempdir):
super(TestArchiveMboxUncompressed, self).tearDown()
-class TestArchiveSize(TestCaseInTempdir):
+class TestArchiveSize(unittest.TestCase):
"""check that the 'size' argument works"""
def setUp(self):
- super(TestArchiveSize, self).setUp()
archivemail.options.quiet = 1
+ msg_text = make_message(hours_old=24*181)
+ self.msg_size = len(msg_text)
+ fp = cStringIO.StringIO(msg_text)
+ self.msg = rfc822.Message(fp)
def testSmaller(self):
"""giving a size argument smaller than the message"""
- self.mbox_name = make_mbox(messages=1, hours_old=(24 * 181))
- size_arg = os.path.getsize(self.mbox_name) - 1
- self.copy_name = tempfile.mkstemp()[1]
- shutil.copyfile(self.mbox_name, self.copy_name)
- archivemail.options.min_size = size_arg
- archivemail.archive(self.mbox_name)
- assert(os.path.exists(self.mbox_name))
- self.assertEqual(os.path.getsize(self.mbox_name), 0)
- archive_name = self.mbox_name + "_archive.gz"
- assertEqualContent(archive_name, self.copy_name, zipfirst=True)
+ archivemail.options.min_size = self.msg_size - 1
+ assert(archivemail.should_archive(self.msg))
def testBigger(self):
"""giving a size argument bigger than the message"""
- self.mbox_name = make_mbox(messages=1, hours_old=(24 * 181))
- size_arg = os.path.getsize(self.mbox_name) + 1
- self.copy_name = tempfile.mkstemp()[1]
- shutil.copyfile(self.mbox_name, self.copy_name)
- archivemail.options.min_size = size_arg
- archivemail.archive(self.mbox_name)
- assertEqualContent(self.mbox_name, self.copy_name)
- archive_name = self.mbox_name + "_archive.gz"
- assert(not os.path.exists(archive_name))
+ archivemail.options.min_size = self.msg_size + 1
+ assert(not archivemail.should_archive(self.msg))
def tearDown(self):
archivemail.options.quiet = 0
archivemail.options.min_size = None
- super(TestArchiveSize, self).tearDown()
class TestArchiveMboxMode(TestCaseInTempdir):