Esempio n. 1
0
 def test_modules(self):
     """Validate all modules with a stricter metaschema"""
     (validator, _) = get_jsonschema_validator()
     for (name, value) in get_schemas().items():
         if value:
             validate_cloudconfig_metaschema(validator, value)
         else:
             logging.warning("module %s has no schema definition", name)
Esempio n. 2
0
    def test_validate_bad_module(self):
        """Throw exception by default, don't throw if throw=False

        item should be 'items' and is therefore interpreted as an additional
        property which is invalid with a strict metaschema
        """
        (validator, _) = get_jsonschema_validator()
        schema = {
            "type": "array",
            "item": {
                "type": "object",
            },
        }
        with pytest.raises(
                SchemaValidationError,
                match=r"Additional properties are not allowed.*",
        ):

            validate_cloudconfig_metaschema(validator, schema)

        validate_cloudconfig_metaschema(validator, schema, throw=False)