File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,28 @@ def test_download_data__table_row():
365
365
assert os .path .exists (f'{ downloaddir } /data/file.txt' )
366
366
367
367
368
+ def test_download_data__exclude_rows_with_errors ():
369
+ with tempfile .TemporaryDirectory () as tmpdir :
370
+ datadir = f'{ tmpdir } /data'
371
+ downloaddir = f'{ tmpdir } /download'
372
+ os .makedirs (datadir , exist_ok = True )
373
+ with open (f'{ datadir } /file.txt' , 'w' ) as fp :
374
+ fp .write ('data' )
375
+ # include both a file and a directory
376
+ tab = Table ({
377
+ 'sciserver' : [f'{ tmpdir } /data/file.txt' , f'{ tmpdir } /data' ],
378
+ 'error_message' : ['' , 'Error' ]
379
+ })
380
+ # The patch is to avoid the test that we are on sciserver
381
+ with patch ('os.path.exists' ) as exists :
382
+ exists .return_value = True
383
+ Heasarc .download_data (tab , host = "sciserver" , location = downloaddir )
384
+ assert os .path .exists (f'{ downloaddir } /file.txt' )
385
+ # data/ should be excluded because it has an error
386
+ assert not os .path .exists (f'{ downloaddir } /data' )
387
+ assert not os .path .exists (f'{ downloaddir } /data/file.txt' )
388
+
389
+
368
390
# S3 mock tests
369
391
s3_bucket = "nasa-heasarc"
370
392
s3_key1 = "some/location/file1.txt"
You can’t perform that action at this time.
0 commit comments