def test_uri_and_curie(self): """ Compile a model of URI's and Curies and then test the various types """ self.single_file_generator('py', PythonGenerator, filtr=metadata_filter, comparator=compare_python) # Check that the interpretations are correct self.single_file_generator( 'jsonld', ContextGenerator, filtr=ldcontext_metadata_filter, comparator=lambda expected, actual: compare_rdf( expected, actual, fmt="json-ld")) self.single_file_generator('json', JSONLDGenerator, filtr=json_metadata_filter) module = compile_python(env.expected_path(self.model_name + '.py')) curie_obj = module.C1("ex:obj1", hasCurie="ex:curie", hasURI="http://example.org/test/uri", hasNcName="A123", id2="ex:id2") instance_jsonld = loads('{ "ex": "http://example.org/test/inst#" }') g = as_rdf( curie_obj, [env.input_path(self.model_name + '.jsonld'), instance_jsonld]) env.eval_single_file(env.expected_path('uriandcurie.ttl'), g.serialize(format='ttl').decode(), lambda s: s, compare_rdf)
def rdf_comparator(expected_data: str, actual_data: str) -> str: """ compare expected_data to actual_data using basic RDF comparator method """ return compare_rdf(expected_data, actual_data)
def n3_comparator(expected_data: str, actual_data: str) -> str: """ compare expected_data in n3 format to actual_data in n3 format """ return compare_rdf(expected_data, actual_data, "n3")
def jsonld_comparator(expected_data: str, actual_data: str) -> str: """ Compare expected data in json-ld format to actual data in json-ld format """ return compare_rdf(expected_data, actual_data, "json-ld")
def rdf_comparator(expected_data: str, actual_data: str, fmt: Optional[str] = 'turtle') -> str: """ compare expected_data to actual_data using basic RDF comparator method """ return compare_rdf(expected_data, actual_data, fmt=fmt)