Skip to content

Commit

Permalink
Added new unittest for testing test_output directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
crosenth committed Aug 13, 2024
1 parent d2c3cab commit 3ca3884
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import unittest
import os


class TestSConsPipelineOutput(unittest.TestCase):
def test_pipeline_output(self):
output_dir = 'test_output'

output_files = [
'blast',
'lineages.csv',
'seqs.fasta',
'seq_info.csv',
'taxonomy.csv',
]

expected = {}
for date_dir in os.listdir(output_dir):
if len(date_dir) == 8 and date_dir.isnumeric():
out = f'{output_dir}/{date_dir}'
self.assertTrue(os.path.isfile(out + '/SUCCESS'))
expected.update({
f'{out}/dedup/1200bp/types': output_files,
f'{out}/dedup/1200bp/named/': output_files,
f'{out}/dedup/1200bp/named/filtered': [
'blast',
'taxonomy.csv',
'outliers.csv',
'unsorted.fasta'],
f'{out}/dedup/1200bp/named/filtered/trusted': output_files,
f'{out}/dedup/1200bp/named/filtered/types': output_files,
})

# Verify the folder structure and contents
for folder_path, contents in expected.items():
self.assertTrue(
os.path.isdir(folder_path),
f"Folder {folder_path} does not exist")
actual_contents = os.listdir(folder_path)
for expected_file in contents:
self.assertIn(
expected_file,
actual_contents,
f"{expected_file} not found in {folder_path}")
file = os.path.join(folder_path, expected_file)
self.assertTrue(os.path.isfile(file))
self.assertTrue(os.stat(file).st_size > 0) # not empty


if __name__ == '__main__':
unittest.main()

0 comments on commit 3ca3884

Please sign in to comment.