test: handle imap.gmx.net server: workarounds

Signed-off-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@gmx.fr>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Pierre-Louis Bonicoli 2015-03-23 18:20:46 +01:00 committed by Nicolas Sebrecht
parent ff069e1d86
commit b7789268b7
2 changed files with 29 additions and 12 deletions

View File

@ -155,11 +155,15 @@ class OLITestLib():
folder = b'"%s"' % d[1].replace('"', '\\"') folder = b'"%s"' % d[1].replace('"', '\\"')
else: else:
m = re.search(br''' m = re.search(br'''
(" # starting quote [ ] # space
(?P<dir>
(?P<quote>"?) # starting quote
([^"]|\\")* # a non-quote or a backslashded quote ([^"]|\\")* # a non-quote or a backslashded quote
")$ # ending quote (?P=quote))$ # ending quote
''', d, flags=re.VERBOSE) ''', d, flags=re.VERBOSE)
folder = bytearray(m.group(1)) folder = bytearray(m.group('dir'))
if not m.group('quote'):
folder = '"%s"' % folder
#folder = folder.replace(br'\"', b'"') # remove quoting #folder = folder.replace(br'\"', b'"') # remove quoting
dirs.append(folder) dirs.append(folder)
# 2) filter out those not starting with INBOX.OLItest and del... # 2) filter out those not starting with INBOX.OLItest and del...

View File

@ -61,20 +61,33 @@ class TestBasicFunctions(unittest.TestCase):
boxes, mails)) boxes, mails))
def test_02_createdir(self): def test_02_createdir(self):
"""Create local OLItest 1 & OLItest "1" maildir, sync """Create local 'OLItest 1', sync"""
OLITestLib.delete_maildir('') #Delete all local maildir folders
Folder names with quotes used to fail and have been fixed, so
one is included here as a small challenge."""
OLITestLib.create_maildir('INBOX.OLItest 1') OLITestLib.create_maildir('INBOX.OLItest 1')
OLITestLib.create_maildir('INBOX.OLItest "1"')
code, res = OLITestLib.run_OLI() code, res = OLITestLib.run_OLI()
self.assertEqual(res, "") self.assertEqual(res, "")
boxes, mails = OLITestLib.count_maildir_mails('') boxes, mails = OLITestLib.count_maildir_mails('')
self.assertTrue((boxes, mails)==(2,0), msg="Expected 2 folders and 0 " self.assertTrue((boxes, mails)==(1,0), msg="Expected 1 folders and 0 "
"mails, but sync led to {0} folders and {1} mails".format( "mails, but sync led to {0} folders and {1} mails".format(
boxes, mails)) boxes, mails))
def test_03_nametransmismatch(self): def test_03_createdir_quote(self):
"""Create local 'OLItest "1"' maildir, sync
Folder names with quotes used to fail and have been fixed, so
one is included here as a small challenge."""
OLITestLib.delete_maildir('') #Delete all local maildir folders
OLITestLib.create_maildir('INBOX.OLItest "1"')
code, res = OLITestLib.run_OLI()
if 'unallowed folder' in res:
raise unittest.SkipTest("remote server doesn't handle quote")
self.assertEqual(res, "")
boxes, mails = OLITestLib.count_maildir_mails('')
self.assertTrue((boxes, mails)==(1,0), msg="Expected 1 folders and 0 "
"mails, but sync led to {0} folders and {1} mails".format(
boxes, mails))
def test_04_nametransmismatch(self):
"""Create mismatching remote and local nametrans rules """Create mismatching remote and local nametrans rules
This should raise an error.""" This should raise an error."""
@ -95,7 +108,7 @@ class TestBasicFunctions(unittest.TestCase):
OLITestLib.write_config_file() OLITestLib.write_config_file()
def test_04_createmail(self): def test_05_createmail(self):
"""Create mail in OLItest 1, sync, wipe folder sync """Create mail in OLItest 1, sync, wipe folder sync
Currently, this will mean the folder will be recreated Currently, this will mean the folder will be recreated
@ -118,7 +131,7 @@ class TestBasicFunctions(unittest.TestCase):
"assigned the IMAP's UID number, but {0} messages had no valid ID "\ "assigned the IMAP's UID number, but {0} messages had no valid ID "\
.format(len([None for x in uids if x==None]))) .format(len([None for x in uids if x==None])))
def test_05_createfolders(self): def test_06_createfolders(self):
"""Test if createfolders works as expected """Test if createfolders works as expected
Create a local Maildir, then sync with remote "createfolders" Create a local Maildir, then sync with remote "createfolders"