|
1 | 1 | from pathlib import Path |
2 | 2 |
|
3 | 3 | import pytest |
| 4 | +import ontograph.client as client_module |
4 | 5 |
|
5 | 6 | from ontograph.client import ClientCatalog, ClientOntology |
6 | 7 | from ontograph.models import Ontology, TermList |
@@ -117,7 +118,7 @@ def test_get_download_url_and_formats(client_catalog): |
117 | 118 |
|
118 | 119 | def test_client_ontology_load_from_file(client_ontology, dummy_ontology_path): |
119 | 120 | # 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)) |
121 | 122 | # The new load method does not return ontology, so check internal state |
122 | 123 | assert isinstance(client_ontology._ontology, Ontology) |
123 | 124 | # Should be able to access root term |
@@ -187,3 +188,43 @@ def test_client_ontology_introspection_methods( |
187 | 188 | assert isinstance(path, list) |
188 | 189 | trajectories = client_ontology.get_trajectories_from_root('D') |
189 | 190 | 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