Skip to content

Commit add088a

Browse files
committed
fix test
1 parent 959fcbc commit add088a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

qiita_db/test/test_artifact.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tempfile import mkstemp, mkdtemp
1111
from datetime import datetime
1212
from os import close, remove
13-
from os.path import exists, join, basename
13+
from os.path import exists, join, basename, dirname, abspath
1414
from shutil import copyfile
1515
from functools import partial
1616
from 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}.bk')
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}.bk', fp)
15541572

15551573
if __name__ == '__main__':
15561574
main()

0 commit comments

Comments
 (0)