mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Merge branch 'master' into schedule-api-notification
This commit is contained in:
@@ -16,6 +16,7 @@ from app.models import (
|
||||
NOTIFICATION_STATUS_TYPES,
|
||||
NOTIFICATION_STATUS_TYPES_FAILED,
|
||||
NOTIFICATION_SENT,
|
||||
NOTIFICATION_DELIVERED,
|
||||
KEY_TYPE_NORMAL,
|
||||
KEY_TYPE_TEAM,
|
||||
KEY_TYPE_TEST
|
||||
@@ -357,28 +358,45 @@ def test_should_update_status_by_id_if_created(notify_db, notify_db_session):
|
||||
assert updated.status == 'failed'
|
||||
|
||||
|
||||
def test_should_not_update_status_by_reference_if_in_sent_status(notify_db, notify_db_session):
|
||||
notification = sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
def test_should_not_update_status_by_reference_if_from_country_with_no_delivery_receipts(sample_template):
|
||||
notification = create_notification(
|
||||
sample_template,
|
||||
status=NOTIFICATION_SENT,
|
||||
reference='foo'
|
||||
)
|
||||
|
||||
update_notification_status_by_reference('foo', 'failed')
|
||||
assert Notification.query.get(notification.id).status == NOTIFICATION_SENT
|
||||
res = update_notification_status_by_reference('foo', 'failed')
|
||||
|
||||
assert res is None
|
||||
assert notification.status == NOTIFICATION_SENT
|
||||
|
||||
|
||||
def test_should_not_update_status_by_id_if_in_sent_status(notify_db, notify_db_session):
|
||||
notification = sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
status=NOTIFICATION_SENT
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_no_delivery_receipts(sample_template):
|
||||
notification = create_notification(
|
||||
sample_template,
|
||||
status=NOTIFICATION_SENT,
|
||||
international=True,
|
||||
phone_prefix='1' # americans only have carrier delivery receipts
|
||||
)
|
||||
|
||||
update_notification_status_by_id(notification.id, 'failed')
|
||||
res = update_notification_status_by_id(notification.id, 'delivered')
|
||||
|
||||
assert Notification.query.get(notification.id).status == NOTIFICATION_SENT
|
||||
assert res is None
|
||||
assert notification.status == NOTIFICATION_SENT
|
||||
|
||||
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_no_delivery_receipts(sample_template):
|
||||
notification = create_notification(
|
||||
sample_template,
|
||||
status=NOTIFICATION_SENT,
|
||||
international=True,
|
||||
phone_prefix='7' # russians have full delivery receipts
|
||||
)
|
||||
|
||||
res = update_notification_status_by_id(notification.id, 'delivered')
|
||||
|
||||
assert res == notification
|
||||
assert notification.status == NOTIFICATION_DELIVERED
|
||||
|
||||
|
||||
def test_should_not_update_status_by_reference_if_not_sending(notify_db, notify_db_session):
|
||||
|
||||
@@ -20,7 +20,7 @@ from tests.app.conftest import (
|
||||
sample_notification_history as create_notification_history,
|
||||
sample_notification_with_job
|
||||
)
|
||||
from app.models import KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST
|
||||
from app.models import Service, KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST
|
||||
|
||||
from tests.app.db import create_user
|
||||
|
||||
@@ -216,6 +216,10 @@ def test_create_service(client, sample_user):
|
||||
assert json_resp['data']['dvla_organisation'] == '001'
|
||||
assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER']
|
||||
|
||||
service_db = Service.query.get(json_resp['data']['id'])
|
||||
assert service_db.name == 'created service'
|
||||
assert service_db.sms_sender == current_app.config['FROM_NUMBER']
|
||||
|
||||
auth_header_fetch = create_authorization_header()
|
||||
|
||||
resp = client.get(
|
||||
@@ -1731,3 +1735,19 @@ def test_update_service_does_not_call_send_notification_when_restricted_not_chan
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert not send_notification_mock.called
|
||||
|
||||
|
||||
def test_update_service_works_when_sms_sender_is_null(sample_service, client, mocker):
|
||||
sample_service.sms_sender = None
|
||||
data = {'name': 'new name'}
|
||||
|
||||
resp = client.post(
|
||||
'service/{}'.format(sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[create_authorization_header()],
|
||||
content_type='application/json'
|
||||
)
|
||||
|
||||
assert resp.status_code == 200
|
||||
# make sure it wasn't changed to not-null under the hood
|
||||
assert sample_service.sms_sender is None
|
||||
|
||||
Reference in New Issue
Block a user