File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,3 +134,16 @@ def stmt_calls_banned(stmt: ast.stmt) -> bool:
134134def _import_kwave_inertly () -> ModuleType :
135135 """Import kwave without allowing it to install binaries"""
136136 return _import_without_calls ("kwave" , banned_calls = ["install_binaries" ])
137+
138+ def get_kwave_paths () -> list [tuple [Path , str ]]:
139+ """Get a list of paths and urls to kwave binaries.
140+
141+ Each item in the list is a pair consisting of the install of a needed binary, followed by a download url for that binary.
142+ """
143+ kwave = _import_kwave_inertly ()
144+ paths : list [tuple [str , str ]] = []
145+ for url_list in kwave .URL_DICT [kwave .PLATFORM ].values ():
146+ for url in url_list :
147+ _ , filename = url .split ("/" )[- 2 :]
148+ paths .append ((Path (kwave .BINARY_PATH ) / filename , url ))
149+ return paths
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import shutil
4+ from pathlib import Path
45from unittest .mock import MagicMock
56
67import pytest
78import requests
89
9- from openlifu .util .assets import install_asset
10+ from openlifu .util .assets import get_kwave_paths , install_asset
1011
1112
1213def test_destination_already_exists (tmp_path , mocker ):
@@ -94,3 +95,14 @@ def test_raises_error_if_no_source_provided(tmp_path):
9495 destination = tmp_path / "asset.dat"
9596 with pytest .raises (ValueError , match = "Either path_to_asset or url_to_asset must be provided." ):
9697 install_asset (destination , path_to_asset = None , url_to_asset = None )
98+
99+ def test_get_kwave_paths ():
100+ """Check that get_kwave_paths returns a nonempty list of (Path, str) pairs.
101+ This may break if kwave changes how it represents download urls and binary paths."""
102+ paths = get_kwave_paths ()
103+ assert isinstance (paths , list )
104+ assert len (paths ) > 0
105+ for p , url in paths :
106+ assert isinstance (p , Path )
107+ assert isinstance (url , str )
108+ assert len (url ) > 0
You can’t perform that action at this time.
0 commit comments