Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Api bioschemas profile validation #155

Merged
merged 8 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,20 @@ def get(self):
return check_kg(kg, True)


@fc_inspect_namespace.route("/bioschemas_validation")
class InspectBioschemas(Resource):
@fc_inspect_namespace.expect(reqparse)
def get(self):
"""Validate an RDF JSON-LD graph against Bioschemas profiles"""
args = reqparse.parse_args()
url = args["url"]

web_res = WebResource(url)
kg = web_res.get_rdf()
results = validate_any_from_KG(kg)
return results


def list_routes():
return ["%s" % rule for rule in app.url_map.iter_rules()]

Expand Down
7 changes: 7 additions & 0 deletions tests/test_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,10 @@ def test_inspect_ontologies(self):
self.assertEqual(200, response.status_code)
self.assertEqual(3, len(response.get_json()["classes"]))
self.assertEqual(14, len(response.get_json()["properties"]))

def test_inspect_bioschemas(self):
response = self.app.get(
"/api/inspect/bioschemas_validation?url=" + self.url_biotools,
)
self.assertEqual(200, response.status_code)
self.assertLess(0, len(response.get_json()))
14 changes: 7 additions & 7 deletions tests/test_gen_shacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def test_biotools_validation(self):
input_url="https://bio.tools/api/jaspar?format=jsonld", rdf_syntax="json-ld"
)
self.assertGreater(len(res), 0)
self.assertEquals(len(res["https://bio.tools/jaspar"]["warnings"]), 5)
self.assertEquals(len(res["https://bio.tools/jaspar"]["errors"]), 3)
self.assertEqual(len(res["https://bio.tools/jaspar"]["warnings"]), 5)
self.assertEqual(len(res["https://bio.tools/jaspar"]["errors"]), 3)

def test_pangaea_validation(self):
res = validate_any_from_microdata(
input_url="https://doi.pangaea.de/10.1594/PANGAEA.914331"
)
self.assertGreater(len(res[0]), 0)
self.assertEquals(
self.assertEqual(
len(res[0]["https://doi.org/10.1594/PANGAEA.914331"]["errors"]), 0
)

Expand All @@ -109,10 +109,10 @@ def test_datacite_validation(self):
)
self.assertGreater(len(res[0]), 0)
self.assertFalse(res[0]["https://doi.org/10.7892/boris.108387"]["conforms"])
self.assertEquals(
self.assertEqual(
len(res[0]["https://doi.org/10.7892/boris.108387"]["errors"]), 2
)
self.assertEquals(
self.assertEqual(
len(res[0]["https://doi.org/10.7892/boris.108387"]["warnings"]), 11
)

Expand All @@ -126,8 +126,8 @@ def test_datacite_validation_kg(self):
res = validate_any_from_KG(kg=kg)
self.assertGreater(len(res), 0)
self.assertFalse(res["https://doi.org/10.7892/boris.108387"]["conforms"])
self.assertEquals(len(res["https://doi.org/10.7892/boris.108387"]["errors"]), 2)
self.assertEquals(
self.assertEqual(len(res["https://doi.org/10.7892/boris.108387"]["errors"]), 2)
self.assertEqual(
len(res["https://doi.org/10.7892/boris.108387"]["warnings"]), 11
)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_exclude_ns_prefix(self):
print("toto")
print(len(kg))
print(len(cleaned_kg))
self.assertEquals(len(kg) - 2, len(cleaned_kg))
self.assertEqual(len(kg) - 2, len(cleaned_kg))

def test_exclude_xhtml(self):
ns = "http://www.w3.org/1999/xhtml/vocab#"
Expand All @@ -246,7 +246,7 @@ def test_exclude_xhtml(self):
print(q_xhtml)

res = kg.query(q_xhtml)
self.assertEquals(len(res), 1)
self.assertEqual(len(res), 1)

q_del = (
'DELETE {?s ?p ?o} WHERE { ?s ?p ?o . FILTER (strstarts(str(?p), "'
Expand All @@ -257,7 +257,7 @@ def test_exclude_xhtml(self):
print(kg.serialize(format="turtle"))

res = kg.query(q_xhtml)
self.assertEquals(len(res), 0)
self.assertEqual(len(res), 0)


if __name__ == "__main__":
Expand Down