From d7ec93c119f80a0036f0e28e841550ccd39ee083 Mon Sep 17 00:00:00 2001 From: francescalb Date: Mon, 12 Dec 2022 14:00:27 +0100 Subject: [PATCH 1/3] Added fix for adding annotations that are not strings in ontodoc Furthermore, reenabled test for ontodoc. This is still aminimal test, but I think can be gradually expanded. Lastlt - because a new altLabel was added in the testontology, it was revieled that the same entity is returned twice in by get_by_label_all in test_prefix. Issue #511 was made bacause of this. --- ontopy/ontodoc.py | 3 ++- tests/ontopy_tests/test_prefix.py | 2 +- tests/testonto/models.ttl | 3 ++- tests/tools/test_ontodoc.py | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ontopy/ontodoc.py b/ontopy/ontodoc.py index e028ac9eb..0d9d226fa 100644 --- a/ontopy/ontodoc.py +++ b/ontopy/ontodoc.py @@ -288,7 +288,8 @@ def itemdoc( annotations.keys(), key=lambda key: order.get(key, key) ): for value in annotations[key]: - if self.url_regex.match(value): + value = str(value) + if self.url_regex.match(str(value)): doc.append( annotation_style.format( key=key, value=asstring(value, link_style) diff --git a/tests/ontopy_tests/test_prefix.py b/tests/ontopy_tests/test_prefix.py index 71b8b3029..a2d8e713d 100644 --- a/tests/ontopy_tests/test_prefix.py +++ b/tests/ontopy_tests/test_prefix.py @@ -9,7 +9,7 @@ def test_prefix(testonto: "Ontology", emmo: "Ontology") -> None: """Test prefix in ontology""" - assert len(testonto.get_by_label_all("*")) == 2 + assert len(testonto.get_by_label_all("*")) == 3 assert testonto.get_by_label_all("*", prefix="testonto") == [ testonto.TestClass ] diff --git a/tests/testonto/models.ttl b/tests/testonto/models.ttl index 18c20a890..ac6670fcc 100644 --- a/tests/testonto/models.ttl +++ b/tests/testonto/models.ttl @@ -18,4 +18,5 @@ skos:altLabel rdf:type owl:AnnotationProperty . :testclass rdf:type owl:Class ; rdfs:subClassOf owl:Thing ; - skos:prefLabel "TestClass"@en . + skos:prefLabel "TestClass"@en ; + skos:altLabel 25517 . # Test that values given as integers as still accepted by ontodoc diff --git a/tests/tools/test_ontodoc.py b/tests/tools/test_ontodoc.py index 462d0e84e..fa570511a 100644 --- a/tests/tools/test_ontodoc.py +++ b/tests/tools/test_ontodoc.py @@ -4,7 +4,6 @@ import pytest -@pytest.mark.skip("ontodoc is tested in other ways") @pytest.mark.parametrize("tool", ["ontodoc"], indirect=True) def test_run(tool, tmpdir: Path) -> None: """Check that running `ontodoc` works.""" @@ -13,3 +12,6 @@ def test_run(tool, tmpdir: Path) -> None: ) tool.main([str(test_file), str(tmpdir / "test.md")]) + tool.main( + [str(test_file), "--format=simple-html", str(tmpdir / "test.html")] + ) From 16858f50d192056c8316877672f3d837a8d274fe Mon Sep 17 00:00:00 2001 From: "Francesca L. Bleken" <48128015+francescalb@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:58:06 +0100 Subject: [PATCH 2/3] typo --- tests/testonto/models.ttl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testonto/models.ttl b/tests/testonto/models.ttl index ac6670fcc..e5cd06cae 100644 --- a/tests/testonto/models.ttl +++ b/tests/testonto/models.ttl @@ -19,4 +19,4 @@ skos:altLabel rdf:type owl:AnnotationProperty . :testclass rdf:type owl:Class ; rdfs:subClassOf owl:Thing ; skos:prefLabel "TestClass"@en ; - skos:altLabel 25517 . # Test that values given as integers as still accepted by ontodoc + skos:altLabel 25517 . # Test that values given as integers are accepted by ontodoc From 9b7f13e2753a80e4607eab49922f584d2d25867f Mon Sep 17 00:00:00 2001 From: "Francesca L. Bleken" <48128015+francescalb@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:59:06 +0100 Subject: [PATCH 3/3] typo --- ontopy/ontodoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ontopy/ontodoc.py b/ontopy/ontodoc.py index 0d9d226fa..3092d13bc 100644 --- a/ontopy/ontodoc.py +++ b/ontopy/ontodoc.py @@ -289,7 +289,7 @@ def itemdoc( ): for value in annotations[key]: value = str(value) - if self.url_regex.match(str(value)): + if self.url_regex.match(value): doc.append( annotation_style.format( key=key, value=asstring(value, link_style)