summaryrefslogtreecommitdiffstats
path: root/testsuite/Testschema
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-16 09:22:49 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-16 09:22:49 -0400
commitdd196ce73618390736bd9df9ab41e97996ee7e9b (patch)
tree864a4672fb586c7d410fa8406ebae007db8b917d /testsuite/Testschema
parenta530d2d21c67b8ba2bd0575823a94084f2461118 (diff)
downloadbcfg2-dd196ce73618390736bd9df9ab41e97996ee7e9b.tar.gz
bcfg2-dd196ce73618390736bd9df9ab41e97996ee7e9b.tar.bz2
bcfg2-dd196ce73618390736bd9df9ab41e97996ee7e9b.zip
added unit tests to test for schema validity
Diffstat (limited to 'testsuite/Testschema')
-rw-r--r--testsuite/Testschema/test_schema.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/Testschema/test_schema.py b/testsuite/Testschema/test_schema.py
new file mode 100644
index 000000000..56fe76205
--- /dev/null
+++ b/testsuite/Testschema/test_schema.py
@@ -0,0 +1,40 @@
+import os
+import re
+import sys
+import glob
+from subprocess import Popen, PIPE, STDOUT
+
+# add all parent testsuite directories to sys.path to allow (most)
+# relative imports in python 2.4
+_path = os.path.dirname(__file__)
+while _path != '/':
+ if os.path.basename(_path).lower().startswith("test"):
+ sys.path.append(_path)
+ if os.path.basename(_path) == "testsuite":
+ break
+ _path = os.path.dirname(_path)
+from common import *
+
+# path to Bcfg2 schema directory
+srcpath = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
+ "schemas"))
+
+# test for xmllint existence
+try:
+ Popen(['xmllint'], stdout=PIPE, stderr=STDOUT).wait()
+ HAS_XMLLINT = True
+except OSError:
+ HAS_XMLLINT = False
+
+
+class TestSchemas(Bcfg2TestCase):
+ schema_url = "http://www.w3.org/2001/XMLSchema.xsd"
+
+ @skipUnless(HAS_XMLLINT, "xmllint not installed")
+ def test_valid(self):
+ schemas = [s for s in glob.glob(os.path.join(srcpath,'*.xsd'))]
+ xmllint = Popen(['xmllint', '--xinclude', '--noout', '--schema',
+ self.schema_url] + schemas,
+ stdout=PIPE, stderr=STDOUT)
+ print(xmllint.communicate()[0])
+ self.assertEqual(xmllint.wait(), 0)