-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new unittest for testing test_output directory structure
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |