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:
parent
6695294a29
commit
49dc76c434
2 changed files with 20 additions and 17 deletions
20
test/mod/test_meta.py
Normal file
20
test/mod/test_meta.py
Normal 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
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue