mirror of
https://git.code.sf.net/p/archivemail/code
synced 2025-01-03 05:34:58 +00:00
test suite: cut down the test of the --size option
Don't do entire test archiving runs, just call archivemail.should_archive().
This commit is contained in:
parent
6d2e23ac80
commit
41da26b655
1 changed files with 9 additions and 22 deletions
|
@ -1042,41 +1042,28 @@ class TestArchiveMboxUncompressed(TestCaseInTempdir):
|
||||||
super(TestArchiveMboxUncompressed, self).tearDown()
|
super(TestArchiveMboxUncompressed, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveSize(TestCaseInTempdir):
|
class TestArchiveSize(unittest.TestCase):
|
||||||
"""check that the 'size' argument works"""
|
"""check that the 'size' argument works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveSize, self).setUp()
|
|
||||||
archivemail.options.quiet = 1
|
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):
|
def testSmaller(self):
|
||||||
"""giving a size argument smaller than the message"""
|
"""giving a size argument smaller than the message"""
|
||||||
self.mbox_name = make_mbox(messages=1, hours_old=(24 * 181))
|
archivemail.options.min_size = self.msg_size - 1
|
||||||
size_arg = os.path.getsize(self.mbox_name) - 1
|
assert(archivemail.should_archive(self.msg))
|
||||||
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)
|
|
||||||
|
|
||||||
def testBigger(self):
|
def testBigger(self):
|
||||||
"""giving a size argument bigger than the message"""
|
"""giving a size argument bigger than the message"""
|
||||||
self.mbox_name = make_mbox(messages=1, hours_old=(24 * 181))
|
archivemail.options.min_size = self.msg_size + 1
|
||||||
size_arg = os.path.getsize(self.mbox_name) + 1
|
assert(not archivemail.should_archive(self.msg))
|
||||||
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))
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = 0
|
||||||
archivemail.options.min_size = None
|
archivemail.options.min_size = None
|
||||||
super(TestArchiveSize, self).tearDown()
|
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveMboxMode(TestCaseInTempdir):
|
class TestArchiveMboxMode(TestCaseInTempdir):
|
||||||
|
|
Loading…
Reference in a new issue