Add support for multiple config paths

Help messages mention support for multiple config paths separated by colons.
Yet this feature is not implemented. This change implements it.

Change-Id: Ieb99cba98c9cf775765eacd4ebadfbccfa815a65
This commit is contained in:
Mathieu Gagné 2016-06-06 22:34:45 -04:00
parent 3b01b4df7d
commit 0941f4e3b0
3 changed files with 30 additions and 7 deletions

View File

@ -44,13 +44,15 @@ class Builder(object):
def load_files(self, path):
files_to_process = []
if os.path.isdir(path):
files_to_process.extend([os.path.join(path, f)
for f in os.listdir(path)
if (f.endswith('.yaml')
or f.endswith('.yml'))])
else:
files_to_process.append(path)
paths = path.split(':')
for path in paths:
if os.path.isdir(path):
files_to_process.extend([os.path.join(path, f)
for f in os.listdir(path)
if (f.endswith('.yaml')
or f.endswith('.yml'))])
else:
files_to_process.append(path)
for fn in files_to_process:
self.parser.parse(fn)

View File

@ -71,6 +71,25 @@ class TestCaseValidate(TestCase):
(stdout + stderr),
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
def test_validate_mutiple_directories_success(self):
paths = [
os.path.join(
os.path.dirname(__file__),
'../fixtures/cmd/validate/test0001'),
os.path.join(
os.path.dirname(__file__),
'../fixtures/cmd/validate/test0002'),
]
required = [
'SUCCESS!',
]
stdout, stderr = self.shell(
'validate %s' % ':'.join(paths), exitcodes=[0])
for r in required:
self.assertThat(
(stdout + stderr),
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
def test_validate_directory_invalid(self):
path = os.path.join(
os.path.dirname(__file__), '../fixtures/cmd/validate/__invalid__')

View File

@ -0,0 +1,2 @@
dashboard:
title: New dashboard (2)