10
10
from tempfile import mkstemp , mkdtemp
11
11
from datetime import datetime
12
12
from os import close , remove
13
- from os .path import exists , join , basename
13
+ from os .path import exists , join , basename , dirname , abspath
14
14
from shutil import copyfile
15
15
from functools import partial
16
16
from json import dumps
@@ -1529,7 +1529,22 @@ def test_archive(self):
1529
1529
obs_artifacts = len (qdb .util .get_artifacts_information ([4 , 5 , 6 , 8 ]))
1530
1530
self .assertEqual (2 , obs_artifacts )
1531
1531
1532
- # now let's try to delete the prep
1532
+ # in the tests above we generated and validated archived artifacts
1533
+ # so this allows us to add tests to delete a prep-info with archived
1534
+ # artifacts. The first bottleneck to do this is that this tests will
1535
+ # actually remove files, which we will need for other tests so lets
1536
+ # make a copy and then restore them
1537
+ mfolder = dirname (dirname (abspath (__file__ )))
1538
+ mpath = join (mfolder , 'support_files' , 'test_data' )
1539
+ mp = partial (join , mpath )
1540
+ fps = [
1541
+ mp ('processed_data/1_study_1001_closed_reference_otu_table.biom' ),
1542
+ mp ('processed_data/1_study_1001_closed_reference_otu_table_Silva.biom' ),
1543
+ mp ('raw_data/1_s_G1_L001_sequences.fastq.gz' ),
1544
+ mp ('raw_data/1_s_G1_L001_sequences_barcodes.fastq.gz' )]
1545
+ for fp in fps :
1546
+ copyfile (fp , f'{ fp } .bk' )
1547
+
1533
1548
PT = qdb .metadata_template .prep_template .PrepTemplate
1534
1549
QEE = qdb .exceptions .QiitaDBExecutionError
1535
1550
pt = A (1 ).prep_templates [0 ]
@@ -1549,8 +1564,11 @@ def test_archive(self):
1549
1564
for aid in [3 , 2 , 1 ]:
1550
1565
A .delete (aid )
1551
1566
1552
- PT .delete (1 )
1567
+ PT .delete (pt . id )
1553
1568
1569
+ # bringing back the filepaths
1570
+ for fp in fps :
1571
+ copyfile (f'{ fp } .bk' , fp )
1554
1572
1555
1573
if __name__ == '__main__' :
1556
1574
main ()
0 commit comments