Merge "Allow test
command to use conf files"
This commit is contained in:
commit
ca6335d770
@ -118,12 +118,12 @@ def setup_config_settings(options):
|
|||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
## Load default config always
|
## Load default config always
|
||||||
config.readfp(cStringIO.StringIO(DEFAULT_CONF))
|
config.readfp(cStringIO.StringIO(DEFAULT_CONF))
|
||||||
if options.command == 'test':
|
if os.path.isfile(conf):
|
||||||
logger.debug("Not reading config for test output generation")
|
|
||||||
elif os.path.isfile(conf):
|
|
||||||
logger.debug("Reading config from {0}".format(conf))
|
logger.debug("Reading config from {0}".format(conf))
|
||||||
conffp = open(conf, 'r')
|
conffp = open(conf, 'r')
|
||||||
config.readfp(conffp)
|
config.readfp(conffp)
|
||||||
|
elif options.command == 'test':
|
||||||
|
logger.debug("Not requiring config for test output generation")
|
||||||
else:
|
else:
|
||||||
raise JenkinsJobsException(
|
raise JenkinsJobsException(
|
||||||
"A valid configuration file is required when not run as a test"
|
"A valid configuration file is required when not run as a test"
|
||||||
|
2
tests/cmd/fixtures/cmd-001.conf
Normal file
2
tests/cmd/fixtures/cmd-001.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[jenkins]
|
||||||
|
url=http://test-jenkins.with.non.default.url:8080/
|
@ -83,3 +83,18 @@ class CmdTests(testtools.TestCase):
|
|||||||
'r',
|
'r',
|
||||||
'utf-8').read()
|
'utf-8').read()
|
||||||
self.assertEqual(console_out.getvalue(), xml_content)
|
self.assertEqual(console_out.getvalue(), xml_content)
|
||||||
|
|
||||||
|
def test_config_with_test(self):
|
||||||
|
"""
|
||||||
|
Run test mode and pass a config file
|
||||||
|
"""
|
||||||
|
args = self.parser.parse_args(['--conf',
|
||||||
|
os.path.join(self.fixtures_path,
|
||||||
|
'cmd-001.conf'),
|
||||||
|
'test',
|
||||||
|
os.path.join(self.fixtures_path,
|
||||||
|
'cmd-001.yaml'),
|
||||||
|
'foo-job'])
|
||||||
|
config = cmd.setup_config_settings(args)
|
||||||
|
self.assertEqual(config.get('jenkins', 'url'),
|
||||||
|
"http://test-jenkins.with.non.default.url:8080/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user