From 3f95986981bd02e703c1fbf582b1412be638687c Mon Sep 17 00:00:00 2001 From: gryf Date: Mon, 28 Nov 2016 17:57:49 +0100 Subject: [PATCH] Fix the tests. For some reason, database key was treated differently in configparser object in python 3.4.2. In Python 3.4.5 everything is fine. Fixed the defaults to make sure all string options are treated equally. --- setup.py | 2 +- slack_backup/config.py | 16 +++++++++++----- tests/test_config.py | 9 +-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index eab8b03..1573435 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: setup(name="slack-backup", packages=["slack_backup"], - version="0.4.1", + version="0.4.2", description="Make copy of slack converstaions", author="Roman Dobosz", author_email="gryf73@gmail.com", diff --git a/slack_backup/config.py b/slack_backup/config.py index 67565e8..7840a92 100644 --- a/slack_backup/config.py +++ b/slack_backup/config.py @@ -83,19 +83,25 @@ class Config(object): val = self.cp.get(section, option, fallback='[]') val = json.loads(val) else: - val = self.cp.get(section, option, fallback='') + val = self.cp.get(section, option, fallback=None) self._options[option] = val def update_args(self, args): + if 'parser' not in args: + # it doesn't make sense to update args, since no action was + # choosen + return # special case, re-set information for verbose/quiet options - if args.verbose is not None and self._options['quiet'] is not None: - self._options['quiet'] = 0 + if 'verbose' in args and args.verbose is not None: self._options['verbose'] = args.verbose - if args.quiet is not None and self._options['verbose'] is not None: - self._options['verbose'] = 0 + if self._options['quiet'] is not None: + self._options['quiet'] = 0 + if 'quiet' in args and args.quiet is not None: self._options['quiet'] = args.quiet + if self._options['verbose'] is not None: + self._options['verbose'] = 0 for sec_id in (args.parser, 'common'): for option in self.sections[sec_id]: diff --git a/tests/test_config.py b/tests/test_config.py index 3644f1d..d556f98 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -51,13 +51,6 @@ class TestConfig(unittest.TestCase): args.config = None args.parser = 'fetch' args.verbose = 2 - args.quiet = None - args.channels = None - args.database = None - args.user = None - args.password = None - args.team = None - args.token = None conf = config.Config() conf.update(args) @@ -66,7 +59,7 @@ class TestConfig(unittest.TestCase): 'verbose': 2, 'quiet': 0, 'channels': [], - 'database': '', + 'database': None, 'user': None, 'password': None, 'team': None,