@@ -51,6 +51,8 @@ def test_uploading(self):
51
51
"""Update rows having a stale `direction` field and serve the results."""
52
52
53
53
# insert some sample data
54
+ # src, sig1, 1111:
55
+ # direction should be updated to None as there are no historical data for (src, sig1, state).
54
56
# CA 20200301:
55
57
# timeline should be x=[-2, -1, 0], y=[2, 6, 5] with direction=1
56
58
# FL 20200517:
@@ -60,31 +62,77 @@ def test_uploading(self):
60
62
# wrong) is fresh
61
63
self .cur .execute ('''
62
64
insert into covidcast values
65
+ (0, 'src', 'sig1', 'day', 'state', 20201028, '1111',
66
+ 123, 2, 0, 0, 0, -1, 20201028, 0, 1, False),
67
+ (0, 'src', 'sig1', 'day', 'state', 20201029, '1111',
68
+ 123, 6, 0, 0, 0, 0, 20201029, 0, 1, False),
69
+ (0, 'src', 'sig1', 'day', 'state', 20201030, '1111',
70
+ 123, 5, 0, 0, 0, 1, 20201030, 0, 1, False),
63
71
(0, 'src', 'sig', 'day', 'state', 20200228, 'ca',
64
- 123, 2, 0, 0, 0, NULL, 20200228, 0),
72
+ 123, 2, 0, 0, 0, NULL, 20200228, 0, 1, False ),
65
73
(0, 'src', 'sig', 'day', 'state', 20200229, 'ca',
66
- 123, 6, 0, 0, 0, NULL, 20200229, 0),
74
+ 123, 6, 0, 0, 0, NULL, 20200229, 0, 1, False ),
67
75
(0, 'src', 'sig', 'day', 'state', 20200301, 'ca',
68
- 123, 5, 0, 0, 0, NULL, 20200301, 0),
76
+ 123, 5, 0, 0, 0, NULL, 20200301, 0, 1, False ),
69
77
(0, 'src', 'sig', 'day', 'state', 20200511, 'fl',
70
- 123, 1, 0, 0, 0, NULL, 20200511, 0),
78
+ 123, 1, 0, 0, 0, NULL, 20200511, 0, 1, False ),
71
79
(0, 'src', 'sig', 'day', 'state', 20200512, 'fl',
72
- 123, 2, 0, 0, 0, NULL, 20200512, 0),
80
+ 123, 2, 0, 0, 0, NULL, 20200512, 0, 1, False ),
73
81
(0, 'src', 'sig', 'day', 'state', 20200517, 'fl',
74
- 123, 2, 0, 0, 0, NULL, 20200517, 0),
82
+ 123, 2, 0, 0, 0, NULL, 20200517, 0, 1, False ),
75
83
(0, 'src', 'sig', 'day', 'state', 20200615, 'tx',
76
- 123, 9, 0, 0, 456, NULL, 20200615, 0),
84
+ 123, 9, 0, 0, 456, NULL, 20200615, 0, 1, False ),
77
85
(0, 'src', 'sig', 'day', 'state', 20200616, 'tx',
78
- 123, 5, 0, 0, 456, NULL, 20200616, 0),
86
+ 123, 5, 0, 0, 456, NULL, 20200616, 0, 1, False ),
79
87
(0, 'src', 'sig', 'day', 'state', 20200617, 'tx',
80
- 123, 1, 0, 0, 456, 1, 20200617, 0)
88
+ 123, 1, 0, 0, 456, 1, 20200617, 0, 1, False )
81
89
''' )
82
90
self .cnx .commit ()
83
91
84
92
# update direction (only 20200417 has enough history)
85
- args = None
93
+ args = get_argument_parser (). parse_args ( '' )
86
94
main (args )
87
95
96
+ # The Quick-Fix is working
97
+ response = Epidata .covidcast (
98
+ 'src' , 'sig1' , 'day' , 'state' , '20200101-20201231' , '*' )
99
+
100
+ self .assertEqual (response , {
101
+ 'result' : 1 ,
102
+ 'epidata' : [{
103
+ 'time_value' : 20201028 ,
104
+ 'geo_value' : '1111' ,
105
+ 'value' : 2 ,
106
+ 'stderr' : 0 ,
107
+ 'sample_size' : 0 ,
108
+ 'direction' : None ,
109
+ 'issue' : 20201028 ,
110
+ 'lag' : 0
111
+ },
112
+ {
113
+ 'time_value' : 20201029 ,
114
+ 'geo_value' : '1111' ,
115
+ 'value' : 6 ,
116
+ 'stderr' : 0 ,
117
+ 'sample_size' : 0 ,
118
+ 'direction' : None ,
119
+ 'issue' : 20201029 ,
120
+ 'lag' : 0
121
+ },
122
+ {
123
+ 'time_value' : 20201030 ,
124
+ 'geo_value' : '1111' ,
125
+ 'value' : 5 ,
126
+ 'stderr' : 0 ,
127
+ 'sample_size' : 0 ,
128
+ 'direction' : None ,
129
+ 'issue' : 20201030 ,
130
+ 'lag' : 0
131
+ },
132
+ ],
133
+ 'message' : 'success' ,
134
+ })
135
+
88
136
# request data from the API
89
137
response = Epidata .covidcast (
90
138
'src' , 'sig' , 'day' , 'state' , '20200101-20201231' , '*' )
@@ -188,11 +236,11 @@ def test_uploading(self):
188
236
})
189
237
190
238
# verify secondary timestamps were updated
191
- self .cur .execute ('select timestamp2 from covidcast order by id asc' )
239
+ self .cur .execute ('select direction_updated_timestamp from covidcast order by id asc' )
192
240
timestamps = [t for (t ,) in self .cur ]
193
- for t in timestamps [:6 ]:
194
- # first 6 rows had `direction` updated
241
+ for t in timestamps [:9 ]:
242
+ # first 9 rows had `direction` updated
195
243
self .assertGreater (t , 0 )
196
- for t in timestamps [6 :]:
244
+ for t in timestamps [9 :]:
197
245
# last 3 rows were not updated
198
246
self .assertEqual (t , 456 )
0 commit comments