Update post_allocate_inbound_number to set the service_sms_sender in the case when a service had the number, then it was set to inactive and now there is a request to turn it back on (or click allow inbound sms a couple of times on the front end)

This commit is contained in:
Rebecca Law
2017-10-02 17:35:58 +01:00
parent fb68767720
commit eff2a720ea
2 changed files with 2 additions and 19 deletions

View File

@@ -36,6 +36,8 @@ def post_allocate_inbound_number(service_id):
if inbound_number: if inbound_number:
if not inbound_number.active: if not inbound_number.active:
dao_set_inbound_number_active_flag(service_id, active=True) dao_set_inbound_number_active_flag(service_id, active=True)
service = dao_fetch_service_by_id(service_id)
insert_or_update_service_sms_sender(service, inbound_number.number, inbound_number.id)
return jsonify(), 204 return jsonify(), 204
else: else:
return jsonify(), 200 return jsonify(), 200

View File

@@ -114,25 +114,6 @@ def test_rest_set_inbound_number_active_flag_off(
assert not inbound_number_from_db.active assert not inbound_number_from_db.active
def test_allocate_inbound_number_insert_update_service_sms_sender(
admin_request, notify_db_session
):
service = create_service()
inbound_number = create_inbound_number(number='123')
admin_request.post(
'inbound_number.post_allocate_inbound_number',
_expected_status=204,
service_id=service.id
)
service_sms_senders = ServiceSmsSender.query.all()
assert len(service_sms_senders) == 1
assert service_sms_senders[0].sms_sender == inbound_number.number
assert service_sms_senders[0].inbound_number_id == inbound_number.id
assert service_sms_senders[0].is_default
def test_allocate_inbound_number_to_service(admin_request, notify_db_session): def test_allocate_inbound_number_to_service(admin_request, notify_db_session):
service = create_service() service = create_service()
inbound_number = create_inbound_number(number='1235468') inbound_number = create_inbound_number(number='1235468')