test: Validate the source test manifests

This helps prevent testing against invalid manifest data. It runs on the
source's manifest data, using the highest schema version parsed for the
source.
This commit is contained in:
Brian C. Lane 2023-06-12 11:30:52 -07:00 committed by Simon de Vlieger
parent e2345a6348
commit 0eb842e80c

View file

@ -127,6 +127,14 @@ def test_sources(source, case, tmp_path):
items = desc.get("items", {})
options = desc.get("options", {})
# What version to use for validation?
version = "2" if info.opts["2"] else "1"
schema = osbuild.meta.Schema(info.get_schema(version=version), source)
res = schema.validate(desc)
# NOTE: ValidationResult overrides __bool__ to return res.valid
if not res:
raise RuntimeError(f"Validation failed on {source}:{case}:{res.as_dict()}")
src = osbuild.sources.Source(info, items, options)
with osbuild.objectstore.ObjectStore(tmp_path) as store, \