Implement the "createfolders" setting for repositories

By default OfflineImap propagates new folders in both
directions. Sometimes this is not what you want. E.g. you might want
new folders on your IMAP server to propagate to your local MailDir,
but not the other way around. The 'readonly' setting on a repository
will not help here, as it prevents any change from occuring on that
repository. This is what the `createfolders` setting is for. By
default it is `True`, meaning that new folders can be created on this
repository. To prevent folders from ever being created on a
repository, set this to `False`. If you set this to False on the
REMOTE repository, you will not have to create the `Reverse
nametrans`_ rules on the LOCAL repository.

Also implement a test for this

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth
2012-05-08 16:41:21 +02:00
parent 644b9f0bb9
commit 0752c123f5
5 changed files with 66 additions and 2 deletions

View File

@ -105,6 +105,7 @@ class TestBasicFunctions(unittest.TestCase):
# Write out default config file again
OLITestLib.write_config_file()
def test_04_createmail(self):
"""Create mail in OLItest 1, sync, wipe folder sync
@ -127,3 +128,30 @@ class TestBasicFunctions(unittest.TestCase):
self.assertFalse (None in uids, msg = "All mails should have been "+ \
"assigned the IMAP's UID number, but {} messages had no valid ID "\
.format(len([None for x in uids if x==None])))
def test_05_createfolders(self):
"""Test if createfolders works as expected
Create a local Maildir, then sync with remote "createfolders"
disabled. Delete local Maildir and sync. We should have no new
local maildir then. TODO: Rewrite this test to directly test
and count the remote folders when the helper functions have
been written"""
config = OLITestLib.get_default_config()
config.set('Repository IMAP', 'createfolders',
'False' )
OLITestLib.write_config_file(config)
# delete all remote and local testfolders
OLITestLib.delete_remote_testfolders()
OLITestLib.delete_maildir('')
OLITestLib.create_maildir('INBOX.OLItest')
code, res = OLITestLib.run_OLI()
#logging.warn("%s %s "% (code, res))
self.assertEqual(res, "")
OLITestLib.delete_maildir('INBOX.OLItest')
code, res = OLITestLib.run_OLI()
boxes, mails = OLITestLib.count_maildir_mails('')
self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0 "
"mails, but sync led to {} folders and {} mails".format(
boxes, mails))