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>
This commit is contained in:
Sebastian Spaeth
2012-02-16 11:45:18 +01:00
parent 189d78cc5c
commit ac033c68fd
2 changed files with 35 additions and 16 deletions

View File

@ -72,3 +72,21 @@ class TestBasicFunctions(unittest.TestCase):
self.assertEqual(res, "")
boxes, mails = OLITestLib.count_maildir_mails('')
logging.warn("%d boxes and %d mails" % (boxes, mails))
def test_03_nametransmismatch(self):
"""Create mismatching remote and local nametrans rules
This should raise an error."""
config = OLITestLib.get_default_config()
config.set('Repository IMAP', 'nametrans',
'lambda f: f' )
config.set('Repository Maildir', 'nametrans',
'lambda f: f + "moo"' )
OLITestLib.write_config_file(config)
code, res = OLITestLib.run_OLI()
#logging.warn("%s %s "% (code, res))
# We expect an INFINITE FOLDER CREATION WARNING HERE....
mismatch = "ERROR: INFINITE FOLDER CREATION DETECTED!" in res
self.assertEqual(mismatch, True, "Mismatching nametrans rules did NOT"
"trigger an 'infinite folder generation' error.")
boxes, mails = OLITestLib.count_maildir_mails('')