File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,6 +184,32 @@ def skip_if_downloading_fails():
184184 raise rt_e
185185
186186
187+ SAMPLE_TIFF = (
188+ https :// huggingface .co / datasets / MONAI / testing_data / resolve / main / CMU - 1. tiff
189+ )
190+
191+ SAMPLE_TIFF_HASH = "73a7e89bc15576587c3d68e55d9bf92f09690280166240b48ff4b48230b13bcd"
192+ SAMPLE_TIFF_HASH_TYPE = "sha256"
193+
194+ def test_download_url ():
195+ with tempfile .TemporaryDirectory () as tempdir :
196+ # successful download with correct hash
197+ download_url (
198+ url = SAMPLE_TIFF ,
199+ filepath = os .path .join (tempdir , "model.tiff" ),
200+ hash_val = SAMPLE_TIFF_HASH ,
201+ hash_type = SAMPLE_TIFF_HASH_TYPE ,
202+ )
203+
204+ # fails with wrong hash
205+ with self .assertRaises (RuntimeError ):
206+ download_url (
207+ url = SAMPLE_TIFF ,
208+ filepath = os .path .join (tempdir , "model_bad.tiff" ),
209+ hash_val = "wrong_hash" ,
210+ hash_type = SAMPLE_TIFF_HASH_TYPE ,
211+ )
212+
187213def test_pretrained_networks (network , input_param , device ):
188214 with skip_if_downloading_fails ():
189215 return network (** input_param ).to (device )
You can’t perform that action at this time.
0 commit comments