def test_validate_schema_contains_conflict(instance): with pytest.raises(jsonschema.ValidationError) as errormsg: validate_schema(instance) assert errormsg.match( "contains and must_not_contain are not allowed to have " "the same members for the same object.") assert errormsg.match(" Common members: {'bla'}")
def test_validate_schema_colliding_names(): with pytest.raises(jsonschema.ValidationError) as error: validate_schema([ dict(name="name collision", command="echo moo"), dict(name="name collision", command="echo moo"), dict(name="name collision", command="echo moo") ]) assert error.match("Some names were not unique when whitespace was " "removed. Defined names:") assert error.match("name collision")
def test_validate_schema_conflicting_keys(): with pytest.raises(jsonschema.ValidationError) as error: validate_schema([ dict(name="bla", command="cowsay moo", files=[ dict(path="/some/path", should_exist=False, must_not_contain=["bla"]) ]) ]) assert error.match("Content checking not allowed on non existing" + " file: /some/path. Key = must_not_contain")
def test_no_empty_command(): with pytest.raises(jsonschema.ValidationError) as error: validate_schema([dict(name="empty", command="")]) assert error.match("command must not be empty")
def test_validate_schema(yaml_path): with Path(VALID_YAML_DIR, yaml_path).open() as yaml_fh: validate_schema(yaml.safe_load(yaml_fh))
def test_no_empty_name(): with pytest.raises(jsonschema.ValidationError) as error: validate_schema([dict(name="", command="echo nothing")]) assert error.match("name must not be empty")