def post_process(business: Business, filing: Filing): """Post processing activities for incorporations. THIS SHOULD NOT ALTER THE MODEL """ with suppress(IndexError, KeyError, TypeError): if err := business_profile.update_business_profile( business, filing.json['filing']['alteration']['contactPoint']): sentry_sdk.capture_message( f'Queue Error: Update Business for filing:{filing.id},error:{err}', level='error')
def post_process(business: Business, filing: Filing, correction: bool = False): """Post processing activities for incorporations. THIS SHOULD NOT ALTER THE MODEL """ if not correction and name_request.has_new_nr_for_alteration( business, filing.filing_json): name_request.consume_nr(business, filing, '/filing/alteration/nameRequest/nrNumber') with suppress(IndexError, KeyError, TypeError): if err := business_profile.update_business_profile( business, filing.json['filing']['alteration']['contactPoint']): sentry_sdk.capture_message( f'Queue Error: Update Business for filing:{filing.id},error:{err}', level='error')
def test_update_business_profile(app, session, requests_mock, test_name, response_json, response_status, put_status, expected_error): """Assert that the business profile is updated. WHITE BOX test, as I'm mocking out 2 end points to work the business logic. """ from flask import current_app email_address = '*****@*****.**' new_data = {'contactPoint': {'email': email_address}} business = Business(identifier='BC1234567', legal_type='BEN') with app.app_context(): # setup requests_mock.post(f'{current_app.config["ACCOUNT_SVC_AUTH_URL"]}', json={'access_token': 'token'}) requests_mock.post( f'{current_app.config["ACCOUNT_SVC_ENTITY_URL"]}/{business.identifier}', json=response_json, status_code=response_status) requests_mock.put( f'{current_app.config["ACCOUNT_SVC_ENTITY_URL"]}/{business.identifier}', status_code=put_status) # test err = business_profile.update_business_profile( business, new_data['contactPoint']) assert err == expected_error