@@ -76,7 +76,7 @@ def test_acquire_dataset(self):
76
76
response = Epidata .covid_hosp_facility (
77
77
'450822' , Epidata .range (20200101 , 20210101 ))
78
78
self .assertEqual (response ['result' ], 1 )
79
- self .assertEqual (len (response ['epidata' ]), 1 )
79
+ self .assertEqual (len (response ['epidata' ]), 2 )
80
80
row = response ['epidata' ][0 ]
81
81
for k ,v in expected_spotchecks .items ():
82
82
self .assertTrue (
@@ -101,9 +101,9 @@ def test_acquire_dataset(self):
101
101
response = Epidata .covid_hosp_facility (
102
102
'450822' , Epidata .range (20200101 , 20210101 ))
103
103
self .assertEqual (response ['result' ], 1 )
104
- self .assertEqual (len (response ['epidata' ]), 1 )
104
+ self .assertEqual (len (response ['epidata' ]), 2 )
105
105
106
- @freeze_time ("2021-03-16 " )
106
+ @freeze_time ("2021-03-17 " )
107
107
def test_facility_lookup (self ):
108
108
"""Lookup facilities using various filters."""
109
109
@@ -120,7 +120,7 @@ def test_facility_lookup(self):
120
120
self .assertTrue (acquired )
121
121
122
122
# texas ground truth, sorted by `hospital_pk`
123
- # see sample data at testdata/acquisition/covid_hosp/facility/dataset_old .csv
123
+ # see sample data at testdata/acquisition/covid_hosp/facility/dataset .csv
124
124
texas_hospitals = [{
125
125
'hospital_pk' : '450771' ,
126
126
'state' : 'TX' ,
@@ -139,7 +139,7 @@ def test_facility_lookup(self):
139
139
'hospital_name' : 'MEDICAL CITY LAS COLINAS' ,
140
140
'address' : '6800 N MACARTHUR BLVD' ,
141
141
'city' : 'IRVING' ,
142
- 'zip' : '75039' ,
142
+ 'zip' : '77777' , # most-recent collection week should take precedence
143
143
'hospital_subtype' : 'Short Term' ,
144
144
'fips_code' : '48113' ,
145
145
'is_metro_micro' : 1 ,
@@ -150,7 +150,7 @@ def test_facility_lookup(self):
150
150
'hospital_name' : 'RANKIN HOSPITAL MEDICAL CLINIC' ,
151
151
'address' : '1611 SPUR 576' ,
152
152
'city' : 'RANKIN' ,
153
- 'zip' : '79778' ,
153
+ 'zip' : '99999' , # most-recent collection week should take precedence
154
154
'hospital_subtype' : 'Critical Access Hospitals' ,
155
155
'fips_code' : '48461' ,
156
156
'is_metro_micro' : 0 ,
@@ -160,16 +160,16 @@ def test_facility_lookup(self):
160
160
response = Epidata .covid_hosp_facility_lookup (state = 'tx' )
161
161
self .assertEqual (response ['epidata' ], texas_hospitals )
162
162
163
- with self .subTest (name = 'by ccn ' ):
164
- response = Epidata .covid_hosp_facility_lookup (ccn = '450771 ' )
163
+ with self .subTest (name = 'by zip ' ):
164
+ response = Epidata .covid_hosp_facility_lookup (zip = '75093 ' )
165
165
self .assertEqual (response ['epidata' ], texas_hospitals [0 :1 ])
166
166
167
167
with self .subTest (name = 'by city' ):
168
168
response = Epidata .covid_hosp_facility_lookup (city = 'irving' )
169
169
self .assertEqual (response ['epidata' ], texas_hospitals [1 :2 ])
170
170
171
- with self .subTest (name = 'by zip ' ):
172
- response = Epidata .covid_hosp_facility_lookup (zip = '79778 ' )
171
+ with self .subTest (name = 'by ccn ' ):
172
+ response = Epidata .covid_hosp_facility_lookup (ccn = '451329 ' )
173
173
self .assertEqual (response ['epidata' ], texas_hospitals [2 :3 ])
174
174
175
175
with self .subTest (name = 'by fips_code' ):
@@ -179,3 +179,20 @@ def test_facility_lookup(self):
179
179
with self .subTest (name = 'no results' ):
180
180
response = Epidata .covid_hosp_facility_lookup (state = 'not a state' )
181
181
self .assertEqual (response ['result' ], - 2 )
182
+
183
+ # update facility info
184
+ mock_network = MagicMock ()
185
+ mock_network .fetch_metadata .return_value = \
186
+ self .test_utils .load_sample_metadata ('metadata_update_facility.csv' )
187
+ mock_network .fetch_dataset .return_value = \
188
+ self .test_utils .load_sample_dataset ('dataset_update_facility.csv' )
189
+
190
+ # acquire sample data into local database
191
+ with self .subTest (name = 'second acquisition' ):
192
+ acquired = Update .run (network = mock_network )
193
+ self .assertTrue (acquired )
194
+
195
+ texas_hospitals [1 ]['zip' ] = '88888'
196
+ with self .subTest (name = 'by city after update' ):
197
+ response = Epidata .covid_hosp_facility_lookup (city = 'irving' )
198
+ self .assertEqual (response ['epidata' ], texas_hospitals [1 :2 ])
0 commit comments