Skip to content

Commit

Permalink
Added test cases for replace_cgmlst_errors function
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkc committed Sep 3, 2024
1 parent 2f4f2ca commit 915c9e7
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/parse/test_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Test typing method parsing."""

import pytest
from prp.parse.typing import replace_cgmlst_errors
from prp.models.typing import ChewbbacaErrors

# build test cases for handeling chewbacca allele caller errors and annotations
# reference, https://chewbbaca.readthedocs.io/en/latest/user/modules/AlleleCall.html
cgmlst_test_base = [("1", 1), ("99", 99)] # normal alllale calls
cgmlst_test_include_novel = [("INF-1", 1), ("INF-99", 99)] # inferred alleles
cgmlst_test_not_include_novel = [
("INF-1", "INF-1"),
("INF-99", "INF-99"),
] # inferred alleles
cgmlst_test_replace_errors = [
(err.value, None) for err in ChewbbacaErrors
] # errors to strip
cgmlst_test_not_replace_errors = [
(err.value, err.value) for err in ChewbbacaErrors
] # errors to strip


@pytest.mark.parametrize(
"called_allele,expected",
[
*cgmlst_test_base,
*cgmlst_test_not_include_novel,
*cgmlst_test_not_replace_errors,
],
)
def test_replace_cgmlst_errors_not_include_novel(called_allele, expected):
"""Test function that process Chewbbaca allele calling."""

assert (
replace_cgmlst_errors(
called_allele, include_novel_alleles=False, correct_alleles=False
)
== expected
)


@pytest.mark.parametrize(
"called_allele,expected",
[*cgmlst_test_base, *cgmlst_test_include_novel, *cgmlst_test_not_replace_errors],
)
def test_replace_cgmlst_errors_include_novel(called_allele, expected):
"""Test function that process Chewbbaca allele calling."""

assert (
replace_cgmlst_errors(
called_allele, include_novel_alleles=True, correct_alleles=False
)
== expected
)


@pytest.mark.parametrize(
"called_allele,expected",
[*cgmlst_test_base, *cgmlst_test_include_novel, *cgmlst_test_replace_errors],
)
def test_replace_cgmlst_errors_include_novel_and_correct_allels(
called_allele, expected
):
"""Test function that process Chewbbaca allele calling."""

assert (
replace_cgmlst_errors(
called_allele, include_novel_alleles=True, correct_alleles=True
)
== expected
)

0 comments on commit 915c9e7

Please sign in to comment.