mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-12 05:10:45 -04:00
Merge pull request #3676 from alphagov/broadcast-includes-content
Add content property to broadcast message model
This commit is contained in:
@@ -432,6 +432,9 @@ def clear_cache():
|
||||
'live-service-and-organisation-counts',
|
||||
'organisation-????????-????-????-????-????????????-name',
|
||||
]),
|
||||
('broadcast', [
|
||||
'service-????????-????-????-????-????????????-broadcast-message-????????-????-????-????-????????????',
|
||||
]),
|
||||
])
|
||||
|
||||
form = ClearCacheForm()
|
||||
|
||||
@@ -24,6 +24,7 @@ class BroadcastMessage(JSONModel):
|
||||
'template_id',
|
||||
'template_name',
|
||||
'template_version',
|
||||
'content',
|
||||
'service_id',
|
||||
'created_by',
|
||||
'personalisation',
|
||||
|
||||
@@ -650,6 +650,7 @@ def broadcast_message_json(
|
||||
approved_by_id=None,
|
||||
cancelled_by_id=None,
|
||||
areas=None,
|
||||
content=None,
|
||||
):
|
||||
return {
|
||||
'id': id_,
|
||||
@@ -659,6 +660,7 @@ def broadcast_message_json(
|
||||
'template_id': template_id,
|
||||
'template_version': 123,
|
||||
'template_name': 'Example template',
|
||||
'content': content or 'This is a test',
|
||||
|
||||
'personalisation': {},
|
||||
'areas': areas or [
|
||||
|
||||
@@ -689,10 +689,14 @@ def test_clear_cache_shows_form(client_request, platform_admin_user, mocker):
|
||||
|
||||
@pytest.mark.parametrize('model_type, expected_calls, expected_confirmation', (
|
||||
('template', [
|
||||
# Returns 101
|
||||
call('service-????????-????-????-????-????????????-templates'),
|
||||
# Returns 102
|
||||
call('service-????????-????-????-????-????????????-template-????????-????-????-????-????????????-version-*'),
|
||||
# Returns 103
|
||||
call('service-????????-????-????-????-????????????-template-????????-????-????-????-????????????-versions'),
|
||||
], 'Removed 3 template objects from redis'),
|
||||
# 103 shown here because it’s the `max` of the 3 counts
|
||||
], 'Removed 103 template objects from redis'),
|
||||
('service', [
|
||||
call('has_jobs-????????-????-????-????-????????????'),
|
||||
call('service-????????-????-????-????-????????????'),
|
||||
@@ -701,13 +705,16 @@ def test_clear_cache_shows_form(client_request, platform_admin_user, mocker):
|
||||
call('service-????????-????-????-????-????????????-template-folders'),
|
||||
call('service-????????-????-????-????-????????????-returned-letters-statistics'),
|
||||
call('service-????????-????-????-????-????????????-returned-letters-summary'),
|
||||
], 'Removed 3 service objects from redis'),
|
||||
], 'Removed 107 service objects from redis'),
|
||||
('organisation', [
|
||||
call('organisations'),
|
||||
call('domains'),
|
||||
call('live-service-and-organisation-counts'),
|
||||
call('organisation-????????-????-????-????-????????????-name'),
|
||||
], 'Removed 3 organisation objects from redis'),
|
||||
], 'Removed 104 organisation objects from redis'),
|
||||
('broadcast', [
|
||||
call('service-????????-????-????-????-????????????-broadcast-message-????????-????-????-????-????????????'),
|
||||
], 'Removed 101 broadcast objects from redis'),
|
||||
))
|
||||
def test_clear_cache_submits_and_tells_you_how_many_things_were_deleted(
|
||||
client_request,
|
||||
@@ -718,7 +725,9 @@ def test_clear_cache_submits_and_tells_you_how_many_things_were_deleted(
|
||||
expected_confirmation,
|
||||
):
|
||||
redis = mocker.patch('app.main.views.platform_admin.redis_client')
|
||||
redis.delete_cache_keys_by_pattern.side_effect = [0, 3, 1, 0, 0, 0, 0, 0]
|
||||
# The way this is set up means the first time `delete_cache_keys_by_pattern`
|
||||
# is called it will return `101`, the second time it will return `102`, etc
|
||||
redis.delete_cache_keys_by_pattern.side_effect = [101, 102, 103, 104, 105, 106, 107, 108, 109]
|
||||
client_request.login(platform_admin_user)
|
||||
|
||||
page = client_request.post('main.clear_cache', _data={'model_type': model_type}, _expected_status=200)
|
||||
|
||||
@@ -34,3 +34,14 @@ def test_simple_polygons(fake_uuid):
|
||||
# total coordinates
|
||||
[51],
|
||||
]
|
||||
|
||||
|
||||
def test_content_comes_from_attribute_not_template(fake_uuid):
|
||||
broadcast_message = BroadcastMessage(broadcast_message_json(
|
||||
id_=fake_uuid,
|
||||
service_id=fake_uuid,
|
||||
template_id=fake_uuid,
|
||||
status='draft',
|
||||
created_by_id=fake_uuid,
|
||||
))
|
||||
assert broadcast_message.content == 'This is a test'
|
||||
|
||||
Reference in New Issue
Block a user