mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 16:52:23 -05:00
sys.exit rather than throwing an assertion error
Assertions should only be used in tests - they can be disabled at runtime by setting the python flag -O (though I don't believe we use that flag under normal circumstances). also clean up test asserts - mock_redis is the redis object, so its `called` property will always be false, because we never say `redis_store()`. Rather, we should use the `mock_calls` property to see all calls to all of its children
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import functools
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
@@ -504,9 +505,11 @@ def populate_redis_template_usage(service_id, day):
|
||||
Recalculate and replace the stats in redis for a day.
|
||||
To be used if redis data is lost for some reason.
|
||||
"""
|
||||
# the day variable is set to midnight of that day
|
||||
assert current_app.config['REDIS_ENABLED']
|
||||
if not current_app.config['REDIS_ENABLED']:
|
||||
current_app.logger.error('Cannot populate redis template usage - redis not enabled')
|
||||
sys.exit(1)
|
||||
|
||||
# the day variable is set by click to be midnight of that day
|
||||
start_time = get_london_midnight_in_utc(day)
|
||||
end_time = get_london_midnight_in_utc(day + timedelta(days=1))
|
||||
|
||||
@@ -533,5 +536,6 @@ def populate_redis_template_usage(service_id, day):
|
||||
redis_store.set_hash_and_expire(
|
||||
key,
|
||||
usage,
|
||||
current_app.config['EXPIRE_CACHE_EIGHT_DAYS']
|
||||
current_app.config['EXPIRE_CACHE_EIGHT_DAYS'],
|
||||
raise_exception=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user