From d4c4bbdb76e4305ad13a2811b2e662c70b25605c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 28 Aug 2024 14:13:58 -0700 Subject: [PATCH] debug messages for e2e test story --- app/user/rest.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/user/rest.py b/app/user/rest.py index a789ee128..0a706b9bf 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -1,4 +1,5 @@ import json +import os import uuid from urllib.parse import urlencode @@ -53,7 +54,7 @@ post_verify_code_schema, post_verify_webauthn_schema, ) -from app.utils import url_with_token, utc_now +from app.utils import hilite, url_with_token, utc_now from notifications_utils.recipients import is_us_phone_number, use_numeric_sender user_blueprint = Blueprint("user", __name__) @@ -588,13 +589,27 @@ def get_user_login_gov_user(): return jsonify(data=result) +def debug_not_production(msg): + if os.getenv("NOTIFY_ENVIRONMENT") not in ["production"]: + current_app.logger.info(msg) + + @user_blueprint.route("/email", methods=["POST"]) def fetch_user_by_email(): - email = email_data_request_schema.load(request.get_json()) - - fetched_user = get_user_by_email(email["email"]) - result = fetched_user.serialize() - return jsonify(data=result) + try: + debug_not_production( + hilite(f"enter fetch_user_by_email with {request.get_json()}") + ) + email = email_data_request_schema.load(request.get_json()) + debug_not_production(hilite(f"request schema loads {email}")) + fetched_user = get_user_by_email(email["email"]) + debug_not_production(hilite(f"fetched user is {fetched_user}")) + result = fetched_user.serialize() + debug_not_production(hilite(f"result is serialized to {result}")) + return jsonify(data=result) + except Exception as e: + debug_not_production(hilite(f"Failed with {e}!!")) + raise e # TODO: Deprecate this GET endpoint