mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
notify-300 set total message limit of 250k
This commit is contained in:
@@ -209,6 +209,7 @@ def sample_service(sample_user):
|
||||
data = {
|
||||
'name': service_name,
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'email_from': email_from,
|
||||
'created_by': sample_user
|
||||
|
||||
@@ -107,6 +107,7 @@ def create_service(
|
||||
email_from=None,
|
||||
prefix_sms=True,
|
||||
message_limit=1000,
|
||||
total_message_limit=250000,
|
||||
organisation_type='federal',
|
||||
check_if_service_exists=False,
|
||||
go_live_user=None,
|
||||
@@ -123,6 +124,7 @@ def create_service(
|
||||
service = Service(
|
||||
name=service_name,
|
||||
message_limit=message_limit,
|
||||
total_message_limit=total_message_limit,
|
||||
restricted=restricted,
|
||||
email_from=email_from if email_from else service_name.lower().replace(' ', '.'),
|
||||
created_by=user if user else create_user(email='{}@digital.cabinet-office.gov.uk'.format(uuid.uuid4())),
|
||||
|
||||
@@ -249,6 +249,7 @@ def test_get_service_by_id(admin_request, sample_service):
|
||||
'id',
|
||||
'inbound_api',
|
||||
'message_limit',
|
||||
'total_message_limit',
|
||||
'name',
|
||||
'notes',
|
||||
'organisation',
|
||||
@@ -362,6 +363,7 @@ def test_create_service(
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -426,6 +428,7 @@ def test_create_service_with_domain_sets_organisation(
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -448,6 +451,7 @@ def test_create_service_should_create_annual_billing_for_service(
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -468,6 +472,7 @@ def test_create_service_should_raise_exception_and_not_create_service_if_annual_
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -498,6 +503,7 @@ def test_create_service_inherits_branding_from_organisation(
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -516,6 +522,7 @@ def test_should_not_create_service_with_missing_user_id_field(notify_api, fake_u
|
||||
'email_from': 'service',
|
||||
'name': 'created service',
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'created_by': str(fake_uuid)
|
||||
@@ -539,6 +546,7 @@ def test_should_error_if_created_by_missing(notify_api, sample_user):
|
||||
'email_from': 'service',
|
||||
'name': 'created service',
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'user_id': str(sample_user.id)
|
||||
@@ -565,6 +573,7 @@ def test_should_not_create_service_with_missing_if_user_id_is_not_in_database(no
|
||||
'user_id': fake_uuid,
|
||||
'name': 'created service',
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'created_by': str(fake_uuid)
|
||||
@@ -610,6 +619,7 @@ def test_should_not_create_service_with_duplicate_name(notify_api,
|
||||
'name': sample_service.name,
|
||||
'user_id': str(sample_service.users[0].id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'sample.service2',
|
||||
@@ -637,6 +647,7 @@ def test_create_service_should_throw_duplicate_key_constraint_for_existing_email
|
||||
'name': service_name,
|
||||
'user_id': str(first_service.users[0].id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'first.service',
|
||||
@@ -666,6 +677,7 @@ def test_update_service(client, notify_db_session, sample_service):
|
||||
'created_by': str(sample_service.created_by.id),
|
||||
'email_branding': str(brand.id),
|
||||
'organisation_type': 'federal',
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
auth_header = create_admin_authorization_header()
|
||||
@@ -684,6 +696,7 @@ def test_update_service(client, notify_db_session, sample_service):
|
||||
|
||||
|
||||
def test_cant_update_service_org_type_to_random_value(client, sample_service):
|
||||
|
||||
data = {
|
||||
'name': 'updated service name',
|
||||
'email_from': 'updated.service.name',
|
||||
@@ -704,6 +717,7 @@ def test_cant_update_service_org_type_to_random_value(client, sample_service):
|
||||
def test_update_service_remove_email_branding(admin_request, notify_db_session, sample_service):
|
||||
brand = EmailBranding(colour='#000000', logo='justice-league.png', name='Justice League')
|
||||
sample_service.email_branding = brand
|
||||
sample_service.total_message_limit = 250000
|
||||
notify_db_session.commit()
|
||||
|
||||
resp = admin_request.post(
|
||||
@@ -719,6 +733,7 @@ def test_update_service_change_email_branding(admin_request, notify_db_session,
|
||||
brand2 = EmailBranding(colour='#111111', logo='avengers.png', name='Avengers')
|
||||
notify_db_session.add_all([brand1, brand2])
|
||||
sample_service.email_branding = brand1
|
||||
sample_service.total_message_limit = 250000
|
||||
notify_db_session.commit()
|
||||
|
||||
resp = admin_request.post(
|
||||
@@ -742,6 +757,7 @@ def test_update_service_flags(client, sample_service):
|
||||
|
||||
data = {
|
||||
'research_mode': True,
|
||||
'total_message_limit': 250000,
|
||||
'permissions': [INTERNATIONAL_SMS_TYPE]
|
||||
}
|
||||
|
||||
@@ -780,6 +796,7 @@ def test_update_service_sets_volumes(
|
||||
service_id=sample_service.id,
|
||||
_data={
|
||||
field: value,
|
||||
'total_message_limit': 250000,
|
||||
},
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
@@ -804,6 +821,7 @@ def test_update_service_sets_research_consent(
|
||||
service_id=sample_service.id,
|
||||
_data={
|
||||
'consent_to_research': value,
|
||||
'total_message_limit': 250000,
|
||||
},
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
@@ -879,7 +897,8 @@ def test_update_service_permissions_will_add_service_permissions(client, sample_
|
||||
auth_header = create_admin_authorization_header()
|
||||
|
||||
data = {
|
||||
'permissions': [EMAIL_TYPE, SMS_TYPE]
|
||||
'permissions': [EMAIL_TYPE, SMS_TYPE],
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
@@ -1003,7 +1022,8 @@ def test_should_not_update_service_with_duplicate_name(notify_api,
|
||||
email_from='another.name')
|
||||
data = {
|
||||
'name': service_name,
|
||||
'created_by': str(service.created_by.id)
|
||||
'created_by': str(service.created_by.id),
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
auth_header = create_admin_authorization_header()
|
||||
@@ -1034,7 +1054,8 @@ def test_should_not_update_service_with_duplicate_email_from(notify_api,
|
||||
data = {
|
||||
'name': service_name,
|
||||
'email_from': email_from,
|
||||
'created_by': str(service.created_by.id)
|
||||
'created_by': str(service.created_by.id),
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
auth_header = create_admin_authorization_header()
|
||||
@@ -1133,6 +1154,7 @@ def test_default_permissions_are_added_for_user_service(notify_api,
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
'message_limit': 1000,
|
||||
'total_message_limit': 250000,
|
||||
'restricted': False,
|
||||
'active': False,
|
||||
'email_from': 'created.service',
|
||||
@@ -1905,7 +1927,7 @@ def test_set_sms_prefixing_for_service(
|
||||
result = admin_request.post(
|
||||
'service.update_service',
|
||||
service_id=sample_service.id,
|
||||
_data={'prefix_sms': posted_value},
|
||||
_data={'prefix_sms': posted_value, 'total_message_limit': 250000},
|
||||
)
|
||||
assert result['data']['prefix_sms'] == stored_value
|
||||
|
||||
@@ -1917,7 +1939,7 @@ def test_set_sms_prefixing_for_service_cant_be_none(
|
||||
resp = admin_request.post(
|
||||
'service.update_service',
|
||||
service_id=sample_service.id,
|
||||
_data={'prefix_sms': None},
|
||||
_data={'prefix_sms': None, 'total_message_limit': 250000},
|
||||
_expected_status=400,
|
||||
)
|
||||
assert resp['message'] == {'prefix_sms': ['Field may not be null.']}
|
||||
@@ -2256,7 +2278,8 @@ def test_update_service_does_not_call_send_notification_for_live_service(sample_
|
||||
send_notification_mock = mocker.patch('app.service.rest.send_notification_to_service_users')
|
||||
|
||||
data = {
|
||||
"restricted": True
|
||||
"restricted": True,
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
auth_header = create_admin_authorization_header()
|
||||
@@ -2275,7 +2298,8 @@ def test_update_service_does_not_call_send_notification_when_restricted_not_chan
|
||||
send_notification_mock = mocker.patch('app.service.rest.send_notification_to_service_users')
|
||||
|
||||
data = {
|
||||
"name": 'Name of service'
|
||||
"name": 'Name of service',
|
||||
'total_message_limit': 250000,
|
||||
}
|
||||
|
||||
auth_header = create_admin_authorization_header()
|
||||
|
||||
@@ -88,7 +88,6 @@ def _notify_db(notify_api, worker_id):
|
||||
ALEMBIC_CONFIG = os.path.join(BASE_DIR, 'migrations')
|
||||
config = Config(ALEMBIC_CONFIG + '/alembic.ini')
|
||||
config.set_main_option("script_location", ALEMBIC_CONFIG)
|
||||
|
||||
with notify_api.app_context():
|
||||
upgrade(config, 'head')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user