Don't read default config files if --config is given
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 3 Apr 2014 16:06:11 +0000 (19:06 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 8 Apr 2014 09:17:46 +0000 (12:17 +0300)
Only read the default config files if the user does not provide any
config files via the --config command line option.

Change-Id: If816bd325ab96f9ba218bd7dbda96c2e10225e34
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
obs_service_gbp/command.py
tests/test_obs_service_gbp.py

index 4b684dd..41c8778 100644 (file)
@@ -174,13 +174,18 @@ def parse_args(argv):
                         choices=['yes', 'no'])
     parser.add_argument('--spec-vcs-tag', help='Set/update the VCS tag in the'
                                                'spec file')
-    parser.add_argument('--config', default=default_configs, action='append',
+    parser.add_argument('--config', action='append',
                         help='Config file to use, can be given multiple times')
     parser.add_argument('--git-meta', metavar='FILENAME',
                         help='Write data about the exported revision into '
                              'FILENAME in json format')
     args = parser.parse_args(argv)
     args.outdir = os.path.abspath(args.outdir)
+
+    # Use default config files if --config was not defined
+    if args.config is None:
+        args.config = default_configs
+
     return args
 
 def main(argv=None):
index 27123db..63f3e5a 100644 (file)
@@ -151,6 +151,14 @@ class TestService(UnitTestsBase):
         ok_(not os.path.exists(default_cache), os.listdir('.'))
         ok_(os.path.exists('my-repo-cache'), os.listdir('.'))
 
+    def test_options_config2(self):
+        """Test that empty/non-existent config file is ok"""
+        with open('my.conf', 'w') as conf:
+            conf.write('[foo-section]\n')
+
+        ok_((service(['--url', self.orig_repo.path, '--config', 'my.conf']))
+                == 0)
+
     def test_options_git_meta(self):
         """Test the --git-meta option"""
         eq_(service(['--url', self.orig_repo.path, '--git-meta=_git_meta']), 0)