Add support for 'connection' concept
This is a large refactor and as small as I could feasibly make it
while keeping the tests working. I'll do the documentation and
touch ups in the next commit to make digesting easier.
Change-Id: Iac5083996a183d1d8a9b6cb8f70836f7c39ee910
diff --git a/tests/test_layoutvalidator.py b/tests/test_layoutvalidator.py
index 5a8fc46..3dc3234 100644
--- a/tests/test_layoutvalidator.py
+++ b/tests/test_layoutvalidator.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ConfigParser
import os
import re
@@ -22,6 +23,7 @@
import yaml
import zuul.layoutvalidator
+import zuul.lib.connections
FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
'fixtures')
@@ -38,19 +40,31 @@
if not m:
continue
print fn
+
+ # Load any .conf file by the same name but .conf extension.
+ config_file = ("%s.conf" %
+ os.path.join(FIXTURE_DIR, 'layouts',
+ fn.split('.yaml')[0]))
+ if not os.path.isfile(config_file):
+ config_file = os.path.join(FIXTURE_DIR, 'layouts',
+ 'zuul_default.conf')
+ config = ConfigParser.ConfigParser()
+ config.read(config_file)
+ connections = zuul.lib.connections.configure_connections(config)
+
layout = os.path.join(FIXTURE_DIR, 'layouts', fn)
data = yaml.load(open(layout))
validator = zuul.layoutvalidator.LayoutValidator()
if m.group(1) == 'good':
try:
- validator.validate(data)
+ validator.validate(data, connections)
except voluptuous.Invalid as e:
raise Exception(
'Unexpected YAML syntax error in %s:\n %s' %
(fn, str(e)))
else:
try:
- validator.validate(data)
+ validator.validate(data, connections)
raise Exception("Expected a YAML syntax error in %s." %
fn)
except voluptuous.Invalid as e: