Example #1
0

def test_validate_simple():
    # should be true since the dataset has a title (<A>) and a creator (<B>)
    t1 = c.validate(profile_uri='http://example.org/profile/Profile_B')
    print(t1)
    assert t1[0], t1[2]

    # should be false since the dataset does not have a created date (<C>)
    t2 = c.validate(profile_uri='http://example.org/profile/Profile_C')
    assert not t2[0], t2[2]

    # should be false since the dataset claims conformance with <C> but has no created date
    t3 = c.validate()
    assert not t3[0], t3[2]


if __name__ == "__main__":
    import logging
    logging.basicConfig(level=logging.INFO)
    c = Cheka('test_01_d.ttl', 'test_01_p.ttl')
    c.get_remote_profiles = True
    # print(c._get_profiles_hierarchy("http://example.org/profile/Profile_C"))
    import pprint

    # pprint.pprint(c.validate())
    pprint.pprint(
        c.validate(strategy="profile",
                   profile_uri="http://example.org/profile/Profile_C"))
    # c.clear_cache()
Example #2
0
        'extract validating Profile Resources.',
        type=lambda x: is_valid_file(parser, x),
        required=True)

    parser.add_argument(
        '-i',
        '--instance-uri',
        help=
        'The specific profile URI that you wish to validate the data graph against. This need not be set, in which'
        'case, Cheka will look for conformance claims (dct:conformsTo) in the data graph.',
        type=str)

    parser.add_argument(
        '-u',
        '--profile-uri',
        help=
        'The specific profile URI that you wish to validate the data graph against. This need not be set, in which'
        'case, Cheka will look for conformance claims (dct:conformsTo) in the data graph.',
        type=str)

    args = parser.parse_args()

    # do stuff
    c = Cheka(args.data.name, args.profiles.name)
    v = c.validate(profile_uri=args.uri)
    if v[0]:
        pprint.pprint('valid')
    else:
        pprint.pprint('invalid')
        pprint.pprint(v[2])
def test_shacl_fail(data_rdf, profiles_rdf):
    c = Cheka(data_graph_ttl=data_rdf, profiles_graph_ttl=profiles_rdf)
    x = c.validate()
    assert "A void:Dataset must have a dcterms:created property indicating an xsd:date or xsd:dateTime" in x[2]
    assert x[3] is None
def test_shacl_pass(data_rdf2, profiles_rdf):
    c = Cheka(data_graph_ttl=data_rdf2, profiles_graph_ttl=profiles_rdf)
    x = c.validate()
    assert x[0]  # i.e. valid
Example #5
0
    validation_type.add_argument(
        '-i', '--instance-uri',
        help='The specific profile URI that you wish to validate the data graph against. This need not be set, in which'
             'case, Cheka will look for conformance claims (dct:conformsTo) in the data graph.',
        type=str
    )

    validation_type.add_argument(
        '-u', '--profile-uri',
        help='The specific profile URI that you wish to validate the data graph against. This need not be set, in which'
             'case, Cheka will look for conformance claims (dct:conformsTo) in the data graph.',
        type=str
    )

    validation_type.add_argument(
        '-r', '--get-remotes',
        help='If set, tells Cheka to try and look up profile information, e.g. validators, via the profile\'s URI.',
        type=str
    )

    args = parser.parse_args()

    c = Cheka(args.data.name, args.profiles.name)
    v = c.validate(profile_uri=args.uri)  # TODO: read from any of the validation_type values
    if v[0]:
        pprint.pprint('valid')
    else:
        pprint.pprint('invalid')
        pprint.pprint(v[2])