-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
35 additions
and
21 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
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
Empty file.
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 |
---|---|---|
@@ -1,30 +1,44 @@ | ||
import pytest | ||
|
||
from cg.constants.constants import MicrosaltQC | ||
from cg.meta.workflow.microsalt.utils import is_total_reads_above_failure_threshold | ||
|
||
TARGET_READS_FAIL_THRESHOLD = MicrosaltQC.TARGET_READS_FAIL_THRESHOLD | ||
|
||
test_cases = [ | ||
(TARGET_READS_FAIL_THRESHOLD * 100, 100, False, "sufficient_reads"), | ||
(TARGET_READS_FAIL_THRESHOLD * 100 - 1, 100, True, "just_below_threshold"), | ||
(0, 100, True, "edge_case_no_reads"), | ||
(TARGET_READS_FAIL_THRESHOLD * 100, 0, False, "edge_case_no_target_reads"), | ||
] | ||
def test_sample_total_reads_passing(): | ||
# GIVEN a sample with sufficient reads | ||
sample_reads = 100 | ||
target_reads = 100 | ||
|
||
# WHEN checking if the sample has sufficient reads | ||
passes_reads_threshold = is_total_reads_above_failure_threshold( | ||
sample_reads=sample_reads, target_reads=target_reads | ||
) | ||
|
||
# THEN it passes | ||
assert passes_reads_threshold | ||
|
||
|
||
def test_sample_total_reads_failing(): | ||
# GIVEN a sample with insufficient reads | ||
sample_reads = 50 | ||
target_reads = 100 | ||
|
||
# WHEN checking if the sample has sufficient reads | ||
passes_reads_threshold = is_total_reads_above_failure_threshold( | ||
sample_reads=sample_reads, target_reads=target_reads | ||
) | ||
|
||
# THEN it fails | ||
assert not passes_reads_threshold | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"sample_reads, target_reads, expected_result, test_id", test_cases, ids=lambda x: x[-1] | ||
) | ||
def test_is_total_reads_above_failure_threshold( | ||
sample_reads, target_reads, expected_result, test_id | ||
): | ||
# GIVEN a sample with a number of reads and a target number of reads | ||
def test_sample_total_reads_failing_without_reads(): | ||
# GIVEN a sample without reads | ||
sample_reads = 0 | ||
target_reads = 100 | ||
|
||
# WHEN checking if the sample has sufficient reads | ||
result = is_total_reads_above_failure_threshold( | ||
passes_reads_threshold = is_total_reads_above_failure_threshold( | ||
sample_reads=sample_reads, target_reads=target_reads | ||
) | ||
|
||
# THEN the result should be as expected | ||
assert result == expected_result, f"Test failed for {test_id}" | ||
# THEN it fails | ||
assert not passes_reads_threshold |