Skip to content

Commit abc9cc8

Browse files
authored
Merge pull request #526 from sgsmob/hotfix
Fix issues causing `google_health` tests to fail
2 parents bc45edb + a3289cc commit abc9cc8

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

ansible/templates/google_health-params-prod.json.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
"aws_access_key_id": "{{ delphi_aws_access_key_id }}",
1212
"aws_secret_access_key": "{{ delphi_aws_secret_access_key }}"
1313
},
14-
"bucket_name": "delphi-covidcast-indicator-output"
14+
"bucket_name": "delphi-covidcast-indicator-output",
15+
"test": false,
16+
"test_data_dir": ""
1517
}

ansible/templates/google_health-params-test.json.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
"aws_access_key_id": "{{ delphi_aws_access_key_id }}",
1212
"aws_secret_access_key": "{{ delphi_aws_secret_access_key }}"
1313
},
14-
"bucket_name": "delphi-covidcast-indicator-output"
14+
"bucket_name": "delphi-covidcast-indicator-output",
15+
"test": true,
16+
"test_data_dir": "./test_data/{geo_res}_sample.csv"
1517
}

google_health/delphi_google_health/run.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,20 @@ def run_module():
107107
start_date=start_date, receiving_dir=export_dir)
108108
export_csv(df_msa, MSA, signal, smooth=False,
109109
start_date=start_date, receiving_dir=export_dir)
110-
# Diff exports, and make incremental versions
111-
_, common_diffs, new_files = arch_diff.diff_exports()
112110

113-
# Archive changed and new files only
114-
to_archive = [f for f, diff in common_diffs.items() if diff is not None]
115-
to_archive += new_files
116-
_, fails = arch_diff.archive_exports(to_archive)
111+
if not params["test"]:
112+
# Diff exports, and make incremental versions
113+
_, common_diffs, new_files = arch_diff.diff_exports()
114+
115+
# Archive changed and new files only
116+
to_archive = [f for f, diff in common_diffs.items() if diff is not None]
117+
to_archive += new_files
118+
_, fails = arch_diff.archive_exports(to_archive)
117119

118-
# Filter existing exports to exclude those that failed to archive
119-
succ_common_diffs = {f: diff for f, diff in common_diffs.items() if f not in fails}
120-
arch_diff.filter_exports(succ_common_diffs)
120+
# Filter existing exports to exclude those that failed to archive
121+
succ_common_diffs = {f: diff for f, diff in common_diffs.items() if f not in fails}
122+
arch_diff.filter_exports(succ_common_diffs)
121123

122-
# Report failures: someone should probably look at them
123-
for exported_file in fails:
124-
print(f"Failed to archive '{exported_file}'")
124+
# Report failures: someone should probably look at them
125+
for exported_file in fails:
126+
print(f"Failed to archive '{exported_file}'")

google_health/tests/test_run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TestRunModule:
1212

1313
def test_class(self, run_as_module, wip_signal=read_params()["wip_signal"]):
1414
"""Tests output file existence."""
15-
if wip_signal is True:
15+
if wip_signal:
1616
assert exists(join("receiving", "20200419_hrr_wip_raw_search.csv"))
1717
assert exists(join("receiving", "20200419_msa_wip_raw_search.csv"))
1818
assert exists(join("receiving", "20200419_state_wip_raw_search.csv"))
@@ -35,7 +35,7 @@ def test_class(self, run_as_module, wip_signal=read_params()["wip_signal"]):
3535

3636
def test_match_old_raw_output(self, run_as_module, wip_signal=read_params()["wip_signal"]):
3737
"""Tests that raw output files don't change over time."""
38-
if wip_signal is True:
38+
if wip_signal:
3939
files = [
4040
"20200419_hrr_wip_raw_search.csv",
4141
"20200419_msa_wip_raw_search.csv",
@@ -60,7 +60,7 @@ def test_match_old_raw_output(self, run_as_module, wip_signal=read_params()["wip
6060

6161
def test_match_old_smoothed_output(self, run_as_module, wip_signal=read_params()["wip_signal"]):
6262
"""Tests that smooth output files don't change over time."""
63-
if wip_signal is True:
63+
if wip_signal:
6464

6565
files = [
6666
"20200419_hrr_wip_smoothed_search.csv",

0 commit comments

Comments
 (0)