diff --git a/tests/cds_test.py b/tests/cds_test.py index 32b6580..285a9d1 100644 --- a/tests/cds_test.py +++ b/tests/cds_test.py @@ -118,14 +118,14 @@ def test_write_faa(contig1, orf_finder): predicted_genes = orf_finder.find_genes(contig1.seq) contig_name = "contig" - output_file = "tests/tmp_file.faa" + output_file = "tests/tmp_file.faa.gz" cds.write_faa(output_file, [(contig_name, predicted_genes)]) # Check if the file was created and first seq starts # with the contig name as expected assert Path(output_file).exists() - with open(output_file, "r") as f: + with gzip.open(output_file, "rt") as f: assert f.read().startswith(f">{contig_name}") diff --git a/tests/contig_manager_test.py b/tests/contig_manager_test.py index 38aca8b..5214232 100644 --- a/tests/contig_manager_test.py +++ b/tests/contig_manager_test.py @@ -4,12 +4,13 @@ # Parses a valid FASTA file and returns a pyfastx.Fasta object. -def test_valid_fasta_file(): +def test_valid_fasta_file(tmp_path): # Arrange fasta_file = "tests/contigs.fasta" - # Act - result = contig_manager.parse_fasta_file(fasta_file) + index_file = "tests/contigs.fasta.fxi" + + result = contig_manager.parse_fasta_file(fasta_file, str(index_file)) # Assert assert isinstance(result, pyfastx.Fasta) @@ -22,7 +23,7 @@ def test_invalid_fasta_file(): # Act and Assert with pytest.raises(RuntimeError): - contig_manager.parse_fasta_file(fasta_file) + contig_manager.parse_fasta_file(fasta_file, "./index.fxi") # The function returns a tuple containing two dictionaries. diff --git a/tests/diamonds_test.py b/tests/diamonds_test.py index eda2975..8d628e2 100644 --- a/tests/diamonds_test.py +++ b/tests/diamonds_test.py @@ -155,7 +155,7 @@ def __init__(self, returncode): # Simulating successful run of diamond command if ( args[0] - == "diamond blastp --outfmt 6 --max-target-seqs 1 --query test.faa -o output.txt --threads 1 --db db --query-cover 80 --subject-cover 80 --id 30 --evalue 1e-05 --block-size 2 2> log.txt" + == "diamond blastp --outfmt 6 --max-target-seqs 1 --query test.faa -o output.txt --threads 1 --db db --compress 1 --query-cover 80 --subject-cover 80 --id 30 --evalue 1e-05 --block-size 2 2> log.txt" ): return CompletedProcess(0) diff --git a/tests/main_binette_test.py b/tests/main_binette_test.py index 0b2aba7..c519693 100644 --- a/tests/main_binette_test.py +++ b/tests/main_binette_test.py @@ -136,6 +136,7 @@ def test_manage_protein_alignement_resume(tmp_path): contig_to_kegg_counter, contig_to_genes = manage_protein_alignement( faa_file=Path(faa_file), contigs_fasta=Path("contigs_fasta"), + temporary_dir=Path(tmp_path), contig_to_length=contig_to_length, contigs_in_bins=set(), diamond_result_file=Path("diamond_result_file"), @@ -179,6 +180,7 @@ def test_manage_protein_alignement_not_resume(tmpdir, tmp_path): contig_to_kegg_counter, contig_to_genes = manage_protein_alignement( faa_file=Path(faa_file), contigs_fasta=Path(contigs_fasta), + temporary_dir=Path(tmp_path), contig_to_length=contig_to_length, contigs_in_bins=set(), diamond_result_file=Path(diamond_result_file), @@ -208,7 +210,7 @@ def test_parse_input_files_with_contig2bin_tables(tmp_path): # Call the function and capture the return values original_bins, contigs_in_bins, contig_to_length = parse_input_files( - None, [bin_set1, bin_set2], fasta_file + None, [bin_set1, bin_set2], fasta_file, tmp_path ) # # Perform assertions on the returned values @@ -230,7 +232,7 @@ def test_parse_input_files_with_contig2bin_tables_with_unknown_contig(tmp_path): fasta_file.write_text(fasta_file_content) with pytest.raises(ValueError): - parse_input_files(None, [bin_set3], fasta_file) + parse_input_files(None, [bin_set3], fasta_file, tmp_path) def test_parse_input_files_bin_dirs(create_temp_bin_directories, tmp_path): @@ -247,7 +249,7 @@ def test_parse_input_files_bin_dirs(create_temp_bin_directories, tmp_path): # Call the function and capture the return values original_bins, contigs_in_bins, contig_to_length = parse_input_files( - bin_dirs, contig2bin_tables, fasta_file + bin_dirs, contig2bin_tables, fasta_file, temporary_dir=tmp_path ) # # Perform assertions on the returned values @@ -384,6 +386,7 @@ def test_manage_protein_alignment_no_resume(tmp_path): contig_to_kegg_counter, contig_to_genes = manage_protein_alignement( faa_file, contigs_fasta, + tmp_path, contig_to_length, contigs_in_bins, diamond_result_file, @@ -395,7 +398,7 @@ def test_manage_protein_alignment_no_resume(tmp_path): ) # Assertions to check if functions were called - mock_parse_fasta_file.assert_called_once_with(contigs_fasta.as_posix()) + mock_parse_fasta_file.assert_called_once() mock_predict.assert_called_once() mock_diamond_get_contig_to_kegg_id.assert_called_once() mock_diamond_run.assert_called_once_with(