Working tests and provider stats table.

Fix for tests and import error.

Added tests and updated for code review comments.
This commit is contained in:
Nicholas Staples
2016-04-25 10:38:37 +01:00
parent ff61223d97
commit b56e324a4c
14 changed files with 365 additions and 90 deletions

View File

@@ -59,4 +59,11 @@ def register_errors(blueprint):
@blueprint.app_errorhandler(SQLAlchemyError)
def db_error(e):
current_app.logger.exception(e)
return jsonify(result='error', message=str(e)), 500
if e.orig.pgerror and \
('duplicate key value violates unique constraint "services_name_key"' in e.orig.pgerror or
'duplicate key value violates unique constraint "services_email_from_key"' in e.orig.pgerror):
return jsonify(
result='error',
message={'name': ["Duplicate service name '{}'".format(e.params.get('name', ''))]}
), 400
return jsonify(result='error', message="Internal server error"), 500