From 7eea5e99222166731c7e55a95f6c00928289b4b9 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 7 Nov 2020 08:48:38 +0000 Subject: Added failing unit test: No matching triples found for predicate cc:License --- test/test_shex.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/test_shex.py (limited to 'test/test_shex.py') diff --git a/test/test_shex.py b/test/test_shex.py new file mode 100644 index 0000000..ead2396 --- /dev/null +++ b/test/test_shex.py @@ -0,0 +1,35 @@ +import schema_salad.schema +import schema_salad.ref_resolver +import schema_salad.jsonld_context +import pkg_resources +import logging +import traceback +# from rdflib import Graph, Namespace +from pyshex.evaluate import evaluate +import unittest + +class TestStringMethods(unittest.TestCase): + + def test_schema(self): + with open("bh20sequploader/bh20seq-schema.yml") as schema_resource: + metadata_schema = schema_salad.schema.load_schema("https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml") + (document_loader, + avsc_names, + schema_metadata, + metaschema_loader) = metadata_schema + print(metadata_schema) + assert(isinstance(avsc_names, schema_salad.avro.schema.Names)) + metadatafile = "test/data/input/TN_UT2.yaml" + doc, metadata = schema_salad.schema.load_and_validate(document_loader, avsc_names, metadatafile, True) + print(doc) + g = schema_salad.jsonld_context.makerdf("workflow", doc, document_loader.ctx) + shex = pkg_resources.resource_stream(__name__, "../bh20sequploader/bh20seq-shex.rdf").read().decode("utf-8") + rslt, reason = evaluate(g, shex, doc["id"], "https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-shex.rdf#submissionShape") + + g.serialize(format="ntriples") + + if not rslt: + raise Exception(reason) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3