From b7789268b7c904a50c804b53b2c57996c797c7ba Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Mon, 23 Mar 2015 18:20:46 +0100 Subject: [PATCH] test: handle imap.gmx.net server: workarounds Signed-off-by: Pierre-Louis Bonicoli Signed-off-by: Nicolas Sebrecht --- test/OLItest/TestRunner.py | 10 +++++++--- test/tests/test_01_basic.py | 31 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/OLItest/TestRunner.py b/test/OLItest/TestRunner.py index 320ddcf..e5fc030 100644 --- a/test/OLItest/TestRunner.py +++ b/test/OLItest/TestRunner.py @@ -155,11 +155,15 @@ class OLITestLib(): folder = b'"%s"' % d[1].replace('"', '\\"') else: m = re.search(br''' - (" # starting quote + [ ] # space + (?P + (?P"?) # starting quote ([^"]|\\")* # a non-quote or a backslashded quote - ")$ # ending quote + (?P=quote))$ # ending quote ''', 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 dirs.append(folder) # 2) filter out those not starting with INBOX.OLItest and del... diff --git a/test/tests/test_01_basic.py b/test/tests/test_01_basic.py index a1147c0..629131c 100644 --- a/test/tests/test_01_basic.py +++ b/test/tests/test_01_basic.py @@ -61,20 +61,33 @@ class TestBasicFunctions(unittest.TestCase): boxes, mails)) def test_02_createdir(self): - """Create local OLItest 1 & OLItest "1" maildir, sync - - Folder names with quotes used to fail and have been fixed, so - one is included here as a small challenge.""" + """Create local 'OLItest 1', sync""" + OLITestLib.delete_maildir('') #Delete all local maildir folders OLITestLib.create_maildir('INBOX.OLItest 1') - OLITestLib.create_maildir('INBOX.OLItest "1"') code, res = OLITestLib.run_OLI() self.assertEqual(res, "") 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( 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 This should raise an error.""" @@ -95,7 +108,7 @@ class TestBasicFunctions(unittest.TestCase): OLITestLib.write_config_file() - def test_04_createmail(self): + def test_05_createmail(self): """Create mail in OLItest 1, sync, wipe folder sync 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 "\ .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 Create a local Maildir, then sync with remote "createfolders"