예제 #1
0
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'}")
예제 #2
0
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")
예제 #3
0
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")
예제 #4
0
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")
예제 #5
0
def test_validate_schema(yaml_path):
    with Path(VALID_YAML_DIR, yaml_path).open() as yaml_fh:
        validate_schema(yaml.safe_load(yaml_fh))
예제 #6
0
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")