Skip to content

Commit

Permalink
added some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nolangormley committed Feb 3, 2025
1 parent e50624c commit 1604845
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import delphi.operations.secrets as secrets
import delphi.epidata.acquisition.covidcast.database as live
from delphi.epidata.maintenance.coverage_crossref_updater import main
from delphi.epidata.acquisition.covidcast.test_utils import CovidcastBase
from delphi.epidata.acquisition.covidcast.test_utils import CovidcastBase, CovidcastTestRow

# use the local instance of the Epidata API
BASE_URL = 'http://delphi_web_epidata/epidata' # NOSONAR
Expand All @@ -28,9 +28,7 @@ def localSetUp(self):
self._db._cursor.execute('TRUNCATE TABLE `coverage_crossref`')

@staticmethod
def _make_request(params=None):
if params is None:
params = {'geo': 'state:*'}
def _make_request(params):
response = requests.get(f"{Epidata.BASE_URL}/covidcast/geo_coverage", params=params, auth=Epidata.auth)
response.raise_for_status()
return response.json()
Expand All @@ -45,7 +43,7 @@ def test_caching(self):
CovidcastTestRow.make_default_row(geo_type="state", geo_value="ny", signal="sig2"),
])

results = self._make_request()
results = self._make_request(params = {'geo': 'state:*'})

# make sure the tables are empty
self.assertEqual(results, {
Expand All @@ -57,12 +55,12 @@ def test_caching(self):
# update the coverage crossref table
main()

results = self._make_request()
results = self._make_request(params = {'geo': 'state:*'})

# make sure the data was actually served
self.assertEqual(results, {
'result': 1,
'epidata': [{'signal': 'sig', 'source': 'src'}],
'epidata': [{'signal': 'sig', 'source': 'src'}, {'signal': 'sig2', 'source': 'src'}],
'message': 'success',
})

Expand All @@ -83,3 +81,13 @@ def test_caching(self):
'epidata': [{'signal': 'sig', 'source': 'src'}],
'message': 'success',
})

results = self._make_request(params = {'geo': 'state:ny'})

# make sure the data was actually served
self.assertEqual(results, {
'result': 1,
'epidata': [{'signal': 'sig', 'source': 'src'}, {'signal': 'sig2', 'source': 'src'}],
'message': 'success',
})

0 comments on commit 1604845

Please sign in to comment.