@@ -45,19 +45,85 @@ def tearDown(self):
45
45
46
46
def test_covidcast (self ):
47
47
"""Test that the covidcast endpoint returns expected data."""
48
-
48
+ self .maxDiff = None
49
+
49
50
# insert dummy data
50
51
self .cur .execute ('''
51
52
insert into covidcast values
52
53
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
53
54
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0),
55
+ (0, 'src', 'sig2', 'day', 'county', 20200414, '01234',
56
+ 123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0),
54
57
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
55
58
456, 5.5, 1.2, 10.5, 789, 0, 20200415, 1),
56
59
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
57
60
345, 6.5, 2.2, 11.5, 678, 0, 20200416, 2)
58
61
''' )
59
62
self .cnx .commit ()
60
63
64
+ # fetch data
65
+ response = Epidata .covidcast (
66
+ 'src' , ['sig' ,'sig2' ], 'day' , 'county' , 20200414 , '01234' )
67
+
68
+ # check result
69
+ self .assertEqual (response , {
70
+ 'result' : 1 ,
71
+ 'epidata' : [{
72
+ 'time_value' : 20200414 ,
73
+ 'geo_value' : '01234' ,
74
+ 'value' : 6.5 ,
75
+ 'stderr' : 2.2 ,
76
+ 'sample_size' : 11.5 ,
77
+ 'direction' : 0 ,
78
+ 'issue' : 20200416 ,
79
+ 'lag' : 2 ,
80
+ 'signal' : 'sig' ,
81
+ },{
82
+ 'time_value' : 20200414 ,
83
+ 'geo_value' : '01234' ,
84
+ 'value' : 1.5 ,
85
+ 'stderr' : 2.5 ,
86
+ 'sample_size' : 3.5 ,
87
+ 'direction' : 4 ,
88
+ 'issue' : 20200414 ,
89
+ 'lag' : 0 ,
90
+ 'signal' : 'sig2' ,
91
+ }],
92
+ 'message' : 'success' ,
93
+ })
94
+
95
+ # fetch data
96
+ response = Epidata .covidcast (
97
+ 'src' , ['sig' ,'sig2' ], 'day' , 'county' , 20200414 , '01234' , format = 'tree' )
98
+
99
+ # check result
100
+ self .assertEqual (response , {
101
+ 'result' : 1 ,
102
+ 'epidata' : [{
103
+ 'sig' : [{
104
+ 'time_value' : 20200414 ,
105
+ 'geo_value' : '01234' ,
106
+ 'value' : 6.5 ,
107
+ 'stderr' : 2.2 ,
108
+ 'sample_size' : 11.5 ,
109
+ 'direction' : 0 ,
110
+ 'issue' : 20200416 ,
111
+ 'lag' : 2 ,
112
+ }],
113
+ 'sig2' : [{
114
+ 'time_value' : 20200414 ,
115
+ 'geo_value' : '01234' ,
116
+ 'value' : 1.5 ,
117
+ 'stderr' : 2.5 ,
118
+ 'sample_size' : 3.5 ,
119
+ 'direction' : 4 ,
120
+ 'issue' : 20200414 ,
121
+ 'lag' : 0 ,
122
+ }],
123
+ }],
124
+ 'message' : 'success' ,
125
+ })
126
+
61
127
# fetch data, without specifying issue or lag
62
128
response_1 = Epidata .covidcast (
63
129
'src' , 'sig' , 'day' , 'county' , 20200414 , '01234' )
@@ -73,7 +139,8 @@ def test_covidcast(self):
73
139
'sample_size' : 11.5 ,
74
140
'direction' : 0 ,
75
141
'issue' : 20200416 ,
76
- 'lag' : 2
142
+ 'lag' : 2 ,
143
+ 'signal' : 'sig' ,
77
144
}],
78
145
'message' : 'success' ,
79
146
})
@@ -94,7 +161,8 @@ def test_covidcast(self):
94
161
'sample_size' : 10.5 ,
95
162
'direction' : 0 ,
96
163
'issue' : 20200415 ,
97
- 'lag' : 1
164
+ 'lag' : 1 ,
165
+ 'signal' : 'sig' ,
98
166
}],
99
167
'message' : 'success' ,
100
168
})
@@ -115,7 +183,8 @@ def test_covidcast(self):
115
183
'sample_size' : 3.5 ,
116
184
'direction' : 4 ,
117
185
'issue' : 20200414 ,
118
- 'lag' : 0
186
+ 'lag' : 0 ,
187
+ 'signal' : 'sig' ,
119
188
}, {
120
189
'time_value' : 20200414 ,
121
190
'geo_value' : '01234' ,
@@ -124,7 +193,8 @@ def test_covidcast(self):
124
193
'sample_size' : 10.5 ,
125
194
'direction' : 0 ,
126
195
'issue' : 20200415 ,
127
- 'lag' : 1
196
+ 'lag' : 1 ,
197
+ 'signal' : 'sig' ,
128
198
}],
129
199
'message' : 'success' ,
130
200
})
@@ -145,7 +215,8 @@ def test_covidcast(self):
145
215
'sample_size' : 11.5 ,
146
216
'direction' : 0 ,
147
217
'issue' : 20200416 ,
148
- 'lag' : 2
218
+ 'lag' : 2 ,
219
+ 'signal' : 'sig' ,
149
220
}],
150
221
'message' : 'success' ,
151
222
})
@@ -189,7 +260,7 @@ def test_covidcast_meta(self):
189
260
'last_update' : 345 ,
190
261
'max_issue' : 20200416 ,
191
262
'min_lag' : 1 ,
192
- 'max_lag' : 2
263
+ 'max_lag' : 2 ,
193
264
}],
194
265
'message' : 'success' ,
195
266
})
0 commit comments