Skip to content

Commit

Permalink
add unit test for parsing tab-delimited priorities file
Browse files Browse the repository at this point in the history
add unit test for parsing tab-delimited priorities file, where column 1  has spaces in the values.  Thanks to @huddlej for providing this.
  • Loading branch information
tomkinsc committed Feb 12, 2021
1 parent 8ce21a4 commit 190ae73
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def mock_run_shell_command(mocker):
mocker.patch("augur.filter.run_shell_command")


@pytest.fixture
def mock_priorities_file_valid_with_spaces_and_tabs(mocker):
mocker.patch(
"builtins.open", mocker.mock_open(read_data="strain 1\t5\nstrain 2\t6\nstrain 3\t8\n")
)

class TestFilter:
def test_read_vcf_compressed(self):
seq_keep, all_seq = augur.filter.read_vcf(
Expand Down Expand Up @@ -89,6 +95,14 @@ def test_read_priority_scores_malformed(self, mock_priorities_file_malformed):
# builtins.open is stubbed, but we need a valid file to satisfy the existence check
augur.filter.read_priority_scores("tests/builds/tb/data/lee_2015.vcf")

def test_read_priority_scores_valid_with_spaces_and_tabs(self, mock_priorities_file_valid_with_spaces_and_tabs):
# builtins.open is stubbed, but we need a valid file to satisfy the existence check
priorities = augur.filter.read_priority_scores(
"tests/builds/tb/data/lee_2015.vcf"
)

assert priorities == {"strain 1": 5, "strain 2": 6, "strain 3": 8}

def test_read_priority_scores_does_not_exist(self):
with pytest.raises(FileNotFoundError):
augur.filter.read_priority_scores("/does/not/exist.txt")
Expand Down

0 comments on commit 190ae73

Please sign in to comment.