Skip to content

Commit

Permalink
test-cases: add manifest
Browse files Browse the repository at this point in the history
Auto-generate it with `make-metadata.py` and then use RMLMapper with the
mapping to make the RDF version of the manifest.
  • Loading branch information
DylanVanAssche committed Dec 9, 2024
1 parent edc8dc1 commit e442b6b
Show file tree
Hide file tree
Showing 5 changed files with 1,901 additions and 0 deletions.
79 changes: 79 additions & 0 deletions test-cases/descriptions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ID,Title,Purpose,"Error
expected?",Input ,"Output
default","Output
1","Output
2","Output
3",Comment
TARGET,,,,,,,,,
RMLTTC0000,Default target,Test exporting all triples to the default Target when not Targets are specified.,no,Friends.json,default.nq,,,,
RMLTTC0001a,Single Target: Subject Map,Test exporting all triples to a single Target with a given subject.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0001b,Single Target: Predicate Map,Test exporting all triples to a single Target with a given predicate.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0001c,Single Target: Object Map,Test exporting all triples to a single Target with a given object reference.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0001d,Single Target: Graph Map,Test exporting all triples within a named graph to a single Target.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0001e,Single Target: Language Map,Test exporting all triples with a given language tag to a single Target.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0001f,Single Target: Datatype Map,Test exporting all triples with a given datatype to a single Target.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0002a,Multiple Targets: Same Term Map,Test exporting all triples to multiple Targets in the same Term Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002b,Multiple Targets: Subject Map and Predicate Map,Test exporting all triples to a Target in a Subject Map and a Target in a Predicate Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002c,Multiple Targets: Subject Map and Object Map,Test exporting all triples to a Target in a Subject Map and a Target in a Object Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002d,Multiple Targets: Predicate Map and Object Map,Test exporting all triples to a Target in a Predicate Map and a Target in a Object Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002e,"Multiple Targets: Subject Map, Predicate Map, and Object Map","Test exporting all triples to a Target in a Subject Map, a Target in a Predicate Map, and a Target in a Object Map.",no,Friends.json,default.nq,dump1.nq,dump2.nq,dump3.nq,
RMLTTC0002f,Multiple Targets: Subject Map and Graph Map,Test exporting all triples to a Target in a Subject Map and a Target in a Graph Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002g,Multiple Targets: Predicate Map and Graph Map,Test exporting all triples to a Target in a Predicate Map and a Target in a Graph Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002h,Multiple Targets: Object Map and Graph Map,Test exporting all triples to a Target in a Object Map and a Target in a Graph Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002i,Multiple Targets: Language Map and Graph Map,Test exporting all triples to a Target in a Language Map and a Target in a Graph Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002j,Multiple Targets: Language Map and Object Map,Test exporting all triples to a Target in a Language Map and a Target in a Object Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002k,Multiple Targets: Datatype Map and Graph Map,Test exporting all triples to a Target in a Datatype Map and a Target in a Graph Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002l,Multiple Targets: Datatype Map and Object Map,Test exporting all triples to a Target in a Datatype Map and a Target in a Object Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002m,Multiple Targets: Multiple Predicate Maps,Test exporting all triples to Targets in multiple Predicate Maps.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002n,Multiple Targets: Multiple Object Maps,Test exporting all triples to Targets in multiple Object Maps.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002o,Multiple Targets: Multiple Graph Maps,Test exporting all triples to Targets in multiple Graph Maps.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002p,Multiple Targets: Multiple Language Maps,Test exporting all triples to Targets in multiple Language Maps.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002q,Multiple Targets: Multiple Datatype Maps,Test exporting all triples to Targets in multiple Datatype Maps.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0002r,Multiple Targets: Multiple Term Maps with same Target,Test exporting all triples to same Target in multiple Term Maps.,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0003a,Overriding Targets: Seperate Triples Map,Test exporting some triples to a different Target with a separate Triples Map.,no,Friends.json,default.nq,dump1.nq,dump2.nq,,
RMLTTC0004a,Target JSON-LD,Test export all triples as JSON-LD,no,Friends.json,default.nq,dump1.jsonld,,,"Uncommon RDF formats: LD Patch, Microdata, RDFa, TriG, etc. are skipped in test cases."
RMLTTC0004b,Target N3,Test export all triples as N3,no,Friends.json,default.nq,dump1.n3,,,
RMLTTC0004c,Target N-Triples,Test export all triples as N-Triples,no,Friends.json,default.nq,dump1.nt,,,
RMLTTC0004d,Target N-Quads,Test export all triples as N-Quads,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0004e,Target RDF/JSON,Test export all triples as RDF/JSON,no,Friends.json,default.nq,dump1.rdfjson,,,
RMLTTC0004f,Target RDF/XML,Test export all triples as RDF/XML,no,Friends.json,default.nq,dump1.rdfxml,,,
RMLTTC0004g,Target Turtle,Test export all triples as Turtle,no,Friends.json,default.nq,dump1.ttl,,,
RMLTTC0005a,Target UTF-8,Test export all triples with UTF-8 encoding,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0005b,Target UTF-16,Test export all triples with UTF-16 encoding,no,Friends.json,default.nq,dump1-utf16.nq,,,
RMLTTC0006a,Target no compression,Test export all triples with no compression,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0006b,Target GZip compression,Test export all triples with GZip compression,no,Friends.json,default.nq,dump1.nq.gz,,,
RMLTTC0006c,Target Zip compression,Test export all triples with ZIP compression,no,Friends.json,default.nq,dump1.nq.zip,,,
RMLTTC0006d,Target TarXz compression,Test export all triples with TarXZ compression,no,Friends.json,default.nq,dump1.nq.tar.xz,,,
RMLTTC0006e,Target TarGzip compression,Test export all triples with TarGZip compression,no,Friends.json,default.nq,dump1.nq.tar.gz,,,
RMLTTC0007a,Target with DCAT access description,Test export all triples to a target with DCAT access description,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0007b,Target with VoID access description,Test export all triples to a target with VoID access description,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0007c,Target with SD access description,Test export all triples to a target with SD access description,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0007d,Target with Web of Things access description,Test export all triples to a target with Web of Things access description,no,Friends.json,default.nq,dump1.nq,,,
RMLTTC0007e,Target with dcat:format,Test dcat:format in a Target,no,Friends.json,default.nq,dump1.nq,,,
SOURCE,,,,,,,,,
RMLSTC0001a,Source with UTF-8 encoding,Test source with UTF-8 encoding,no,Friends.json,default.nq,,,,
RMLSTC0001b,Source with UTF-16 encoding,Test source with UTF-16 encoding,no,Friends-UTF16.json,default.nq,,,,
RMLSTC0002a,Source no compression,Test source without compression,no,Friends.json,default.nq,,,,
RMLSTC0002b,Source GZip compression,Test source with GZip compression,no,Friends.json.gz,default.nq,,,,
RMLSTC0002c,Source Zip compression,Test source with ZIP compression,no,Friends.json.zip,default.nq,,,,
RMLSTC0002d,Source TarXz compression,Test source with TarXZ compression,no,Friends.json.tar.xz,default.nq,,,,
RMLSTC0002e,Source TarGzip compression,Test source with TarGZip compression,no,Friends.json.tar.gz,default.nq,,,,
RMLSTC0003,Source with query,Test source which requires a query,no,Friends.nt,default.nq,,,,
RMLSTC0004a,Source with default NULL values,Test source with default NULL values,no,Friends-NULL.csv,default.nq,,,,
RMLSTC0004b,Source with one NULL value,Test source with one NULL value defined,no,Friends-NULL.csv,default.nq,,,,
RMLSTC0004c,Source with multiple NULL values,Test source with multiple NULL values defined,no,Friends-NULL2.csv,default.nq,,,,
RMLSTC0005a,Source overrride access: NULL values,Test source with data access description providing NULL values which we override.,no,Friends-NULL.csv,default.nq,,,,
RMLSTC0005b,Source overrride access: Encoding,Test source with data access description providing encoding which we override.,no,Friends.csv,default.nq,,,,
RMLSTC0006a,Source with DCAT access description,Test source with DCAT data access description,no,Friends.json,default.nq,,,,
RMLSTC0006b,Source with VoID access description,Test source with VoID data access description,no,Friends.nt,default.nq,,,,
RMLSTC0006c,Source with SD access description,Test source with SD data access description,no,Friends.nt,default.nq,,,,
RMLSTC0006d,Source with CSVW access description,Test source with CSVW data access description,no,Friends.csv,default.nq,,,,
RMLSTC0006e,Source with Web of Things access description,Test source with Web of Things data access description,no,Friends.json,default.nq,,,,
RMLSTC0006f,Source with D2RQ access description,Test source with D2RQ access description for SQL databases,no,Friends.csv,default.nq,,,,
RMLSTC0007a,Source with JSONPath reference formulation,Test source with JSONPath reference formulation,no,Friends.json,default.nq,,,,
RMLSTC0007b,Source with CSV reference formulation,Test source with Tabular reference formulation,no,Friends.csv,default.nq,,,,
RMLSTC0007c,Source with XPath reference formulation,Test source with XPath reference formulation,no,Friends.xml,default.nq,,,,
RMLSTC0007d,Source with XPath reference formulation with namespaces,Test source with XPath reference formulation with namespaces,no,Friends.xml,default.nq,,,,
,,,,,,,,,
,Missing,,,,,,,,
,SPARQL endpoint,,,,,,,,
141 changes: 141 additions & 0 deletions test-cases/make-metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env python3

import os
import sys
import glob
import csv

def get_title_description(testcase: str):
with open ('descriptions.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
if row[0] == testcase:
return row[1], row[2]

def main(spec: str):
with open ('metadata.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['ID', 'title', 'description', 'specification',
'mapping', 'input_format1', 'input_format2',
'input_format3', 'output_format1', 'output_format2',
'output_format3', 'input1', 'input2', 'input3',
'output1', 'output2', 'output3', 'error'])
for testcase in glob.glob('RML*'):
title, description = get_title_description(testcase)
error = 'false'
input1 = ''
input2 = ''
input3 = ''
input_format1 = ''
input_format2 = ''
input_format3 = ''
output1 = ''
output2 = ''
output3 = ''
output_format1 = ''
output_format2 = ''
output_format3 = ''

# Input file
if os.path.exists(os.path.join(testcase, 'Friends.json')):
input1 = 'Friends.json'
input_format1 = 'application/json'
elif os.path.exists(os.path.join(testcase, 'Friends-UTF16.json')):
input1 = 'Friends-UTF16.json'
input_format1 = 'application/json'
elif os.path.exists(os.path.join(testcase, 'Friends.json.gz')):
input1 = 'Friends.json.gz'
input_format1 = 'application/gzip+json'
elif os.path.exists(os.path.join(testcase, 'Friends.json.zip')):
input1 = 'Friends.json.zip'
input_format1 = 'application/gzip+json'
elif os.path.exists(os.path.join(testcase, 'Friends.json.tar.xz')):
input1 = 'Friends.json.tar.xz'
input_format1 = 'application/tarxz+json'
elif os.path.exists(os.path.join(testcase, 'Friends.json.tar.gz')):
input1 = 'Friends.json.tar.gz'
input_format1 = 'application/targz+json'
elif os.path.exists(os.path.join(testcase, 'Friends-NULL.csv')):
input1 = 'Friends-NULL.csv'
input_format1 = 'text/csv'
elif os.path.exists(os.path.join(testcase, 'Friends-NULL2.csv')):
input1 = 'Friends-NULL2.csv'
input_format1 = 'text/csv'
elif os.path.exists(os.path.join(testcase, 'Friends.nt')):
input1 = 'Friends.nt'
input_format1 = 'application/n-triples'
elif os.path.exists(os.path.join(testcase, 'Friends.csv')):
input1 = 'Friends.csv'
input_format1 = 'text/csv'
elif os.path.exists(os.path.join(testcase, 'Friends.json')):
input1 = 'Friends.json'
input_format1 = 'application/json'
elif os.path.exists(os.path.join(testcase, 'Friends.xml')):
input1 = 'Friends.xml'
input_format1 = 'text/xml'
else:
input1 = f'http://w3id.org/rml/resources/rml-io/{testcase}/Friends.json'
input_format1 = 'application/json'

# Mapping file
if os.path.exists(os.path.join(testcase, 'mapping.ttl')):
mapping_file = 'mapping.ttl'
else:
raise ValueError('Mapping file missing!')

# Output files
if os.path.exists(os.path.join(testcase, 'default.nq')):
output1 = 'default.nq'
output_format1 = 'application/n-quads'
else:
raise NotImplementedError('output1 is not known, but required')

if os.path.exists(os.path.join(testcase, 'dump1.nq')):
output2 = 'dump1.nq'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.nt')):
output2 = 'dump1.nt'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.n3')):
output2 = 'dump1.n3'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.jsonld')):
output2 = 'dump1.jsonld'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.rdfjson')):
output2 = 'dump1.rdfjson'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.rdfxml')):
output2 = 'dump1.rdfxml'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.ttl')):
output2 = 'dump1.ttl'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.nq.gz')):
output2 = 'dump1.nq.gz'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.nq.zip')):
output2 = 'dump1.nq.zip'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.nq.tar.xz')):
output2 = 'dump1.nq.tar.xz'
output_format2 = 'application/n-quads'
elif os.path.exists(os.path.join(testcase, 'dump1.nq.tar.gz')):
output2 = 'dump1.nq.tar.gz'
output_format2 = 'application/n-quads'

if os.path.exists(os.path.join(testcase, 'dump2.nq')):
output3 = 'dump2.nq'
output_format3 = 'application/n-quads'

writer.writerow([testcase, title, description, spec, mapping_file,
input_format1, input_format2, input_format3,
output_format1, output_format2, output_format3,
input1, input2, input3, output1, output2,
output3, error])

if __name__ == '__main__':
if len(sys.argv) != 2:
print('Usage: ./make-metadata.py <IRI OF SPEC>')
sys.exit(1)
main(sys.argv[1])
Loading

0 comments on commit e442b6b

Please sign in to comment.