Reformat offlineimap/test/tests/ all tests
Add some spaces, remove lines,... now format is better (lintian).
This commit is contained in:
parent
d75cf8d80c
commit
bcc497df16
@ -1 +0,0 @@
|
||||
|
@ -4,6 +4,7 @@
|
||||
from offlineimap import globals
|
||||
import unittest
|
||||
|
||||
|
||||
class Opt:
|
||||
def __init__(self):
|
||||
self.one = "baz"
|
||||
@ -16,7 +17,7 @@ class TestOfflineimapGlobals(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(klass):
|
||||
klass.o = Opt()
|
||||
globals.set_options (klass.o)
|
||||
globals.set_options(klass.o)
|
||||
|
||||
def test_initial_state(self):
|
||||
for k in self.o.__dict__.keys():
|
||||
@ -43,7 +44,7 @@ class TestOfflineimapGlobals(unittest.TestCase):
|
||||
|
||||
def test_double_init(self):
|
||||
with self.assertRaises(ValueError):
|
||||
globals.set_options (True)
|
||||
globals.set_options(True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -27,21 +27,24 @@ from test.OLItest import OLITestLib
|
||||
if not OLITestLib.cred_file:
|
||||
OLITestLib(cred_file='./test/credentials.conf', cmd='./offlineimap.py')
|
||||
|
||||
|
||||
def setUpModule():
|
||||
logging.info("Set Up test module %s" % __name__)
|
||||
tdir = OLITestLib.create_test_dir(suffix=__name__)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
logging.info("Tear Down test module")
|
||||
# comment out next line to keep testdir after test runs. TODO: make nicer
|
||||
OLITestLib.delete_test_dir()
|
||||
|
||||
#Stuff that can be used
|
||||
#self.assertEqual(self.seq, range(10))
|
||||
|
||||
# Stuff that can be used
|
||||
# self.assertEqual(self.seq, range(10))
|
||||
# should raise an exception for an immutable sequence
|
||||
#self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
#self.assertTrue(element in self.seq)
|
||||
#self.assertFalse(element in self.seq)
|
||||
# self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
# self.assertTrue(element in self.seq)
|
||||
# self.assertFalse(element in self.seq)
|
||||
|
||||
class TestInternalFunctions(unittest.TestCase):
|
||||
"""While the other test files test OfflineImap as a program, these
|
||||
@ -50,8 +53,8 @@ class TestInternalFunctions(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
#This is run before all tests in this class
|
||||
config= OLITestLib.get_default_config()
|
||||
# This is run before all tests in this class
|
||||
config = OLITestLib.get_default_config()
|
||||
setglobalui(UI_LIST['quiet'](config))
|
||||
|
||||
def test_01_imapsplit(self):
|
||||
@ -90,5 +93,5 @@ class TestInternalFunctions(unittest.TestCase):
|
||||
|
||||
def test_07_uid_sequence(self):
|
||||
"""Test imaputil.uid_sequence()"""
|
||||
res = imaputil.uid_sequence([1,2,3,4,5,10,12,13])
|
||||
res = imaputil.uid_sequence([1, 2, 3, 4, 5, 10, 12, 13])
|
||||
self.assertEqual(res, b'1:5,10,12:13')
|
||||
|
@ -29,16 +29,18 @@ def setUpModule():
|
||||
logging.info("Set Up test module %s" % __name__)
|
||||
tdir = OLITestLib.create_test_dir(suffix=__name__)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
logging.info("Tear Down test module")
|
||||
OLITestLib.delete_test_dir()
|
||||
|
||||
#Stuff that can be used
|
||||
#self.assertEqual(self.seq, range(10))
|
||||
|
||||
# Stuff that can be used
|
||||
# self.assertEqual(self.seq, range(10))
|
||||
# should raise an exception for an immutable sequence
|
||||
#self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
#self.assertTrue(element in self.seq)
|
||||
#self.assertFalse(element in self.seq)
|
||||
# self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
# self.assertTrue(element in self.seq)
|
||||
# self.assertFalse(element in self.seq)
|
||||
|
||||
class TestBasicFunctions(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@ -56,18 +58,18 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
code, res = OLITestLib.run_OLI()
|
||||
self.assertEqual(res, "")
|
||||
boxes, mails = OLITestLib.count_maildir_mails('')
|
||||
self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0 "
|
||||
self.assertTrue((boxes, mails) == (0, 0), msg="Expected 0 folders and 0 "
|
||||
"mails, but sync led to {0} folders and {1} mails".format(
|
||||
boxes, mails))
|
||||
|
||||
def test_02_createdir(self):
|
||||
"""Create local 'OLItest 1', sync"""
|
||||
OLITestLib.delete_maildir('') #Delete all local maildir folders
|
||||
OLITestLib.delete_maildir('') # Delete all local maildir folders
|
||||
OLITestLib.create_maildir('INBOX.OLItest 1')
|
||||
code, res = OLITestLib.run_OLI()
|
||||
self.assertEqual(res, "")
|
||||
boxes, mails = OLITestLib.count_maildir_mails('')
|
||||
self.assertTrue((boxes, mails)==(1,0), msg="Expected 1 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))
|
||||
|
||||
@ -76,14 +78,14 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
|
||||
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.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 "
|
||||
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))
|
||||
|
||||
@ -93,12 +95,12 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
This should raise an error."""
|
||||
config = OLITestLib.get_default_config()
|
||||
config.set('Repository IMAP', 'nametrans',
|
||||
'lambda f: f' )
|
||||
'lambda f: f')
|
||||
config.set('Repository Maildir', 'nametrans',
|
||||
'lambda f: f + "moo"' )
|
||||
'lambda f: f + "moo"')
|
||||
OLITestLib.write_config_file(config)
|
||||
code, res = OLITestLib.run_OLI()
|
||||
#logging.warn("%s %s "% (code, res))
|
||||
# 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, msg="Mismatching nametrans rules did "
|
||||
@ -107,7 +109,6 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
# Write out default config file again
|
||||
OLITestLib.write_config_file()
|
||||
|
||||
|
||||
def test_05_createmail(self):
|
||||
"""Create mail in OLItest 1, sync, wipe folder sync
|
||||
|
||||
@ -115,21 +116,21 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
locally. At some point when remote folder deletion is
|
||||
implemented, this behavior will change."""
|
||||
OLITestLib.delete_remote_testfolders()
|
||||
OLITestLib.delete_maildir('') #Delete all local maildir folders
|
||||
OLITestLib.delete_maildir('') # Delete all local maildir folders
|
||||
OLITestLib.create_maildir('INBOX.OLItest')
|
||||
OLITestLib.create_mail('INBOX.OLItest')
|
||||
code, res = OLITestLib.run_OLI()
|
||||
#logging.warn("%s %s "% (code, res))
|
||||
# logging.warn("%s %s "% (code, res))
|
||||
self.assertEqual(res, "")
|
||||
boxes, mails = OLITestLib.count_maildir_mails('')
|
||||
self.assertTrue((boxes, mails)==(1,1), msg="Expected 1 folders and 1 "
|
||||
self.assertTrue((boxes, mails) == (1, 1), msg="Expected 1 folders and 1 "
|
||||
"mails, but sync led to {0} folders and {1} mails".format(
|
||||
boxes, mails))
|
||||
# The local Mail should have been assigned a proper UID now, check!
|
||||
uids = OLITestLib.get_maildir_uids('INBOX.OLItest')
|
||||
self.assertFalse (None in uids, msg = "All mails should have been "+ \
|
||||
"assigned the IMAP's UID number, but {0} messages had no valid ID "\
|
||||
.format(len([None for x in uids if x==None])))
|
||||
self.assertFalse(None in uids, msg="All mails should have been " + \
|
||||
"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_06_createfolders(self):
|
||||
"""Test if createfolders works as expected
|
||||
@ -141,7 +142,7 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
been written"""
|
||||
config = OLITestLib.get_default_config()
|
||||
config.set('Repository IMAP', 'createfolders',
|
||||
'False' )
|
||||
'False')
|
||||
OLITestLib.write_config_file(config)
|
||||
|
||||
# delete all remote and local testfolders
|
||||
@ -149,12 +150,12 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
OLITestLib.delete_maildir('')
|
||||
OLITestLib.create_maildir('INBOX.OLItest')
|
||||
code, res = OLITestLib.run_OLI()
|
||||
#logging.warn("%s %s "% (code, res))
|
||||
# logging.warn("%s %s "% (code, res))
|
||||
self.assertEqual(res, "")
|
||||
OLITestLib.delete_maildir('INBOX.OLItest')
|
||||
code, res = OLITestLib.run_OLI()
|
||||
self.assertEqual(res, "")
|
||||
boxes, mails = OLITestLib.count_maildir_mails('')
|
||||
self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0 "
|
||||
self.assertTrue((boxes, mails) == (0, 0), msg="Expected 0 folders and 0 "
|
||||
"mails, but sync led to {} folders and {} mails".format(
|
||||
boxes, mails))
|
||||
|
@ -29,30 +29,32 @@ def setUpModule():
|
||||
logging.info("Set Up test module %s" % __name__)
|
||||
tdir = OLITestLib.create_test_dir(suffix=__name__)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
logging.info("Tear Down test module")
|
||||
OLITestLib.delete_test_dir()
|
||||
|
||||
#Stuff that can be used
|
||||
#self.assertEqual(self.seq, range(10))
|
||||
|
||||
# Stuff that can be used
|
||||
# self.assertEqual(self.seq, range(10))
|
||||
# should raise an exception for an immutable sequence
|
||||
#self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
#self.assertTrue(element in self.seq)
|
||||
#self.assertFalse(element in self.seq)
|
||||
# self.assertRaises(TypeError, random.shuffle, (1,2,3))
|
||||
# self.assertTrue(element in self.seq)
|
||||
# self.assertFalse(element in self.seq)
|
||||
|
||||
class TestBasicFunctions(unittest.TestCase):
|
||||
#@classmethod
|
||||
#def setUpClass(cls):
|
||||
#This is run before all tests in this class
|
||||
# @classmethod
|
||||
# def setUpClass(cls):
|
||||
# This is run before all tests in this class
|
||||
# cls._connection = createExpensiveConnectionObject()
|
||||
|
||||
#@classmethod
|
||||
#This is run after all tests in this class
|
||||
#def tearDownClass(cls):
|
||||
# @classmethod
|
||||
# This is run after all tests in this class
|
||||
# def tearDownClass(cls):
|
||||
# cls._connection.destroy()
|
||||
|
||||
# This will be run before each test
|
||||
#def setUp(self):
|
||||
# def setUp(self):
|
||||
# self.seq = range(10)
|
||||
|
||||
def test_01_MappedImap(self):
|
||||
@ -61,11 +63,11 @@ class TestBasicFunctions(unittest.TestCase):
|
||||
Cleans existing remote test folders. Then syncs all "OLItest*
|
||||
(specified in the default config) to our local IMAP (Gmail). The
|
||||
result should be 0 folders and 0 mails."""
|
||||
pass #TODO
|
||||
#OLITestLib.delete_remote_testfolders()
|
||||
#code, res = OLITestLib.run_OLI()
|
||||
#self.assertEqual(res, "")
|
||||
#boxes, mails = OLITestLib.count_maildir_mails('')
|
||||
#self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0"
|
||||
pass # TODO
|
||||
# OLITestLib.delete_remote_testfolders()
|
||||
# code, res = OLITestLib.run_OLI()
|
||||
# self.assertEqual(res, "")
|
||||
# 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))
|
||||
|
Loading…
Reference in New Issue
Block a user