Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 14, 2023
1 parent 1ca7d8f commit 01851a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/curies/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def _ensure_graph(
) -> "rdflib.Graph":
import rdflib

if isinstance(graph, rdflib.Graph):
return graph
if not isinstance(graph, rdflib.Graph):
_temp_graph = rdflib.Graph()
_temp_graph.parse(source=graph, format=format)
graph = _temp_graph

rv = rdflib.Graph()
rv.parse(source=graph, format=format)
return rv
return graph


def _yield_uris(*, graph: "rdflib.Graph") -> Iterable[str]:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def test_simple(self):
uris = [f"http://ran.dom/{i:03}" for i in range(30)]
uris.append("http://purl.obolibrary.org/obo/GO_0001234")

converter = discover(self.converter, uris, cutoff=3)
converter = discover(uris, cutoff=3, converter=self.converter)
self.assertEqual([Record(prefix="ns1", uri_prefix="http://ran.dom/")], converter.records)
self.assertEqual("ns1:001", converter.compress("http://ran.dom/001"))
self.assertIsNone(
converter.compress("http://purl.obolibrary.org/obo/GO_0001234"),
msg="discovered converter should not inherit reference converter's definitions",
)

converter = discover(self.converter, uris, cutoff=50)
converter = discover(uris, cutoff=50, converter=self.converter)
self.assertEqual([], converter.records)
self.assertIsNone(
converter.compress("http://ran.dom/001"),
Expand All @@ -64,7 +64,7 @@ def test_rdflib(self):
)
)

converter = discover_from_rdf(self.converter, graph)
converter = discover_from_rdf(graph, converter=self.converter)
self.assertEqual([Record(prefix="ns1", uri_prefix="http://ran.dom/")], converter.records)
self.assertEqual("ns1:001", converter.compress("http://ran.dom/001"))
self.assertIsNone(
Expand All @@ -76,7 +76,6 @@ def test_rdflib(self):
def test_remote(self):
"""Test parsing AEON."""
converter = discover_from_rdf(
converter=Converter([]),
graph="https://raw.githubusercontent.com/tibonto/aeon/main/aeon.owl",
format="xml",
)
Expand Down

0 comments on commit 01851a1

Please sign in to comment.