mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Cache service data retention in Redis
Adds caching for service data retention. This removes separate API client methods to retrieve individual data retention records by id or type in favor of a single method that fetches and caches all retention settings configured for the service. This makes it much easier to invalidate cache when settings change. Lookup by id or type is provided by helper methods in the service model.
This commit is contained in:
@@ -536,14 +536,6 @@ def mock_get_service_statistics(mocker, api_user_active):
|
||||
return mocker.patch('app.service_api_client.get_service_statistics', side_effect=_get)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_service_data_retention_by_notification_type(mocker, api_user_active):
|
||||
def _get(service_id, notification_type):
|
||||
return {}
|
||||
|
||||
return mocker.patch('app.service_api_client.get_service_data_retention_by_notification_type', side_effect=_get)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_detailed_services(mocker, fake_uuid):
|
||||
service_one = service_json(
|
||||
@@ -2831,11 +2823,11 @@ def normalize_spaces(input):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_service_data_retention(mocker):
|
||||
data = {"id": str(fake_uuid),
|
||||
"service_id": str(fake_uuid),
|
||||
data = {"id": str(sample_uuid()),
|
||||
"service_id": str(sample_uuid()),
|
||||
"service_name": "service name",
|
||||
"notification_type": "email",
|
||||
"days_of_retention": 5,
|
||||
"days_of_retention": 7,
|
||||
"created_at": datetime.now(),
|
||||
"updated_at": None,
|
||||
}
|
||||
@@ -2843,20 +2835,6 @@ def mock_get_service_data_retention(mocker):
|
||||
return_value=[data])
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_service_data_retention_by_id(mocker):
|
||||
data = {"id": str(fake_uuid),
|
||||
"service_id": str(fake_uuid),
|
||||
"service_name": "service name",
|
||||
"notification_type": "email",
|
||||
"days_of_retention": 5,
|
||||
"created_at": datetime.now(),
|
||||
"updated_at": None,
|
||||
}
|
||||
return mocker.patch('app.service_api_client.get_service_data_retention_by_id',
|
||||
return_value=data)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_create_service_data_retention(mocker):
|
||||
return mocker.patch('app.service_api_client.create_service_data_retention')
|
||||
|
||||
Reference in New Issue
Block a user