test/fmt_v2: add validation testing
Add a new test to check that validation works for the basic test pipeline. This needs to be extended in the future to check that invalid data is being caught properly, but it is a start.
This commit is contained in:
parent
b516c5bf19
commit
994c59a06c
1 changed files with 23 additions and 0 deletions
|
|
@ -68,6 +68,22 @@ class TestFormatV1(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.index = osbuild.meta.Index(os.curdir)
|
||||
|
||||
def load_manifest(self, desc):
|
||||
info = self.index.detect_format_info(desc)
|
||||
self.assertIsNotNone(info)
|
||||
fmt = info.module
|
||||
self.assertIsNotNone(fmt)
|
||||
manifest = fmt.load(desc, self.index)
|
||||
return manifest, fmt
|
||||
|
||||
def assert_validation(self, result):
|
||||
if result.valid:
|
||||
return
|
||||
|
||||
msg = "Validation failed:\n"
|
||||
msg += "\n".join(str(e) for e in result.errors)
|
||||
self.fail(msg)
|
||||
|
||||
def test_load(self):
|
||||
|
||||
desc = BASIC_PIPELINE
|
||||
|
|
@ -107,3 +123,10 @@ class TestFormatV1(unittest.TestCase):
|
|||
# the basic test manifest
|
||||
info = index.detect_format_info(BASIC_PIPELINE)
|
||||
self.assertEqual(info.version, "2")
|
||||
|
||||
def test_validation(self):
|
||||
desc = BASIC_PIPELINE
|
||||
_, fmt = self.load_manifest(desc)
|
||||
|
||||
res = fmt.validate(desc, self.index)
|
||||
self.assert_validation(res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue