diff --git a/app.py b/app.py index b224ea3a..9022f2ee 100644 --- a/app.py +++ b/app.py @@ -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()] diff --git a/tests/test_API.py b/tests/test_API.py index 0c8e5aac..255f0d90 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -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())) diff --git a/tests/test_gen_shacl.py b/tests/test_gen_shacl.py index 848dee7f..3a12f626 100644 --- a/tests/test_gen_shacl.py +++ b/tests/test_gen_shacl.py @@ -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 ) @@ -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 ) @@ -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 ) diff --git a/tests/test_vocab.py b/tests/test_vocab.py index 58d0aea3..bde6942b 100644 --- a/tests/test_vocab.py +++ b/tests/test_vocab.py @@ -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#" @@ -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), "' @@ -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__":