test: add new test suite for 'meta' module

Move the checks for `meta.Schema` from `test_osbuild.py` into the new
test suite, converting it to use pytest in the process.
This commit is contained in:
Christian Kellner 2022-03-23 14:36:19 +01:00
parent 6695294a29
commit 49dc76c434
2 changed files with 20 additions and 17 deletions

20
test/mod/test_meta.py Normal file
View file

@ -0,0 +1,20 @@
import osbuild
import osbuild.meta
def test_schema():
schema = osbuild.meta.Schema(None)
assert not schema
schema = osbuild.meta.Schema({"type": "bool"}) # should be 'boolean'
assert not schema.check().valid
assert not schema
schema = osbuild.meta.Schema({"type": "array", "minItems": 3})
assert schema.check().valid
assert schema
res = schema.validate([1, 2])
assert not res
res = schema.validate([1, 2, 3])
assert res

View file

@ -289,20 +289,3 @@ class TestDescriptions(unittest.TestCase):
for version in ["1", "2"]:
with self.subTest(version=version):
self.check_moduleinfo(version)
def test_schema(self):
schema = osbuild.meta.Schema(None)
self.assertFalse(schema)
schema = osbuild.meta.Schema({"type": "bool"}) # should be 'boolean'
self.assertFalse(schema.check().valid)
self.assertFalse(schema)
schema = osbuild.meta.Schema({"type": "array", "minItems": 3})
self.assertTrue(schema.check().valid)
self.assertTrue(schema)
res = schema.validate([1, 2])
self.assertFalse(res)
res = schema.validate([1, 2, 3])
self.assertTrue(res)