12
12
# third party
13
13
import delphi .operations .secrets as secrets
14
14
from delphi .epidata .acquisition .covidcast .covidcast_meta_cache_updater import main as update_covidcast_meta_cache
15
- from delphi .epidata .acquisition .covidcast .covidcast_row import CovidcastRow
16
- from delphi .epidata .acquisition .covidcast .test_utils import CovidcastBase
15
+ from delphi .epidata .acquisition .covidcast .test_utils import CovidcastBase , CovidcastTestRow
17
16
from delphi .epidata .client .delphi_epidata import Epidata
18
17
from delphi_utils import Nans
19
18
@@ -52,13 +51,11 @@ def test_covidcast(self):
52
51
53
52
# insert placeholder data: three issues of one signal, one issue of another
54
53
rows = [
55
- CovidcastRow .make_default_row (issue = 2020_02_02 + i , value = i , lag = i )
54
+ CovidcastTestRow .make_default_row (issue = 2020_02_02 + i , value = i , lag = i )
56
55
for i in range (3 )
57
56
]
58
57
row_latest_issue = rows [- 1 ]
59
- rows .append (
60
- CovidcastRow .make_default_row (signal = "sig2" )
61
- )
58
+ rows .append (CovidcastTestRow .make_default_row (signal = "sig2" ))
62
59
self ._insert_rows (rows )
63
60
64
61
with self .subTest (name = 'request two signals' ):
@@ -68,8 +65,8 @@ def test_covidcast(self):
68
65
)
69
66
70
67
expected = [
71
- row_latest_issue .as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields ),
72
- rows [- 1 ].as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields )
68
+ row_latest_issue .as_api_compatibility_row_dict ( ),
69
+ rows [- 1 ].as_api_compatibility_row_dict ( )
73
70
]
74
71
75
72
self .assertEqual (response ['epidata' ], expected )
@@ -88,10 +85,10 @@ def test_covidcast(self):
88
85
89
86
expected = [{
90
87
rows [0 ].signal : [
91
- row_latest_issue .as_dict (ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields + ['signal' ]),
88
+ row_latest_issue .as_api_compatibility_row_dict (ignore_fields = ['signal' ]),
92
89
],
93
90
rows [- 1 ].signal : [
94
- rows [- 1 ].as_dict (ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields + ['signal' ]),
91
+ rows [- 1 ].as_api_compatibility_row_dict (ignore_fields = ['signal' ]),
95
92
],
96
93
}]
97
94
@@ -108,7 +105,7 @@ def test_covidcast(self):
108
105
** self .params_from_row (rows [0 ])
109
106
)
110
107
111
- expected = [row_latest_issue .as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields )]
108
+ expected = [row_latest_issue .as_api_compatibility_row_dict ( )]
112
109
113
110
# check result
114
111
self .assertEqual (response_1 , {
@@ -123,7 +120,7 @@ def test_covidcast(self):
123
120
** self .params_from_row (rows [0 ], as_of = rows [1 ].issue )
124
121
)
125
122
126
- expected = [rows [1 ].as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields )]
123
+ expected = [rows [1 ].as_api_compatibility_row_dict ( )]
127
124
128
125
# check result
129
126
self .maxDiff = None
@@ -140,8 +137,8 @@ def test_covidcast(self):
140
137
)
141
138
142
139
expected = [
143
- rows [0 ].as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields ),
144
- rows [1 ].as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields )
140
+ rows [0 ].as_api_compatibility_row_dict ( ),
141
+ rows [1 ].as_api_compatibility_row_dict ( )
145
142
]
146
143
147
144
# check result
@@ -157,7 +154,7 @@ def test_covidcast(self):
157
154
** self .params_from_row (rows [0 ], lag = 2 )
158
155
)
159
156
160
- expected = [row_latest_issue .as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields )]
157
+ expected = [row_latest_issue .as_api_compatibility_row_dict ( )]
161
158
162
159
# check result
163
160
self .assertDictEqual (response_3 , {
@@ -222,16 +219,16 @@ def test_geo_value(self):
222
219
# insert placeholder data: three counties, three MSAs
223
220
N = 3
224
221
rows = [
225
- CovidcastRow .make_default_row (geo_type = "county" , geo_value = str (i )* 5 , value = i )
222
+ CovidcastTestRow .make_default_row (geo_type = "county" , geo_value = str (i )* 5 , value = i )
226
223
for i in range (N )
227
224
] + [
228
- CovidcastRow .make_default_row (geo_type = "msa" , geo_value = str (i )* 5 , value = i * 10 )
225
+ CovidcastTestRow .make_default_row (geo_type = "msa" , geo_value = str (i )* 5 , value = i * 10 )
229
226
for i in range (N )
230
227
]
231
228
self ._insert_rows (rows )
232
229
233
230
counties = [
234
- rows [i ].as_dict ( ignore_fields = CovidcastRow . _api_row_compatibility_ignore_fields ) for i in range (N )
231
+ rows [i ].as_api_compatibility_row_dict ( ) for i in range (N )
235
232
]
236
233
237
234
def fetch (geo ):
@@ -277,7 +274,11 @@ def test_covidcast_meta(self):
277
274
# 2nd issue: 1 11 21
278
275
# 3rd issue: 2 12 22
279
276
rows = [
280
- CovidcastRow .make_default_row (time_value = DEFAULT_TIME_VALUE + t , issue = DEFAULT_ISSUE + i , value = t * 10 + i )
277
+ CovidcastTestRow .make_default_row (
278
+ time_value = DEFAULT_TIME_VALUE + t ,
279
+ issue = DEFAULT_ISSUE + i ,
280
+ value = t * 10 + i
281
+ )
281
282
for i in range (3 ) for t in range (3 )
282
283
]
283
284
self ._insert_rows (rows )
@@ -324,10 +325,10 @@ def test_async_epidata(self):
324
325
# insert placeholder data: three counties, three MSAs
325
326
N = 3
326
327
rows = [
327
- CovidcastRow .make_default_row (geo_type = "county" , geo_value = str (i )* 5 , value = i )
328
+ CovidcastTestRow .make_default_row (geo_type = "county" , geo_value = str (i )* 5 , value = i )
328
329
for i in range (N )
329
330
] + [
330
- CovidcastRow .make_default_row (geo_type = "msa" , geo_value = str (i )* 5 , value = i * 10 )
331
+ CovidcastTestRow .make_default_row (geo_type = "msa" , geo_value = str (i )* 5 , value = i * 10 )
331
332
for i in range (N )
332
333
]
333
334
self ._insert_rows (rows )
0 commit comments