@@ -60,12 +60,20 @@ def setUp(self):
60
60
61
61
# use the local instance of the Epidata API
62
62
Epidata .BASE_URL = BASE_URL
63
+ Epidata .auth = ('epidata' , 'key' )
63
64
64
65
def tearDown (self ):
65
66
"""Perform per-test teardown."""
66
67
self .cur .close ()
67
68
self .cnx .close ()
68
69
70
+ @staticmethod
71
+ def _make_request ():
72
+ params = {'endpoint' : 'covidcast_meta' , 'cached' : 'true' }
73
+ response = requests .get (Epidata .BASE_URL , params = params , auth = Epidata .auth )
74
+ response .raise_for_status ()
75
+ return response .json ()
76
+
69
77
def test_caching (self ):
70
78
"""Populate, query, cache, query, and verify the cache."""
71
79
@@ -147,10 +155,7 @@ def test_caching(self):
147
155
self .cnx .commit ()
148
156
149
157
# fetch the cached version (manually)
150
- params = {'endpoint' : 'covidcast_meta' , 'cached' : 'true' }
151
- response = requests .get (BASE_URL , params = params )
152
- response .raise_for_status ()
153
- epidata4 = response .json ()
158
+ epidata4 = self ._make_request ()
154
159
155
160
# make sure the cache was actually served
156
161
self .assertEqual (epidata4 , {
@@ -170,10 +175,7 @@ def test_caching(self):
170
175
self .cnx .commit ()
171
176
172
177
# fetch the cached version (manually)
173
- params = {'endpoint' : 'covidcast_meta' , 'cached' : 'true' }
174
- response = requests .get (BASE_URL , params = params )
175
- response .raise_for_status ()
176
- epidata5 = response .json ()
178
+ epidata5 = self ._make_request ()
177
179
178
180
# make sure the cache was returned anyhow
179
181
self .assertEqual (epidata4 , epidata5 )
0 commit comments