Set free SMS limit depending on organisation type

Different parts of government get billed slightly differently, and
there’s differences in how much money we’re allowed to give them.

Think these numbers are right, but should be double checked.
This commit is contained in:
Chris Hill-Scott
2017-10-05 10:46:55 +01:00
parent 9453f301d2
commit c516760056
6 changed files with 40 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
import pytest
from flask import url_for, session
from app.utils import is_gov_user
@@ -43,6 +44,7 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
service_name='testing the post',
organisation_type='local',
message_limit=app_.config['DEFAULT_SERVICE_LIMIT'],
free_sms_fragment_limit=25000,
restricted=True,
user_id=api_user_active.id,
email_from='testing.the.post'
@@ -67,6 +69,11 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
)
@pytest.mark.parametrize('organisation_type, free_allowance', [
('central', 250 * 1000),
('local', 25 * 1000),
('nhs', 25 * 1000),
])
def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
app_,
logged_in_client,
@@ -74,19 +81,22 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
mock_create_service_template,
mock_get_services,
api_user_active,
organisation_type,
free_allowance,
):
response = logged_in_client.post(
url_for('main.add_service'),
data={
'name': 'testing the post',
'organisation_type': 'central',
'organisation_type': organisation_type,
}
)
assert mock_get_services.called
mock_create_service.assert_called_once_with(
service_name='testing the post',
organisation_type='central',
organisation_type=organisation_type,
message_limit=app_.config['DEFAULT_SERVICE_LIMIT'],
free_sms_fragment_limit=free_allowance,
restricted=True,
user_id=api_user_active.id,
email_from='testing.the.post'

View File

@@ -57,6 +57,7 @@ def test_client_creates_service_with_correct_data(
client.create_service(
service_name='My first service',
organisation_type='central_government',
free_sms_fragment_limit=2,
message_limit=1,
restricted=True,
user_id=fake_uuid,
@@ -72,6 +73,7 @@ def test_client_creates_service_with_correct_data(
name='My first service',
# The rest pass through with the same names
organisation_type='central_government',
free_sms_fragment_limit=2,
message_limit=1,
restricted=True,
user_id=fake_uuid,

View File

@@ -488,7 +488,15 @@ def mock_get_service_with_letters(mocker, api_user_active):
@pytest.fixture(scope='function')
def mock_create_service(mocker):
def _create(service_name, organisation_type, message_limit, restricted, user_id, email_from):
def _create(
service_name,
organisation_type,
message_limit,
free_sms_fragment_limit,
restricted,
user_id,
email_from,
):
service = service_json(
101, service_name, [user_id], message_limit=message_limit, restricted=restricted, email_from=email_from)
return service['id']
@@ -499,7 +507,15 @@ def mock_create_service(mocker):
@pytest.fixture(scope='function')
def mock_create_duplicate_service(mocker):
def _create(service_name, organisation_type, message_limit, restricted, user_id, email_from):
def _create(
service_name,
organisation_type,
message_limit,
free_sms_fragment_limit,
restricted,
user_id,
email_from,
):
json_mock = Mock(return_value={'message': {'name': ["Duplicate service name '{}'".format(service_name)]}})
resp_mock = Mock(status_code=400, json=json_mock)
http_error = HTTPError(response=resp_mock, message="Default message")