From 75be2c284dc0647765046b55655ecd0dbb64f131 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 21 Apr 2018 22:55:05 +0200 Subject: Functioning tests of EmailServer creation with mock. --- archive_folder.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'archive_folder.py') diff --git a/archive_folder.py b/archive_folder.py index e321dfe..744fcba 100755 --- a/archive_folder.py +++ b/archive_folder.py @@ -189,30 +189,21 @@ class EmailServer(object): config = self.get_config() acc_name = serverKey if serverKey is not None \ else config['general']['account'] - if config.has_section(acc_name): - self.cfg = dict(config.items(acc_name)) - else: - self.cfg = { - 'host': 'localhost', - 'username': 'unknown', - 'password': 'verysecret' - } + self.cfg = dict(config.items(acc_name)) self.archive_root = archive_root self.__box = self.__login(**self.cfg) def __login(self, host='localhost', username=None, password=None, ssl=None): box = imaplib.IMAP4_SSL(host=host) - ok, data = box.login(username, password) + res = box.login(username, password) + ok, data = res if ok != 'OK': raise ServerError('Cannot login with credentials %s' % str((host, username, password,))) ok, data = box.capability() - log.debug('data = %s', data) capas = data[0].decode() - log.debug('capas = %s', capas) box.features_present = Capas._make(['MOVE' in capas, 'UIDPLUS' in capas]) - log.debug('features_present = %s', box.features_present) @staticmethod @functools.lru_cache() -- cgit