Skip to content

Commit 4867b3e

Browse files
test: update unit tests accordingly to changes to improve the client API
1 parent d5f0b5f commit 4867b3e

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

tests/test_client.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22

33
import pytest
4+
import ontograph.client as client_module
45

56
from ontograph.client import ClientCatalog, ClientOntology
67
from ontograph.models import Ontology, TermList
@@ -117,7 +118,7 @@ def test_get_download_url_and_formats(client_catalog):
117118

118119
def test_client_ontology_load_from_file(client_ontology, dummy_ontology_path):
119120
# Should load ontology from file and initialize queries
120-
ontology = client_ontology.load(source=str(dummy_ontology_path))
121+
client_ontology.load(source=str(dummy_ontology_path))
121122
# The new load method does not return ontology, so check internal state
122123
assert isinstance(client_ontology._ontology, Ontology)
123124
# Should be able to access root term
@@ -187,3 +188,43 @@ def test_client_ontology_introspection_methods(
187188
assert isinstance(path, list)
188189
trajectories = client_ontology.get_trajectories_from_root('D')
189190
assert isinstance(trajectories, list)
191+
192+
193+
def test_client_catalog_downloader_string_uses_backend(tmp_path, monkeypatch):
194+
class DummyDownloader:
195+
pass
196+
197+
calls = {}
198+
199+
def fake_get_default(cache_dir, *, backend=None):
200+
calls['cache_dir'] = cache_dir
201+
calls['backend'] = backend
202+
return DummyDownloader()
203+
204+
monkeypatch.setattr(
205+
client_module, 'get_default_downloader', fake_get_default
206+
)
207+
208+
client = ClientCatalog(cache_dir=tmp_path, downloader='download_manager')
209+
assert isinstance(client._downloader, DummyDownloader)
210+
assert calls['backend'] == 'download_manager'
211+
212+
213+
def test_client_ontology_downloader_string_uses_backend(tmp_path, monkeypatch):
214+
class DummyDownloader:
215+
pass
216+
217+
calls = {}
218+
219+
def fake_get_default(cache_dir, *, backend=None):
220+
calls['cache_dir'] = cache_dir
221+
calls['backend'] = backend
222+
return DummyDownloader()
223+
224+
monkeypatch.setattr(
225+
client_module, 'get_default_downloader', fake_get_default
226+
)
227+
228+
client = ClientOntology(cache_dir=tmp_path, downloader='pooch')
229+
assert isinstance(client._downloader, DummyDownloader)
230+
assert calls['backend'] == 'pooch'

0 commit comments

Comments
 (0)