@@ -60,12 +60,20 @@ def setUp(self):
6060
6161 # use the local instance of the Epidata API
6262 Epidata .BASE_URL = BASE_URL
63+ Epidata .auth = ('epidata' , 'key' )
6364
6465 def tearDown (self ):
6566 """Perform per-test teardown."""
6667 self .cur .close ()
6768 self .cnx .close ()
6869
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+
6977 def test_caching (self ):
7078 """Populate, query, cache, query, and verify the cache."""
7179
@@ -147,10 +155,7 @@ def test_caching(self):
147155 self .cnx .commit ()
148156
149157 # 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 ()
154159
155160 # make sure the cache was actually served
156161 self .assertEqual (epidata4 , {
@@ -170,10 +175,7 @@ def test_caching(self):
170175 self .cnx .commit ()
171176
172177 # 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 ()
177179
178180 # make sure the cache was returned anyhow
179181 self .assertEqual (epidata4 , epidata5 )
0 commit comments