|
5 | 5 | import pandas as pd
|
6 | 6 | from pandas.testing import assert_frame_equal
|
7 | 7 | from delphi_google_health.run import run_module, add_prefix, public_signal
|
| 8 | +from delphi_google_health.constants import SIGNALS |
8 | 9 | from delphi_utils import read_params
|
9 | 10 |
|
10 |
| -SIGNALS = ["raw_search", "smoothed_search"] |
11 |
| - |
12 | 11 |
|
13 | 12 | class TestRunModule:
|
14 |
| - def test_class(self, run_as_module): |
15 |
| - |
16 |
| - assert exists(join("receiving", "20200419_hrr_raw_search.csv")) |
17 |
| - assert exists(join("receiving", "20200419_msa_raw_search.csv")) |
18 |
| - assert exists(join("receiving", "20200419_state_raw_search.csv")) |
19 |
| - assert exists(join("receiving", "20200419_dma_raw_search.csv")) |
20 |
| - |
21 |
| - assert exists(join("receiving", "20200315_hrr_raw_search.csv")) |
22 |
| - assert exists(join("receiving", "20200315_msa_raw_search.csv")) |
23 |
| - assert exists(join("receiving", "20200315_state_raw_search.csv")) |
24 |
| - assert exists(join("receiving", "20200315_dma_raw_search.csv")) |
25 | 13 |
|
26 |
| - def test_match_old_raw_output(self, run_as_module): |
27 |
| - |
28 |
| - files = [ |
29 |
| - "20200419_hrr_raw_search.csv", |
30 |
| - "20200419_msa_raw_search.csv", |
31 |
| - "20200419_state_raw_search.csv", |
32 |
| - "20200419_dma_raw_search.csv", |
33 |
| - ] |
| 14 | + def test_class(self, run_as_module, wip_signal=read_params()["wip_signal"]): |
| 15 | + if wip_signal is True: |
| 16 | + assert exists(join("receiving", "20200419_hrr_wip_raw_search.csv")) |
| 17 | + assert exists(join("receiving", "20200419_msa_wip_raw_search.csv")) |
| 18 | + assert exists(join("receiving", "20200419_state_wip_raw_search.csv")) |
| 19 | + assert exists(join("receiving", "20200419_dma_wip_raw_search.csv")) |
| 20 | + |
| 21 | + assert exists(join("receiving", "20200315_hrr_wip_raw_search.csv")) |
| 22 | + assert exists(join("receiving", "20200315_msa_wip_raw_search.csv")) |
| 23 | + assert exists(join("receiving", "20200315_state_wip_raw_search.csv")) |
| 24 | + assert exists(join("receiving", "20200315_dma_wip_raw_search.csv")) |
| 25 | + else: |
| 26 | + assert exists(join("receiving", "20200419_hrr_raw_search.csv")) |
| 27 | + assert exists(join("receiving", "20200419_msa_raw_search.csv")) |
| 28 | + assert exists(join("receiving", "20200419_state_raw_search.csv")) |
| 29 | + assert exists(join("receiving", "20200419_dma_raw_search.csv")) |
| 30 | + |
| 31 | + assert exists(join("receiving", "20200315_hrr_raw_search.csv")) |
| 32 | + assert exists(join("receiving", "20200315_msa_raw_search.csv")) |
| 33 | + assert exists(join("receiving", "20200315_state_raw_search.csv")) |
| 34 | + assert exists(join("receiving", "20200315_dma_raw_search.csv")) |
| 35 | + |
| 36 | + def test_match_old_raw_output(self, run_as_module, wip_signal=read_params()["wip_signal"]): |
| 37 | + if wip_signal is True: |
| 38 | + files = [ |
| 39 | + "20200419_hrr_wip_raw_search.csv", |
| 40 | + "20200419_msa_wip_raw_search.csv", |
| 41 | + "20200419_state_wip_raw_search.csv", |
| 42 | + "20200419_dma_wip_raw_search.csv", |
| 43 | + ] |
| 44 | + else: |
| 45 | + files = [ |
| 46 | + "20200419_hrr_raw_search.csv", |
| 47 | + "20200419_msa_raw_search.csv", |
| 48 | + "20200419_state_raw_search.csv", |
| 49 | + "20200419_dma_raw_search.csv", |
| 50 | + ] |
34 | 51 |
|
35 | 52 | for fname in files:
|
36 | 53 | test_df = pd.read_csv(join("receiving_test", fname))
|
| 54 | + print(test_df) |
37 | 55 | new_df = pd.read_csv(join("receiving", fname))
|
| 56 | + print(new_df) |
38 | 57 |
|
39 | 58 | assert_frame_equal(test_df, new_df, check_less_precise=5)
|
40 | 59 |
|
41 |
| - def test_match_old_smoothed_output(self, run_as_module): |
42 |
| - |
43 |
| - files = [ |
44 |
| - "20200419_hrr_smoothed_search.csv", |
45 |
| - "20200419_msa_smoothed_search.csv", |
46 |
| - "20200419_state_smoothed_search.csv", |
47 |
| - "20200419_dma_smoothed_search.csv", |
48 |
| - ] |
| 60 | + def test_match_old_smoothed_output(self, run_as_module, wip_signal=read_params()["wip_signal"]): |
| 61 | + if wip_signal is True: |
| 62 | + |
| 63 | + files = [ |
| 64 | + "20200419_hrr_wip_smoothed_search.csv", |
| 65 | + "20200419_msa_wip_smoothed_search.csv", |
| 66 | + "20200419_state_wip_smoothed_search.csv", |
| 67 | + "20200419_dma_wip_smoothed_search.csv", |
| 68 | + ] |
| 69 | + else: |
| 70 | + files = [ |
| 71 | + "20200419_hrr_smoothed_search.csv", |
| 72 | + "20200419_msa_smoothed_search.csv", |
| 73 | + "20200419_state_smoothed_search.csv", |
| 74 | + "20200419_dma_smoothed_search.csv", |
| 75 | + ] |
49 | 76 |
|
50 | 77 | for fname in files:
|
51 | 78 | test_df = pd.read_csv(join("receiving_test", fname))
|
52 | 79 | new_df = pd.read_csv(join("receiving", fname))
|
53 | 80 |
|
54 | 81 | assert_frame_equal(test_df, new_df, check_less_precise=5)
|
55 |
| - |
56 |
| - def test_handle_wip_signal(self): |
57 |
| - wip_signal = read_params()["wip_signal"] |
58 |
| - assert isinstance(wip_signal, (list, bool)) or wip_signal == "", "Supply True | False or "" or [] | list()" |
59 |
| - if isinstance(wip_signal, list): |
60 |
| - assert set(wip_signal).issubset(set(SIGNALS)), "signal in params don't belong in the registry" |
61 |
| - updated_signal_names = add_prefix(SIGNALS, wip_signal, prefix='wip_') |
62 |
| - assert (len(updated_signal_names) >= len(SIGNALS)) |
|
0 commit comments