MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_download_url

Method test_download_url

tests/test_utils.py:195–215  ·  view source on GitHub ↗

Download a sample TIFF and validate hash handling. Raises: RuntimeError: When the downloaded file's hash does not match.

(self)

Source from the content-addressed store, hash-verified

193 """Exercise ``download_url`` success and hash-mismatch paths."""
194
195 def test_download_url(self):
196 """Download a sample TIFF and validate hash handling.
197
198 Raises:
199 RuntimeError: When the downloaded file's hash does not match.
200 """
201 with tempfile.TemporaryDirectory() as tempdir:
202 with skip_if_downloading_fails():
203 download_url(
204 url=SAMPLE_TIFF,
205 filepath=os.path.join(tempdir, "model.tiff"),
206 hash_val=SAMPLE_TIFF_HASH,
207 hash_type=SAMPLE_TIFF_HASH_TYPE,
208 )
209 with self.assertRaises(RuntimeError):
210 download_url(
211 url=SAMPLE_TIFF,
212 filepath=os.path.join(tempdir, "model_bad.tiff"),
213 hash_val="0" * 64,
214 hash_type=SAMPLE_TIFF_HASH_TYPE,
215 )
216
217
218def test_pretrained_networks(network, input_param, device):

Callers

nothing calls this directly

Calls 2

download_urlFunction · 0.90

Tested by

no test coverage detected