From 53ca5cec523edd5e680a8f3556030a8d3e3bcbd7 Mon Sep 17 00:00:00 2001 From: Doug Lovett Date: Fri, 10 May 2024 11:48:50 -0700 Subject: [PATCH] Securities Act Notice add flag to user profile, update unit test. Signed-off-by: Doug Lovett --- ppr-api/src/ppr_api/resources/v1/user_profile.py | 4 +++- ppr-api/tests/unit/api/test_user_profile.py | 1 + ppr-api/tests/unit/api/test_utils.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ppr-api/src/ppr_api/resources/v1/user_profile.py b/ppr-api/src/ppr_api/resources/v1/user_profile.py index 71529eba6..fc889ec9d 100644 --- a/ppr-api/src/ppr_api/resources/v1/user_profile.py +++ b/ppr-api/src/ppr_api/resources/v1/user_profile.py @@ -18,7 +18,7 @@ from flask import Blueprint, current_app, g, request from flask_cors import cross_origin from ppr_api.exceptions import BusinessException -from ppr_api.models import User, UserProfile +from ppr_api.models import ClientCode, User, UserProfile from ppr_api.resources import utils as resource_utils from ppr_api.services.authz import ( GENERAL_USER_GROUP, @@ -64,6 +64,8 @@ def get_user_profile(): user.user_profile = UserProfile.create_from_json(None, user.id) user.user_profile.save() profile_json = set_service_agreements(jwt, user.user_profile) + parties = ClientCode.find_by_account_id(account_id, False, True) + profile_json['hasSecuritiesActAccess'] = parties is not None and len(parties) > 0 return profile_json, HTTPStatus.OK except BusinessException as exception: diff --git a/ppr-api/tests/unit/api/test_user_profile.py b/ppr-api/tests/unit/api/test_user_profile.py index d5fb87edb..35ddbfafe 100644 --- a/ppr-api/tests/unit/api/test_user_profile.py +++ b/ppr-api/tests/unit/api/test_user_profile.py @@ -141,6 +141,7 @@ def test_get_user_profile(session, client, jwt, desc, staff, include_account, st assert 'selectConfirmationDialog' in response_data assert 'defaultDropDowns' in response_data assert 'defaultTableFilters' in response_data + assert 'hasSecuritiesActAccess' in response_data @pytest.mark.parametrize('desc,staff,include_account,status,role,data', TEST_DATA_UPDATE) diff --git a/ppr-api/tests/unit/api/test_utils.py b/ppr-api/tests/unit/api/test_utils.py index 78085cde4..b66ea635c 100644 --- a/ppr-api/tests/unit/api/test_utils.py +++ b/ppr-api/tests/unit/api/test_utils.py @@ -205,7 +205,7 @@ def test_validate_registration(session, client, jwt, desc, valid): del json_data['authorizationReceived'] # test - error_msg = resource_utils.validate_registration(json_data) + error_msg = resource_utils.validate_registration(json_data, 'PS12345') if valid: assert error_msg == '' else: