mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -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:
@@ -3327,6 +3327,9 @@ def test_show_service_data_retention(
|
||||
mock_get_service_data_retention,
|
||||
|
||||
):
|
||||
|
||||
mock_get_service_data_retention.return_value[0]['days_of_retention'] = 5
|
||||
|
||||
response = logged_in_platform_admin_client.get(url_for('main.data_retention', service_id=service_one['id']))
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
rows = page.select('tbody tr')
|
||||
@@ -3366,12 +3369,12 @@ def test_update_service_data_retention(
|
||||
logged_in_platform_admin_client,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_get_service_data_retention_by_id,
|
||||
mock_get_service_data_retention,
|
||||
mock_update_service_data_retention,
|
||||
):
|
||||
response = logged_in_platform_admin_client.post(url_for('main.edit_data_retention',
|
||||
service_id=service_one['id'],
|
||||
data_retention_id=fake_uuid),
|
||||
data_retention_id=str(fake_uuid)),
|
||||
data={'days_of_retention': 5}
|
||||
)
|
||||
assert response.status_code == 302
|
||||
@@ -3385,7 +3388,7 @@ def test_update_service_data_retention_return_validation_error_for_negative_days
|
||||
logged_in_platform_admin_client,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_get_service_data_retention_by_id,
|
||||
mock_get_service_data_retention,
|
||||
mock_update_service_data_retention,
|
||||
):
|
||||
response = logged_in_platform_admin_client.post(url_for('main.edit_data_retention',
|
||||
@@ -3397,7 +3400,7 @@ def test_update_service_data_retention_return_validation_error_for_negative_days
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
error_message = page.find('span', class_='error-message').text.strip()
|
||||
assert error_message == 'Must be between 3 and 90'
|
||||
assert mock_get_service_data_retention_by_id.called
|
||||
assert mock_get_service_data_retention.called
|
||||
assert not mock_update_service_data_retention.called
|
||||
|
||||
|
||||
@@ -3405,8 +3408,10 @@ def test_update_service_data_retention_populates_form(
|
||||
logged_in_platform_admin_client,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_get_service_data_retention_by_id,
|
||||
mock_get_service_data_retention,
|
||||
):
|
||||
|
||||
mock_get_service_data_retention.return_value[0]['days_of_retention'] = 5
|
||||
response = logged_in_platform_admin_client.get(url_for('main.edit_data_retention',
|
||||
service_id=service_one['id'],
|
||||
data_retention_id=fake_uuid)
|
||||
|
||||
Reference in New Issue
Block a user