From 8cbae10e87efa663a9cfe5dee3fbf3c757596de7 Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 9 Nov 2022 17:10:12 +0100 Subject: [PATCH 1/7] adding git status --- app.py | 9 +++++++++ templates/nav_bar.html | 2 +- tests/test_API.py | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index b2efef30..65104249 100644 --- a/app.py +++ b/app.py @@ -570,6 +570,15 @@ def get(self, url): return check_kg(kg, True) +@fc_inspect_namespace.route("/inspect_bioschemas/") +class InspectBioschemas(Resource): + def get(self, url): + """Validate an RDF JSON-LD graph against Bioschemas profiles""" + 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/templates/nav_bar.html b/templates/nav_bar.html index 1e0ccea8..5bec05ed 100644 --- a/templates/nav_bar.html +++ b/templates/nav_bar.html @@ -51,7 +51,7 @@ About us - API Swagger + API diff --git a/tests/test_API.py b/tests/test_API.py index dab82e0a..86af997c 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -119,3 +119,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/inspect_bioschemas/" + self.url_biotools, + ) + self.assertEqual(200, response.status_code) + self.assertGreater(0, len(response.get_json())) \ No newline at end of file From 9efdfb085c6acb5b0f3c321853f832e8cc8e82f1 Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 9 Nov 2022 17:11:02 +0100 Subject: [PATCH 2/7] adding bioschemas profile validation in API --- app.py | 2 +- tests/test_API.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 65104249..e35201bf 100644 --- a/app.py +++ b/app.py @@ -570,7 +570,7 @@ def get(self, url): return check_kg(kg, True) -@fc_inspect_namespace.route("/inspect_bioschemas/") +@fc_inspect_namespace.route("/validate_bioschemas/") class InspectBioschemas(Resource): def get(self, url): """Validate an RDF JSON-LD graph against Bioschemas profiles""" diff --git a/tests/test_API.py b/tests/test_API.py index 86af997c..4db6b4bb 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -122,7 +122,7 @@ def test_inspect_ontologies(self): def test_inspect_bioschemas(self): response = self.app.get( - "/api/inspect/inspect_bioschemas/" + self.url_biotools, + "/api/inspect/validate_bioschemas/" + self.url_biotools, ) self.assertEqual(200, response.status_code) self.assertGreater(0, len(response.get_json())) \ No newline at end of file From 5b42d744634a3d7ab63e8cfd53345aee223267e9 Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 9 Nov 2022 17:50:00 +0100 Subject: [PATCH 3/7] black --- app.py | 1 + tests/test_API.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index e35201bf..bf02293d 100644 --- a/app.py +++ b/app.py @@ -570,6 +570,7 @@ def get(self, url): return check_kg(kg, True) + @fc_inspect_namespace.route("/validate_bioschemas/") class InspectBioschemas(Resource): def get(self, url): diff --git a/tests/test_API.py b/tests/test_API.py index 4db6b4bb..c6ed4777 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -125,4 +125,4 @@ def test_inspect_bioschemas(self): "/api/inspect/validate_bioschemas/" + self.url_biotools, ) self.assertEqual(200, response.status_code) - self.assertGreater(0, len(response.get_json())) \ No newline at end of file + self.assertGreater(0, len(response.get_json())) From 687147abab4900bb87a56fecbfdf80dd556e3a4e Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Thu, 10 Nov 2022 09:16:51 +0100 Subject: [PATCH 4/7] fixing tests --- tests/test_API.py | 2 +- tests/test_gen_shacl.py | 14 +++++++------- tests/test_vocab.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_API.py b/tests/test_API.py index c6ed4777..60ee68f2 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -125,4 +125,4 @@ def test_inspect_bioschemas(self): "/api/inspect/validate_bioschemas/" + self.url_biotools, ) self.assertEqual(200, response.status_code) - self.assertGreater(0, len(response.get_json())) + 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__": From 3e63c86aa6fe1c958497c2493af81b49e9d70dcc Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 25 Jan 2023 10:24:37 +0100 Subject: [PATCH 5/7] update API url for profile validation --- app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index f5044840..fbaaa0e3 100644 --- a/app.py +++ b/app.py @@ -610,10 +610,14 @@ def get(self): return check_kg(kg, True) -@fc_inspect_namespace.route("/validate_bioschemas/") +@fc_inspect_namespace.route("/bioschemas_validation") class InspectBioschemas(Resource): - def get(self, url): + @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) From 9967020211795c06f0cf0ab083bb94b1f3ba9151 Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 25 Jan 2023 10:26:08 +0100 Subject: [PATCH 6/7] black --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index fbaaa0e3..9022f2ee 100644 --- a/app.py +++ b/app.py @@ -617,7 +617,7 @@ 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) From c30a6091338c1cb7b45ddecaeaa8f779e0ff3882 Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 25 Jan 2023 10:29:12 +0100 Subject: [PATCH 7/7] tests update for bioschemas --- tests/test_API.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_API.py b/tests/test_API.py index 6c364ab2..255f0d90 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -117,7 +117,7 @@ def test_inspect_ontologies(self): def test_inspect_bioschemas(self): response = self.app.get( - "/api/inspect/validate_bioschemas/" + self.url_biotools, + "/api/inspect/bioschemas_validation?url=" + self.url_biotools, ) self.assertEqual(200, response.status_code) self.assertLess(0, len(response.get_json()))