|
17 | 17 | check_plot_frequencies_time_series_with_taxa, |
18 | 18 | check_plot_frequencies_time_series_with_areas, |
19 | 19 | check_plot_frequencies_interactive_map, |
| 20 | + add_random_year, |
20 | 21 | ) |
21 | 22 |
|
22 | 23 |
|
@@ -479,7 +480,7 @@ def test_gene_cnv_frequencies_advanced_with_area_by( |
479 | 480 | ) |
480 | 481 |
|
481 | 482 |
|
482 | | -@pytest.mark.parametrize("period_by", ["year", "quarter", "month"]) |
| 483 | +@pytest.mark.parametrize("period_by", ["year", "quarter", "month", "random_year"]) |
483 | 484 | @parametrize_with_cases("fixture,api", cases=".") |
484 | 485 | def test_gene_cnv_frequencies_advanced_with_period_by( |
485 | 486 | fixture, |
@@ -711,13 +712,17 @@ def check_gene_cnv_frequencies_advanced( |
711 | 712 | if area_by is None: |
712 | 713 | area_by = random.choice(["country", "admin1_iso", "admin2_name"]) |
713 | 714 | if period_by is None: |
714 | | - period_by = random.choice(["year", "quarter", "month"]) |
| 715 | + period_by = random.choice(["year", "quarter", "month", "random_year"]) |
715 | 716 | if sample_sets is None: |
716 | 717 | all_sample_sets = api.sample_sets()["sample_set"].to_list() |
717 | 718 | sample_sets = random.choice(all_sample_sets) |
718 | 719 | if min_cohort_size is None: |
719 | 720 | min_cohort_size = random.randint(0, 2) |
720 | 721 |
|
| 722 | + if period_by == "random_year": |
| 723 | + # Add a random_year column to the sample metadata, if there isn't already. |
| 724 | + api = add_random_year(api=api) |
| 725 | + |
721 | 726 | # Run function under test. |
722 | 727 | ds = api.gene_cnv_frequencies_advanced( |
723 | 728 | region=region, |
@@ -816,6 +821,8 @@ def check_gene_cnv_frequencies_advanced( |
816 | 821 | expected_freqstr = "M" |
817 | 822 | elif period_by == "quarter": |
818 | 823 | expected_freqstr = "Q-DEC" |
| 824 | + elif period_by == "random_year": |
| 825 | + expected_freqstr = "Y-DEC" |
819 | 826 | else: |
820 | 827 | assert False, "not implemented" |
821 | 828 | for p in period_values: |
|
0 commit comments