Skip to content

Commit 8f1e70f

Browse files
committed
Add combo test
1 parent efde789 commit 8f1e70f

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

combo_cases_and_deaths/tests/receiving/.gitkeep

Whitespace-only changes.

combo_cases_and_deaths/tests/test_run.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""Tests for running combo cases and deaths indicator."""
22
from datetime import date
33
from itertools import product
4+
import os
45
import unittest
56
from unittest.mock import patch, call
67
import pandas as pd
78
import numpy as np
89

910
from delphi_combo_cases_and_deaths.run import (
10-
extend_raw_date_range, get_updated_dates,
11+
run_module,
12+
extend_raw_date_range,
13+
get_updated_dates,
1114
sensor_signal,
1215
combine_usafacts_and_jhu,
1316
compute_special_geo_dfs,
@@ -244,6 +247,50 @@ def test_no_nation_jhu(mock_covidcast_signal):
244247
"sample_size": [None]},)
245248
)
246249

250+
@patch("delphi_combo_cases_and_deaths.run.combine_usafacts_and_jhu")
251+
def test_output_files(mock_combine):
252+
params = {
253+
"common": {
254+
"export_dir": "./receiving"
255+
},
256+
"indicator": {
257+
"export_start_date": [2020, 4, 1],
258+
"source":"indicator-combination",
259+
"wip_signal": ""
260+
}
261+
}
262+
mock_combine.return_value = pd.DataFrame(
263+
{
264+
"geo_id": ["01000"],
265+
"val": [10],
266+
"timestamp": [pd.to_datetime("2021-01-04")],
267+
"issue": [pd.to_datetime("2021-01-04")],
268+
"se": 0,
269+
"sample_size": 0
270+
},
271+
index=[1]
272+
)
273+
run_module(params)
274+
csv_files = [f for f in os.listdir("receiving") if f.endswith(".csv")]
275+
dates = ["20210104"]
276+
geos = ["county", "hrr", "msa", "state", "hhs", "nation"]
277+
278+
# enumerate metric names.
279+
metrics = []
280+
for event, span, stat in product(["deaths", "confirmed"],
281+
["cumulative", "incidence"],
282+
["num", "prop"]):
283+
metrics.append("_".join([event, span, stat]))
284+
metrics.append("_".join([event, "7dav", span, stat]))
285+
286+
expected_files = []
287+
for date in dates:
288+
for geo in geos:
289+
for metric in metrics:
290+
if "7dav" in metric and "cumulative" in metric:
291+
continue
292+
expected_files += [date + "_" + geo + "_" + metric + ".csv"]
293+
assert set(csv_files) == set(expected_files)
247294

248295
if __name__ == '__main__':
249296
unittest.main()

0 commit comments

Comments
 (0)