mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 06:18:25 -04:00
Merge pull request #1922 from alphagov/update-free-allowance-for-org-type
Update the free allowance when the organisation type is changed
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from flask import (
|
from flask import (
|
||||||
abort,
|
abort,
|
||||||
|
current_app,
|
||||||
flash,
|
flash,
|
||||||
redirect,
|
redirect,
|
||||||
render_template,
|
render_template,
|
||||||
@@ -695,10 +696,15 @@ def set_organisation_type(service_id):
|
|||||||
form = OrganisationTypeForm(organisation_type=current_service.get('organisation_type'))
|
form = OrganisationTypeForm(organisation_type=current_service.get('organisation_type'))
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
|
free_sms_fragment_limit = current_app.config['DEFAULT_FREE_SMS_FRAGMENT_LIMITS'].get(
|
||||||
|
form.organisation_type.data)
|
||||||
|
|
||||||
service_api_client.update_service(
|
service_api_client.update_service(
|
||||||
service_id,
|
service_id,
|
||||||
organisation_type=form.organisation_type.data,
|
organisation_type=form.organisation_type.data,
|
||||||
)
|
)
|
||||||
|
billing_api_client.create_or_update_free_sms_fragment_limit(service_id, free_sms_fragment_limit)
|
||||||
|
|
||||||
return redirect(url_for('.service_settings', service_id=service_id))
|
return redirect(url_for('.service_settings', service_id=service_id))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -1550,16 +1550,18 @@ def test_should_show_page_to_set_organisation_type(
|
|||||||
assert normalize_spaces(labels[index].text) == expected
|
assert normalize_spaces(labels[index].text) == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('organisation_type', [
|
@pytest.mark.parametrize('organisation_type, free_allowance', [
|
||||||
'central',
|
('central', 250000),
|
||||||
'local',
|
('local', 25000),
|
||||||
'nhs',
|
('nhs', 25000),
|
||||||
pytest.mark.xfail('private sector'),
|
pytest.mark.xfail(('private sector', 1000))
|
||||||
])
|
])
|
||||||
def test_should_set_organisation_type(
|
def test_should_set_organisation_type(
|
||||||
logged_in_platform_admin_client,
|
logged_in_platform_admin_client,
|
||||||
mock_update_service,
|
mock_update_service,
|
||||||
organisation_type,
|
organisation_type,
|
||||||
|
free_allowance,
|
||||||
|
mock_create_or_update_free_sms_fragment_limit
|
||||||
):
|
):
|
||||||
response = logged_in_platform_admin_client.post(
|
response = logged_in_platform_admin_client.post(
|
||||||
url_for(
|
url_for(
|
||||||
@@ -1578,6 +1580,7 @@ def test_should_set_organisation_type(
|
|||||||
SERVICE_ONE_ID,
|
SERVICE_ONE_ID,
|
||||||
organisation_type=organisation_type,
|
organisation_type=organisation_type,
|
||||||
)
|
)
|
||||||
|
mock_create_or_update_free_sms_fragment_limit.assert_called_once_with(SERVICE_ONE_ID, free_allowance)
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_page_to_set_sms_allowance(
|
def test_should_show_page_to_set_sms_allowance(
|
||||||
|
|||||||
Reference in New Issue
Block a user