Skip to content

Commit

Permalink
Symmetrically test relative dates for --min-date/--max-date
Browse files Browse the repository at this point in the history
Previously, some tests for --max-date were not done for --min-date and vice-versa.
Added tests and re-ordered so that similar tests are adjacent.
  • Loading branch information
victorlin committed Apr 11, 2022
1 parent a2ac8e5 commit 0dbb930
Showing 1 changed file with 58 additions and 20 deletions.
78 changes: 58 additions & 20 deletions tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,29 +274,29 @@ def test_filter_date_formats(self, tmpdir, fasta_fn, argparser):
"argparse_params, metadata_rows, output_sorted_expected",
[
(
"--min-date 1M",
"--min-date 1D",
(
("SEQ_1","2020-01-25"),
("SEQ_2","2020-02-25"),
("SEQ_1","2020-03-23"),
("SEQ_2","2020-03-24"),
("SEQ_3","2020-03-25"),
),
["SEQ_2", "SEQ_3"],
),
(
"--min-date P1M",
"--max-date 1D",
(
("SEQ_1","2020-01-25"),
("SEQ_2","2020-02-25"),
("SEQ_1","2020-03-23"),
("SEQ_2","2020-03-24"),
("SEQ_3","2020-03-25"),
),
["SEQ_2", "SEQ_3"],
["SEQ_1", "SEQ_2"],
),
(
"--min-date 2Y",
"--min-date 1M",
(
("SEQ_1","2017-03-25"),
("SEQ_2","2018-03-25"),
("SEQ_3","2019-03-25"),
("SEQ_1","2020-01-25"),
("SEQ_2","2020-02-25"),
("SEQ_3","2020-03-25"),
),
["SEQ_2", "SEQ_3"],
),
Expand All @@ -310,13 +310,13 @@ def test_filter_date_formats(self, tmpdir, fasta_fn, argparser):
["SEQ_2", "SEQ_3"],
),
(
"--min-date 1Y2W5D",
"--max-date 4W",
(
("SEQ_1","2019-03-05"),
("SEQ_2","2019-03-06"),
("SEQ_3","2019-03-07"),
("SEQ_1","2020-02-25"),
("SEQ_2","2020-02-26"),
("SEQ_3","2020-03-25"),
),
["SEQ_2", "SEQ_3"],
["SEQ_1", "SEQ_2"],
),
(
"--max-date 1M",
Expand All @@ -327,6 +327,15 @@ def test_filter_date_formats(self, tmpdir, fasta_fn, argparser):
),
["SEQ_1", "SEQ_2"],
),
(
"--min-date P1M",
(
("SEQ_1","2020-01-25"),
("SEQ_2","2020-02-25"),
("SEQ_3","2020-03-25"),
),
["SEQ_2", "SEQ_3"],
),
(
"--max-date P1M",
(
Expand All @@ -337,11 +346,38 @@ def test_filter_date_formats(self, tmpdir, fasta_fn, argparser):
["SEQ_1", "SEQ_2"],
),
(
"--max-date 1D",
"--min-date 2Y",
(
("SEQ_1","2020-03-23"),
("SEQ_2","2020-03-24"),
("SEQ_3","2020-03-25"),
("SEQ_1","2017-03-25"),
("SEQ_2","2018-03-25"),
("SEQ_3","2019-03-25"),
),
["SEQ_2", "SEQ_3"],
),
(
"--max-date 2Y",
(
("SEQ_1","2017-03-25"),
("SEQ_2","2018-03-25"),
("SEQ_3","2019-03-25"),
),
["SEQ_1", "SEQ_2"],
),
(
"--min-date 1Y2W5D",
(
("SEQ_1","2019-03-05"),
("SEQ_2","2019-03-06"),
("SEQ_3","2019-03-07"),
),
["SEQ_2", "SEQ_3"],
),
(
"--max-date 1Y2W5D",
(
("SEQ_1","2019-03-05"),
("SEQ_2","2019-03-06"),
("SEQ_3","2019-03-07"),
),
["SEQ_1", "SEQ_2"],
),
Expand All @@ -362,7 +398,9 @@ def test_filter_relative_dates(self, tmpdir, argparser, argparse_params, metadat
@pytest.mark.parametrize(
"argparse_flag, argparse_value",
[
("--min-date", "3000Y"),
("--max-date", "3000Y"),
("--min-date", "invalid"),
("--max-date", "invalid"),
],
)
Expand Down

0 comments on commit 0dbb930

Please sign in to comment.