test: Create all intermediary maildirs

Don't fail if root maildir folder does not exist it. Create it recursively.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
test: Split configuration generation so we can tweak values

Use get_default_config and write_config_file (which can be handed an optional
config object), so we can manipulate configuration options easily from within
the test function.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Folder: Implement __eq__ for folders

This allows to compare folders directly with strings. It also allows
constructs such as "if 'moo' in repo.getfolders()".

See the code documentation for the exact behavior (it basically is equal if
it's the same instance *or* a string matching the untranslated folder name.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
sync_folder_structure: make more readable

Rename variable src_name to src_name_t to indicate that it is the transposed
name. Also rather than testing the hash thingie, we can simply test for
"if source_name_t in dst_folders" now.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Improve nametrans local->remote folder syncing

While improving the test suite, I noticed that we would not create folders on
the remote in some cases when we should (yay for test suites!). This is because
we were testing the untransposed LOCAL foldername and check if it existed on
the remote side when deciding whether we should potentially create a new folder.

Simplify the code by transposing the LOCAL folder names in dst_hash, saving us
to create another confusing "newsrc" temp variable. Make the code a bit more
readable by using dst_name_t to indicate we operate a transposed folder name.

This now passes test 03 (using invalid nametrans rules) when test 03 would pass
before.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Changelog entry

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
folder/IMAP: better error when savemessage fails

If we cannot identify the new UID after a sendmessage(), log a better error
message, including the server response for better debugging.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
UIDMaps: Better error message when not finding a mapping

Bail out with a better Exception and error text. The whole mapped
UID situation needs to be improved though.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
tests: add delete remote folder helper function

We need to clean out the remote folders before we invoke the test suite.
Implement a helper function that does this, and improve the test output
(less verbose) and the setup.py --help-commands (more verbose). Document
that it is possible to run a single test only. (although it is not
guaranteed that a test does not rely on the output of previous tests).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
tests: Add MappedIMAP test skeleton

No working tests yet.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Implement CustomConfig.set_if_not_exists()

A convenience helper function that allows to set a configuration value
if the user has not explicitly configured anything ie the option does
not exist yet in the configuration. It won't do anything, if the option
exists.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Add command line option --dry-run

And set the [general]dry-run=True setting if yes. It is not used yet.
Also set ui.dryrun to True so we can output what WE WOULD HAVE DONE in
dryrun mode.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Implement dry-run on Account() level

1) Set attribute self.dryrun depending on whether we are in dry-run mode.
2) Don't actually call hooks in --dry-run (just log what you would
   invoke
3) Don't write out the mbnames file in --dry-run mode.

Repository, and Folder levels still need to be protected in dry-run mode
as of now.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Implement ui.makefolder and abort repo.makefolder() in dry-run mode

IMAP, Maildir, and LocalStatus abort if in dry-run mode. IMAP and Maildir
will log that they "would have" created a new folder.

This will probably fail later on as we can not cache messagelists on
folder that don't exist, so --dry-run is not yet safe when new folders
have been created.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Prevent modifications on a folder level to occur in dry-run

Prevent savemessage(), and savemessageflags() to occur in dryrun mode in
all backends. Still need to protect against deletemessage().

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
dry-run mode: Protect us from actually deleting a message in dry-run mode

Document which functions honor dry-run mode and which don't.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Add Changelog entry for dry-run mode

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Improve command line option help text

Shuffle around and update command line option descriptions in the
docs.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
tests: Use only 1 IMAP connection by default

We don't want to hammmer IMAP servers for the test series too much
to avoid being locked out. We will need a few tests to test
concurrent connections, but by default one connection should be fine.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
python3: Fix import in tests to work with python3

DOH

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>