1010from  tempfile  import  mkstemp , mkdtemp 
1111from  datetime  import  datetime 
1212from  os  import  close , remove 
13- from  os .path  import  exists , join , basename 
13+ from  os .path  import  exists , join , basename ,  dirname ,  abspath 
1414from  shutil  import  copyfile 
1515from  functools  import  partial 
1616from  json  import  dumps 
@@ -1529,7 +1529,22 @@ def test_archive(self):
15291529        obs_artifacts  =  len (qdb .util .get_artifacts_information ([4 , 5 , 6 , 8 ]))
15301530        self .assertEqual (2 , obs_artifacts )
15311531
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 }  )
1547+ 
15331548        PT  =  qdb .metadata_template .prep_template .PrepTemplate 
15341549        QEE  =  qdb .exceptions .QiitaDBExecutionError 
15351550        pt  =  A (1 ).prep_templates [0 ]
@@ -1549,8 +1564,11 @@ def test_archive(self):
15491564        for  aid  in  [3 , 2 , 1 ]:
15501565            A .delete (aid )
15511566
1552-         PT .delete (1 )
1567+         PT .delete (pt . id )
15531568
1569+         # bringing back the filepaths 
1570+         for  fp  in  fps :
1571+             copyfile (f'{ fp }  , fp )
15541572
15551573if  __name__  ==  '__main__' :
15561574    main ()
0 commit comments