test: Skip check_moduleinfo for unsupported versions

Most modules do not support both schema versions. This is masked by
module type code in get_schema() in most cases, but really should not be
tested. This skips running check_moduleinfo if the module doesn't
support the version. eg. org.osbuild.librepo only supports v2.
This commit is contained in:
Brian C. Lane 2023-06-12 16:09:54 -07:00 committed by Simon de Vlieger
parent 0eb842e80c
commit e4ae9ec018

View file

@ -282,6 +282,10 @@ class TestDescriptions(unittest.TestCase):
try:
info = osbuild.meta.ModuleInfo.load(os.curdir, klass, name)
if not info.opts[version]:
print(f"{klass} '{name}' does not support version '{version}'")
continue
schema = osbuild.meta.Schema(info.get_schema(version), name)
res = schema.check()
if not res:
@ -291,6 +295,10 @@ class TestDescriptions(unittest.TestCase):
except json.decoder.JSONDecodeError as e:
msg = f"{klass} '{name}' has invalid STAGE_OPTS\n\t" + str(e)
self.fail(msg)
# pylint: disable=broad-exception-caught
except Exception as e:
msg = f"{klass} '{name}': " + str(e)
self.fail(msg)
def test_moduleinfo(self):
for version in ["1", "2"]: