Refactored to use service_id to set flag

This commit is contained in:
Ken Tsang
2017-08-14 18:20:25 +01:00
parent 4eba6335d6
commit e14fa2d87e
4 changed files with 8 additions and 8 deletions

View File

@@ -26,8 +26,8 @@ def dao_set_inbound_number_to_service(service_id, inbound_number):
@transactional
def dao_set_inbound_number_active_flag(inbound_number_id, active):
inbound_number = InboundNumber.query.filter(InboundNumber.id == inbound_number_id).first()
def dao_set_inbound_number_active_flag(service_id, active):
inbound_number = InboundNumber.query.filter(InboundNumber.service_id == service_id).first()
inbound_number.active = active
db.session.add(inbound_number)

View File

@@ -33,7 +33,7 @@ def post_allocate_inbound_number(service_id):
if inbound_number:
if not inbound_number.active:
dao_set_inbound_number_active_flag(inbound_number.id, active=True)
dao_set_inbound_number_active_flag(service_id, active=True)
return '', 204
else:
return '', 200
@@ -47,7 +47,7 @@ def post_allocate_inbound_number(service_id):
raise InvalidRequest('No available inbound numbers', status_code=400)
@inbound_number_blueprint.route('/<uuid:inbound_number_id>/off', methods=['POST'])
def post_set_inbound_number_off(inbound_number_id):
dao_set_inbound_number_active_flag(inbound_number_id, active=False)
@inbound_number_blueprint.route('/service/<uuid:service_id>/off', methods=['POST'])
def post_set_inbound_number_off(service_id):
dao_set_inbound_number_active_flag(service_id, active=False)
return '', 204

View File

@@ -74,7 +74,7 @@ def test_set_inbound_number_active_flag(notify_db, notify_db_session, sample_ser
inbound_number = create_inbound_number(number='1')
dao_set_inbound_number_to_service(sample_service.id, inbound_number)
dao_set_inbound_number_active_flag(inbound_number.id, active=active)
dao_set_inbound_number_active_flag(sample_service.id, active=active)
inbound_number = dao_get_inbound_number_for_service(sample_service.id)

View File

@@ -110,7 +110,7 @@ def test_rest_set_inbound_number_active_flag_off(
admin_request.post(
'inbound_number.post_set_inbound_number_off',
_expected_status=204,
inbound_number_id=inbound_number.id
service_id=service.id
)
inbound_number_from_db = dao_get_inbound_number_for_service(service.id)