Merge pull request #894 from alphagov/fix-research-mode-toggle

Fix admin app putting service into research mode
This commit is contained in:
Chris Hill-Scott
2016-08-23 14:27:02 +01:00
committed by GitHub
2 changed files with 23 additions and 18 deletions

View File

@@ -89,6 +89,7 @@ class ServiceAPIClient(NotificationsAPIClient):
'restricted', 'restricted',
'email_from', 'email_from',
'reply_to_email_address', 'reply_to_email_address',
'research_mode',
'sms_sender', 'sms_sender',
'created_by', 'created_by',
'branding', 'branding',

View File

@@ -592,25 +592,29 @@ def test_if_reply_to_email_address_set_then_form_populated(app_,
def test_switch_service_to_research_mode( def test_switch_service_to_research_mode(
app_, app_,
service_one, service_one,
mock_login, mock_login,
mock_get_user, mock_get_user,
active_user_with_permissions, active_user_with_permissions,
mock_get_service, mock_get_service,
mock_has_permissions, mock_has_permissions,
mocker): mocker
with app_.test_request_context(): ):
with app_.test_client() as client: with app_.test_request_context(), app_.test_client() as client:
mocker.patch('app.service_api_client.update_service_with_properties', return_value=service_one) mocker.patch('app.service_api_client.post', return_value=service_one)
client.login(active_user_with_permissions) client.login(active_user_with_permissions)
response = client.get(url_for('main.service_switch_research_mode', service_id=service_one['id'])) response = client.get(url_for('main.service_switch_research_mode', service_id=service_one['id']))
assert response.status_code == 302 assert response.status_code == 302
assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True) assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True)
app.service_api_client.update_service_with_properties.assert_called_with( app.service_api_client.post.assert_called_with(
service_one['id'], {"research_mode": True} '/service/{}'.format(service_one['id']),
) {
'research_mode': True,
'created_by': active_user_with_permissions.id
}
)
def test_switch_service_from_research_mode_to_normal( def test_switch_service_from_research_mode_to_normal(