Skip to content

Commit 36d9d31

Browse files
authored
remove rate-limiting info from redis for each test (#1214)
1 parent 376c877 commit 36d9d31

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/acquisition/covidcast/test_utils.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
import unittest
55

66
import pandas as pd
7+
from redis import Redis
78

89
from delphi_utils import Nans
910
from delphi.epidata.common.covidcast_row import CovidcastRow
1011
from delphi.epidata.acquisition.covidcast.database import Database
12+
from delphi.epidata.server._config import REDIS_HOST, REDIS_PASSWORD
1113
from delphi.epidata.server.utils.dates import day_to_time_value, time_value_to_day
1214
import delphi.operations.secrets as secrets
1315

1416
# all the Nans we use here are just one value, so this is a shortcut to it:
1517
nmv = Nans.NOT_MISSING.value
1618

17-
# TODO replace these real geo_values with fake values, and use patch and mock to mock the return values of
19+
# TODO replace these real geo_values with fake values, and use patch and mock to mock the return values of
1820
# delphi_utils.geomap.GeoMapper().get_geo_values(geo_type) in parse_geo_sets() of _params.py
1921

2022
FIPS = ['04019', '19143', '29063', '36083'] # Example list of valid FIPS codes as strings
@@ -166,19 +168,25 @@ def setUp(self):
166168
self.localSetUp()
167169
self._db._connection.commit()
168170

171+
# clear all rate-limiting info from redis
172+
r = Redis(host=REDIS_HOST, password=REDIS_PASSWORD)
173+
for k in r.keys("LIMITER/*"):
174+
r.delete(k)
175+
176+
169177
def tearDown(self):
170178
# close and destroy conenction to the database
171179
self.localTearDown()
172180
self._db.disconnect(False)
173181
del self._db
174182

175183
def localSetUp(self):
176-
# stub; override in subclasses to perform custom setup.
184+
# stub; override in subclasses to perform custom setup.
177185
# runs after tables have been truncated but before database changes have been committed
178186
pass
179187

180188
def localTearDown(self):
181-
# stub; override in subclasses to perform custom teardown.
189+
# stub; override in subclasses to perform custom teardown.
182190
# runs after database changes have been committed
183191
pass
184192

@@ -198,4 +206,4 @@ def params_from_row(self, row: CovidcastTestRow, **kwargs):
198206
'geo_value': row.geo_value,
199207
}
200208
ret.update(kwargs)
201-
return ret
209+
return ret

0 commit comments

Comments
 (0)