Skip to content

Commit 6da3598

Browse files
committed
Add docstrings to test functions
1 parent 9e46bc2 commit 6da3598

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

combo_cases_and_deaths/tests/test_run.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212

1313
def test_issue_dates():
14+
"""The smoothed value for a particular date is computed from the raw
15+
values for a span of dates. We want users to be able to see in the
16+
API all the raw values that went into the smoothed computation,
17+
for transparency and peer review. This means that each issue
18+
should contain more days of raw data than smoothed data.
19+
"""
1420
reference_dr = [date.today(), date.today()]
1521
params = {'date_range': reference_dr}
1622
n_changed = 0
@@ -23,14 +29,16 @@ def test_issue_dates():
2329
if dr[0] != reference_dr[0]:
2430
n_changed += 1
2531
variants_changed.append(sensor_name)
26-
assert n_changed == len(variants) / 2, f"""Raw variants should post more days than smoothed.
32+
assert n_changed == len(variants) / 2, f"""
33+
Raw variants should post more days than smoothed.
2734
All variants: {variants}
2835
Date-extended variants: {variants_changed}
2936
"""
3037

3138

3239
def test_handle_wip_signal():
33-
40+
"""Verify that "wip_" prefixes are being applied appropriately.
41+
"""
3442
signal_list = [sensor_signal(metric, sensor, smoother)[1]
3543
for (metric, sensor, smoother) in
3644
product(METRICS, SENSORS, SMOOTH_TYPES)]
@@ -51,6 +59,10 @@ def test_handle_wip_signal():
5159
assert all(not s.startswith("wip_") for s in signal_names[1:])
5260

5361
def test_unstable_sources():
62+
"""Verify that combine_usafacts_and_jhu assembles the combined data
63+
frame correctly for all cases where 0, 1, or both signals are
64+
available.
65+
"""
5466
placeholder = lambda geo: pd.DataFrame(
5567
[(date.today(),"pr" if geo == "state" else "72000",1,1,1,0)],
5668
columns="time_value geo_value value stderr sample_size direction".split())
@@ -70,12 +82,16 @@ def test_unstable_sources():
7082
]:
7183
df = combine_usafacts_and_jhu("", geo, date_range, fetcher)
7284
assert df.size == expected_size * len(COLUMN_MAPPING), f"""
85+
Wrong number of rows in combined data frame for the number of available signals.
86+
7387
input for {geo}:
7488
{fetcher('usa-facts',geo)}
7589
{fetcher('jhu-csse',geo)}
7690
7791
output:
7892
{df}
93+
94+
expected rows: {expected_size}
7995
"""
8096

8197
class MyTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)