Skip to content

Commit

Permalink
Added fix for adding annotations that are not strings in ontodoc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
francescalb committed Dec 12, 2022
1 parent 5b38254 commit d7ec93c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ontopy/ontodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/ontopy_tests/test_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
3 changes: 2 additions & 1 deletion tests/testonto/models.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tests/tools/test_ontodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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")]
)

0 comments on commit d7ec93c

Please sign in to comment.