Skip to content

Commit 00ab794

Browse files
committed
mock _url_download for exact assert
1 parent 8bf09cd commit 00ab794

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
import pytest
1+
import os
22
from pathlib import Path
3+
from typing import Optional
4+
5+
import pytest
36

47
from bioimageio.spec.shared.raw_nodes import URI
58

69

10+
def mock_download(uri: URI, output: Optional[os.PathLike] = None, pbar=None):
11+
return Path(__file__).resolve()
12+
13+
714
@pytest.mark.parametrize(
815
"src",
916
[
10-
"https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_specs/models/unet2d_nuclei_broad/rdf.yaml",
17+
"https://example.com/fake",
1118
Path(__file__),
1219
__file__,
13-
URI(
14-
"https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/example_specs/models/unet2d_nuclei_broad/rdf.yaml"
15-
),
20+
URI("https://example.com/fake"),
1621
],
1722
)
1823
def test_get_resolved_source_path(src):
1924
from bioimageio.spec.shared import get_resolved_source_path
2025

26+
import bioimageio.spec
27+
28+
bioimageio.spec.shared._resolve_source._download_url = mock_download
2129
res = get_resolved_source_path(src, root_path=Path(__file__).parent)
2230
assert isinstance(res, Path)
2331
assert res.exists()
32+
assert res == Path(__file__).resolve()

0 commit comments

Comments
 (0)