mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 00:11:16 -05:00
Remove unnecessary code to do with testing service name uniqueness
notifications-admin has now been changed to always pass the service_id to the 'service/unique' endpoint. This means we don't need to cover the case of there being no service_id and the tests can also be updated.
This commit is contained in:
@@ -677,13 +677,10 @@ def is_service_name_unique():
|
||||
|
||||
name_exists = Service.query.filter_by(name=name).first()
|
||||
|
||||
if service_id:
|
||||
email_from_exists = Service.query.filter(
|
||||
Service.email_from == email_from,
|
||||
Service.id != service_id
|
||||
).first()
|
||||
else:
|
||||
email_from_exists = Service.query.filter_by(email_from=email_from).first()
|
||||
email_from_exists = Service.query.filter(
|
||||
Service.email_from == email_from,
|
||||
Service.id != service_id
|
||||
).first()
|
||||
|
||||
result = not (name_exists or email_from_exists)
|
||||
return jsonify(result=result), 200
|
||||
@@ -694,6 +691,8 @@ def check_request_args(request):
|
||||
name = request.args.get('name', None)
|
||||
email_from = request.args.get('email_from', None)
|
||||
errors = []
|
||||
if not service_id:
|
||||
errors.append({'service_id': ["Can't be empty"]})
|
||||
if not name:
|
||||
errors.append({'name': ["Can't be empty"]})
|
||||
if not email_from:
|
||||
|
||||
Reference in New Issue
Block a user