mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 10:29:49 -04:00
Don’t prefil answer to research consent question
We were treating `None` (not answered) the same as `False` (previously answered no).
This commit is contained in:
@@ -151,7 +151,10 @@ def estimate_usage(service_id):
|
|||||||
volume_email=current_service.volume_email,
|
volume_email=current_service.volume_email,
|
||||||
volume_sms=current_service.volume_sms,
|
volume_sms=current_service.volume_sms,
|
||||||
volume_letter=current_service.volume_letter,
|
volume_letter=current_service.volume_letter,
|
||||||
consent_to_research='yes' if current_service.consent_to_research else 'no',
|
consent_to_research={
|
||||||
|
True: 'yes',
|
||||||
|
False: 'no',
|
||||||
|
}.get(current_service.consent_to_research),
|
||||||
)
|
)
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
|
|||||||
@@ -826,6 +826,11 @@ def test_non_gov_user_is_told_they_cant_go_live(
|
|||||||
assert page.select('button') == []
|
assert page.select('button') == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('consent_to_research, displayed_consent', (
|
||||||
|
(None, None),
|
||||||
|
(True, 'yes'),
|
||||||
|
(False, 'no'),
|
||||||
|
))
|
||||||
@pytest.mark.parametrize('volumes, displayed_volumes', (
|
@pytest.mark.parametrize('volumes, displayed_volumes', (
|
||||||
(
|
(
|
||||||
(('email', None), ('sms', None), ('letter', None)),
|
(('email', None), ('sms', None), ('letter', None)),
|
||||||
@@ -841,6 +846,8 @@ def test_should_show_estimate_volumes(
|
|||||||
client_request,
|
client_request,
|
||||||
volumes,
|
volumes,
|
||||||
displayed_volumes,
|
displayed_volumes,
|
||||||
|
consent_to_research,
|
||||||
|
displayed_consent,
|
||||||
):
|
):
|
||||||
for channel, volume in volumes:
|
for channel, volume in volumes:
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
@@ -849,6 +856,12 @@ def test_should_show_estimate_volumes(
|
|||||||
new_callable=PropertyMock,
|
new_callable=PropertyMock,
|
||||||
return_value=volume,
|
return_value=volume,
|
||||||
)
|
)
|
||||||
|
mocker.patch(
|
||||||
|
'app.models.service.Service.consent_to_research',
|
||||||
|
create=True,
|
||||||
|
new_callable=PropertyMock,
|
||||||
|
return_value=consent_to_research,
|
||||||
|
)
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.estimate_usage', service_id=SERVICE_ONE_ID
|
'main.estimate_usage', service_id=SERVICE_ONE_ID
|
||||||
)
|
)
|
||||||
@@ -875,6 +888,14 @@ def test_should_show_estimate_volumes(
|
|||||||
) == label
|
) == label
|
||||||
assert page.select_one('#volume_{}'.format(channel))['value'] == value
|
assert page.select_one('#volume_{}'.format(channel))['value'] == value
|
||||||
|
|
||||||
|
assert len(page.select('input[type=radio]')) == 2
|
||||||
|
|
||||||
|
if displayed_consent is None:
|
||||||
|
assert len(page.select('input[checked]')) == 0
|
||||||
|
else:
|
||||||
|
assert len(page.select('input[checked]')) == 1
|
||||||
|
assert page.select_one('input[checked]')['value'] == displayed_consent
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('consent_to_research, expected_persisted_consent_to_research', (
|
@pytest.mark.parametrize('consent_to_research, expected_persisted_consent_to_research', (
|
||||||
('yes', True),
|
('yes', True),
|
||||||
|
|||||||
Reference in New Issue
Block a user