aboutsummaryrefslogtreecommitdiffstats
path: root/test_archivemail.py
Commit message (Collapse)AuthorAgeFilesLines
* test suite: add more maildir test casesNikolaus Schulz2010-07-291-18/+187
| | | | Maildir testing should now be roughly on par with mbox testing.
* test suite: remove unused remove() methods from maildir classesNikolaus Schulz2010-07-291-17/+0
| | | | | For cleanup of temporary files, we lean on shutil.rmtree anyway, so don't bother wasting more code on this.
* test suite: remove incomplete MH testing codeNikolaus Schulz2010-07-291-32/+1
| | | | | | | | | | I just discovered that archivemails MH support is broken with respect to message flags, and in my opinion it doesn't make much sense to test known-broken functionality. In fact there may well be zero archivemail users with MH mailboxes; MH is basically an obsolete format, and any archivemail user with MH mailboxes would probably have complained about lost message flags.
* test suite: first shot at implementing maildir test casesNikolaus Schulz2010-07-291-3/+387
|
* test suite: remove obsolete $Id$ subversion keywordNikolaus Schulz2010-07-291-1/+0
|
* test suite: cleanup of the mbox testing codeNikolaus Schulz2010-07-291-52/+56
| | | | | | This code is complex, too complex actually. Rename some methods and variables, rework some code and and add some explaining comments in order to make it it least a bit easier to understand.
* test suite: remove obsolete test that we preserve mbox file modesNikolaus Schulz2010-07-291-38/+0
| | | | | This test case is obsolete since we no longer replace the mbox file with a new copy but rewrite it.
* Python language fix: replace C-style boolean values "1" and "0" with True/FalseNikolaus Schulz2010-07-191-52/+52
|
* Python language fix: remove parentheses around asserted expressionsNikolaus Schulz2010-07-191-56/+56
| | | | assert is not a function.
* mbox locking: omit dotlock if we don't have the permissions to create itNikolaus Schulz2010-07-191-0/+11
| | | | Closes: issue #855269.
* mbox locking: combine locking functions into one and swap lock orderNikolaus Schulz2010-07-191-4/+4
| | | | | | | | | | | | | We used to create a dotlock file first and then lock with fcntl; swap that order, since locking first with fcntl seems to be more common. This patch also adds general mbox lock/unlock methods, which call the dotlock and fcntl-lock methods, and moves the retry logic there. When the dotlock and fcntl methods fail to acquire a lock, they now raise a custom exception "LockUnavailable", which gets caught in the general lock() method. That way, if we succeed to acquire one lock but fail to acquire the other, we can release our locks at the upper level and retry.
* Switch mbox locking from flock(2) to posix lockf(2)Nikolaus Schulz2010-07-191-15/+10
| | | | flock() locks aren't portable; lockf() locks are.
* Rename procmail_lock->dotlock_lockNikolaus Schulz2010-07-191-7/+7
| | | | | An entirely cosmetic variable rename, but it's just not correct to call this a "procmail lock". Also reword some comments accordingly.
* test suite: use common base class with helper methods for mbox testingNikolaus Schulz2010-07-191-216/+168
| | | | | | | | These helper methods provide success verification after test archiving runs, and test case setup. This is a tradeoff: because these methods need to support all scenarios in one place, they introduce some new complexity - but they replace a lot of tedious, very similar, but still not entirely identical code all over the place.
* test suite: cut down the test of the --all optionNikolaus Schulz2010-07-191-19/+9
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: cut down the test of the --preserve-unread optionNikolaus Schulz2010-07-191-21/+8
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: change misleading test case nameNikolaus Schulz2010-07-191-3/+3
| | | | | | TestArchiveMboxPreserveStatus actually doesn't test that the message status is preserved, but that the --preserve-unread option works. Rename it to TestArchiveMboxPreserveUnread.
* test suite: cut down the test of the --size optionNikolaus Schulz2010-07-191-22/+9
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: cut down the test of --output-dirNikolaus Schulz2010-07-191-14/+5
| | | | | Don't do entire test archiving runs, just call archivemail.make_archive_name() and verify the result.
* test suite: cut down testing the handling of flagged messagesNikolaus Schulz2010-07-191-29/+10
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: remove duplicate test case for --date optionNikolaus Schulz2010-07-191-35/+0
|
* test suite: cut down archive suffix generation testingNikolaus Schulz2010-07-191-17/+8
| | | | | Don't do entire test archiving runs, just call archivemail.make_archive_name() and verify the result.
* test suite: test weird message headers in one runNikolaus Schulz2010-07-191-8/+12
| | | | Before, every test header was tested in a separate archiving run.
* test suite: cut down the test of date header processingNikolaus Schulz2010-07-191-15/+3
| | | | | Don't do entire test archiving runs, just call archivemail.should_archive().
* test suite: let make_message() optionally return a rfc822.MessageNikolaus Schulz2010-07-191-3/+7
|
* Remove lots of redundant test runs from the test suiteNikolaus Schulz2010-07-191-615/+347
| | | | | | | | | | | The test suite used to run a lot of triple tests, by first calling archivemail.archive() directly, and then running the entire archivemail script twice, once with long and once with short options. But we already test option processing seperately, and beyond that, archivemail.main() essentially just calls archive() for each mailbox in turn. So we just drop all runs of the entire archivemail script from the test suite, giving it a huge speed boost (on my old iBook, running the test suite drops from 73 to 5 seconds).
* Test suite: test command line option processingNikolaus Schulz2010-07-191-0/+88
|
* test suite: eliminate remaining call of external gzip programNikolaus Schulz2010-07-191-4/+6
| | | | Use gzip.GzipFile instead.
* test suite: define and use assertEqualContent() to compare filesNikolaus Schulz2010-07-191-114/+60
| | | | | This eliminates a lot of copy-and-paste code, and switches from os.system("gzip <...>") to gzip.GzipFile.
* test suite: account for lacking precision of os.utime()Nikolaus Schulz2010-07-191-6/+9
| | | | | | | os.utime() uses the utimes(2) system call to set file timestamps. utimes(2) has a microsecond resolution, but stat(2) may return timestamps with nanosecond resolution. So, the check that we have properly reset the mbox file timestamp must allow a minor deviation.
* Simplify the final committing of the mailbox and archiveNikolaus Schulz2010-07-191-15/+0
| | | | | | | | | | * Make the finalise() methods spot if they have anything to do * We used to create the temporary mbox files on demand in the message processing loop, if we needed to write to them. Now we create them beforehand, but only if they might be needed (e.g. we don't create an archive if options.delete_old_mail is set). * The above combined makes the final committing of the changes simpler (a *lot* simpler for mboxes), and we can dump the Mbox.leave_empty() method.
* Split out new class TempMboxNikolaus Schulz2010-07-191-26/+27
| | | | | This separates write-only mbox access to the temporary mboxes from the read-only access to the original mbox.
* Remove unused method Mbox.is_empty()Nikolaus Schulz2009-11-061-16/+0
|
* Added new option --all to archive all messages in a mailbox.Nikolaus Schulz2008-03-151-0/+36
| | | | | | Updated documentation, and added a first simple unittest for this. Closes: #1764846.
* Updated copyright notes to include year 2008.Nikolaus Schulz2008-03-151-1/+1
|
* test_archivemail.py: removed nested calls to setUp() and tearDown(). Nikolaus Schulz2008-03-061-68/+0
|
* archivemail.py, setup.py, test_archivemail.py: Nikolaus Schulz2007-11-071-1/+1
| | | | | bumped version to 0.7.1, and updated copyright.
* Added simple unittest for the --copy option. Mbox only. :-/Nikolaus Schulz2007-11-021-0/+96
|
* Added unittest for the new IMAP URL parser.Nikolaus Schulz2007-10-231-0/+77
|
* Testsuite: fixed testDeleteOldMail to check the right option. Nikolaus Schulz2006-10-301-1/+1
|
* Testsuite: create temporary directory with prefix. Nikolaus Schulz2006-10-291-2/+3
|
* Dropped test from testsuite if dotlock file is world-readable, this isn'tNikolaus Schulz2006-10-291-6/+0
| | | | | required.
* Replaced all tempfile.mktemp() calls with mkstemp()/mkdtemp().Nikolaus Schulz2006-10-271-29/+28
| | | | | | | Should just serve as a last security fallback, since we operate in a safe temporary directory and everything should be okay anyway, but that may be less obvious. :-)
* test_archivemail.py: fixed unsafe creation of temporary files. Nikolaus Schulz2006-10-271-115/+85
| | | | | | | | | | | | | | | | | Derive all testcases that create temporary files from the new class TestCaseInTempdir, which provides standard fixtures to set up a secure temporary root directory for tempfiles and cleaning up afterwards. This also simplifies the code. This addresses Debian bug #385253, and reading the BTS log, it seems this issue was assigned CVE-2006-4245, although I cannot find any further reference to that CVE. Note that the bug was initially reported to affect archivemail itself, too. This is not correct. There *are* race conditions with archivemail, but they were not subject of that report, and are not that critical. Also bumped python dependency to version 2.3 since we use tempfile.mkstemp() and other recent stuff.
* test_archivemail.py: added two missing self.setUp() calls in the TestArchiveMboxNikolaus Schulz2006-10-271-0/+2
| | | | | testcase.
* test_archivemail.py: put standard setUp() fixtures in the testcases; theNikolaus Schulz2006-10-271-38/+61
| | | | | | | matching tearDown() methods were already there. We surely can move more (possibly duplicated) stuff into the setUp() methods later.
* test_archivemail.py: don't check for os.fork(), simply use it -- we're targetingNikolaus Schulz2006-10-271-2/+0
| | | | | posix platforms only.
* Fixed unittest TestMboxExclusiveLock: on some systems flock(2) is emulated withNikolaus Schulz2006-10-201-5/+38
| | | | | | fcntl(2) calls. fcntl locks don't support interlocking within a process, so we need to fork() to correctly test them.
* Added maintainer entry in setup.py. Nikolaus Schulz2006-10-121-0/+1
| | | | | Updated copyright notices in archivemail.py and test_archivemail.py.
* Fixed unittest failure by updating --suffix testcase: archivemail used to expandNikolaus Schulz2006-10-011-2/+8
| | | | | | date directives in the suffix to the current date, but rev. 94 changed that to the archive cut off date. Based on analysis by Peter Poeml. Thanks, Peter.