Merge branch 'next'
Conflicts: Changelog.rst Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
commit
61d05788bb
@ -17,6 +17,9 @@ Changes
|
|||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
OfflineIMAP v6.5.3.1 (2012-04-03)
|
||||||
|
=================================
|
||||||
|
|
||||||
* Don't fail if no dry-run setting exists in offlineimap.conf
|
* Don't fail if no dry-run setting exists in offlineimap.conf
|
||||||
(introduced in 6.5.3)
|
(introduced in 6.5.3)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
__all__ = ['OfflineImap']
|
__all__ = ['OfflineImap']
|
||||||
|
|
||||||
__productname__ = 'OfflineIMAP'
|
__productname__ = 'OfflineIMAP'
|
||||||
__version__ = "6.5.3"
|
__version__ = "6.5.3.1"
|
||||||
__copyright__ = "Copyright 2002-2012 John Goerzen & contributors"
|
__copyright__ = "Copyright 2002-2012 John Goerzen & contributors"
|
||||||
__author__ = "John Goerzen"
|
__author__ = "John Goerzen"
|
||||||
__author_email__= "john@complete.org"
|
__author_email__= "john@complete.org"
|
||||||
|
@ -24,10 +24,8 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import random
|
import random
|
||||||
random.seed()
|
random.seed()
|
||||||
try:
|
|
||||||
from configparser import SafeConfigParser
|
from offlineimap.CustomConfig import CustomConfigParser
|
||||||
except ImportError: # python 2
|
|
||||||
from ConfigParser import SafeConfigParser
|
|
||||||
from . import default_conf
|
from . import default_conf
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +73,7 @@ class OLITestLib():
|
|||||||
#TODO, only do first time and cache then for subsequent calls?
|
#TODO, only do first time and cache then for subsequent calls?
|
||||||
assert cls.cred_file != None
|
assert cls.cred_file != None
|
||||||
assert cls.testdir != None
|
assert cls.testdir != None
|
||||||
config = SafeConfigParser()
|
config = CustomConfigParser()
|
||||||
config.readfp(default_conf)
|
config.readfp(default_conf)
|
||||||
default_conf.seek(0) # rewind config_file to start
|
default_conf.seek(0) # rewind config_file to start
|
||||||
config.read(cls.cred_file)
|
config.read(cls.cred_file)
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
|
96
test/tests/test_00_imaputil.py
Normal file
96
test/tests/test_00_imaputil.py
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# Copyright (C) 2012- Sebastian Spaeth & contributors
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from offlineimap import imaputil
|
||||||
|
from offlineimap.ui import UI_LIST, setglobalui
|
||||||
|
from offlineimap.CustomConfig import CustomConfigParser
|
||||||
|
|
||||||
|
from test.OLItest import OLITestLib
|
||||||
|
|
||||||
|
# Things need to be setup first, usually setup.py initializes everything.
|
||||||
|
# but if e.g. called from command line, we take care of default values here:
|
||||||
|
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))
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
class TestInternalFunctions(unittest.TestCase):
|
||||||
|
"""While the other test files test OfflineImap as a program, these
|
||||||
|
tests directly invoke internal helper functions to guarantee that
|
||||||
|
they deliver results as expected"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
#This is run before all tests in this class
|
||||||
|
config= OLITestLib.get_default_config()
|
||||||
|
setglobalui(UI_LIST['quiet'](config))
|
||||||
|
|
||||||
|
def test_01_imapsplit(self):
|
||||||
|
"""Test imaputil.imapsplit()"""
|
||||||
|
res = imaputil.imapsplit(b'(\\HasNoChildren) "." "INBOX.Sent"')
|
||||||
|
self.assertEqual(res, [b'(\\HasNoChildren)', b'"."', b'"INBOX.Sent"'])
|
||||||
|
|
||||||
|
def test_02_flagsplit(self):
|
||||||
|
"""Test imaputil.flagsplit()"""
|
||||||
|
res = imaputil.flagsplit(b'(\\Draft \\Deleted)')
|
||||||
|
self.assertEqual(res, [b'\\Draft', b'\\Deleted'])
|
||||||
|
|
||||||
|
res = imaputil.flagsplit(b'(FLAGS (\\Seen Old) UID 4807)')
|
||||||
|
self.assertEqual(res, [b'FLAGS', b'(\\Seen Old)', b'UID', b'4807'])
|
||||||
|
|
||||||
|
def test_03_options2hash(self):
|
||||||
|
"""Test imaputil.options2hash()"""
|
||||||
|
res = imaputil.options2hash([1,2,3,4,5,6])
|
||||||
|
self.assertEqual(res, {1:2, 3:4, 5:6})
|
||||||
|
|
||||||
|
def test_04_flags2hash(self):
|
||||||
|
"""Test imaputil.flags2hash()"""
|
||||||
|
res = imaputil.flags2hash(b'(FLAGS (\\Seen Old) UID 4807)')
|
||||||
|
self.assertEqual(res, {b'FLAGS': b'(\\Seen Old)', b'UID': b'4807'})
|
||||||
|
|
||||||
|
def test_05_flagsimap2maildir(self):
|
||||||
|
"""Test imaputil.flagsimap2maildir()"""
|
||||||
|
res = imaputil.flagsimap2maildir(b'(\\Draft \\Deleted)')
|
||||||
|
self.assertEqual(res, set(b'DT'))
|
||||||
|
|
||||||
|
def test_06_flagsmaildir2imap(self):
|
||||||
|
"""Test imaputil.flagsmaildir2imap()"""
|
||||||
|
res = imaputil.flagsmaildir2imap(set(b'DR'))
|
||||||
|
self.assertEqual(res, b'(\\Answered \\Draft)')
|
||||||
|
# test all possible flags
|
||||||
|
res = imaputil.flagsmaildir2imap(set(b'SRFTD'))
|
||||||
|
self.assertEqual(res, b'(\\Answered \\Deleted \\Draft \\Flagged \\Seen)')
|
||||||
|
|
||||||
|
def test_07_uid_sequence(self):
|
||||||
|
"""Test imaputil.uid_sequence()"""
|
||||||
|
res = imaputil.uid_sequence([1,2,3,4,5,10,12,13])
|
||||||
|
self.assertEqual(res, b'1:5,10,12:13')
|
Loading…
Reference in New Issue
Block a user