11
11
12
12
13
13
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
+ """
14
20
reference_dr = [date .today (), date .today ()]
15
21
params = {'date_range' : reference_dr }
16
22
n_changed = 0
@@ -23,14 +29,16 @@ def test_issue_dates():
23
29
if dr [0 ] != reference_dr [0 ]:
24
30
n_changed += 1
25
31
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.
27
34
All variants: { variants }
28
35
Date-extended variants: { variants_changed }
29
36
"""
30
37
31
38
32
39
def test_handle_wip_signal ():
33
-
40
+ """Verify that "wip_" prefixes are being applied appropriately.
41
+ """
34
42
signal_list = [sensor_signal (metric , sensor , smoother )[1 ]
35
43
for (metric , sensor , smoother ) in
36
44
product (METRICS , SENSORS , SMOOTH_TYPES )]
@@ -51,6 +59,10 @@ def test_handle_wip_signal():
51
59
assert all (not s .startswith ("wip_" ) for s in signal_names [1 :])
52
60
53
61
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
+ """
54
66
placeholder = lambda geo : pd .DataFrame (
55
67
[(date .today (),"pr" if geo == "state" else "72000" ,1 ,1 ,1 ,0 )],
56
68
columns = "time_value geo_value value stderr sample_size direction" .split ())
@@ -70,12 +82,16 @@ def test_unstable_sources():
70
82
]:
71
83
df = combine_usafacts_and_jhu ("" , geo , date_range , fetcher )
72
84
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
+
73
87
input for { geo } :
74
88
{ fetcher ('usa-facts' ,geo )}
75
89
{ fetcher ('jhu-csse' ,geo )}
76
90
77
91
output:
78
92
{ df }
93
+
94
+ expected rows: { expected_size }
79
95
"""
80
96
81
97
class MyTestCase (unittest .TestCase ):
0 commit comments