def test_sa_get_token(client, jwt): """Assert that an OIDC get token request with valid SA credentials works as expected.""" # setup token = helper_create_jwt(jwt, [PPR_ROLE]) pay_client = SBCPaymentClient(jwt=token, account_id='PS12345') # test jwt = pay_client.get_sa_token() # check assert jwt assert len(jwt) > 0
def test_client_exception(client, jwt): """Assert that the pay-api client works as expected with an unuathorized exception.""" # setup token = helper_create_jwt(jwt, [PPR_ROLE]) pay_client = SBCPaymentClient(jwt=token, account_id='PS12345') pay_client.api_url = MOCK_URL # test with pytest.raises(ApiRequestError) as request_err: pay_client.create_payment(TransactionTypes.SEARCH.value, 1, '200000001', 'UT-PAY-SEARCH-01') assert request_err
def test_client_search_mock(client, jwt): """Assert that a pay-api client works as expected with the mock service endpoint.""" # setup token = helper_create_jwt(jwt, [PPR_ROLE]) pay_client = SBCPaymentClient(jwt=token, account_id='PS12345') pay_client.api_url = MOCK_URL_NO_KEY # test pay_data = pay_client.create_payment(TransactionTypes.SEARCH.value, 1, '200000001', 'UT-PAY-SEARCH-01') print(pay_data) # check assert pay_data assert pay_data['invoiceId'] assert pay_data['receipt']
def test_payment_data_no_trans_id_or_client_ref(client, jwt): """Assert that the payment-request body is as expected with no client reference id and no transaction id.""" # no setup # test data = SBCPaymentClient.create_payment_data(TransactionTypes.SEARCH.value, 1, None, None) # check assert data assert 'filingIdentifier' not in data['filingInfo'] assert 'folioNumber' not in data['filingInfo'] assert len(data['filingInfo']['filingTypes']) == 1 assert data['filingInfo']['filingTypes'][0]['quantity'] == 1 assert data['filingInfo']['filingTypes'][0]['filingTypeCode'] == 'SERCH' assert data['businessInfo']['corpType'] == 'PPR'
def test_payment_data_all(client, jwt): """Assert that the payment-request body content is as expected with all properties.""" # setup # test data = SBCPaymentClient.create_payment_data(TransactionTypes.SEARCH.value, 1, '200000000', 'UT-PAY-0001') print(json.dumps(data)) # check assert data assert data['filingInfo']['filingIdentifier'] == '200000000' assert data['filingInfo']['folioNumber'] == 'UT-PAY-0001' assert len(data['filingInfo']['filingTypes']) == 1 assert data['filingInfo']['filingTypes'][0]['quantity'] == 1 assert data['filingInfo']['filingTypes'][0]['filingTypeCode'] == 'SERCH' assert data['businessInfo']['corpType'] == 'PPR'
def test_payment_filing_type(client, jwt, pay_trans_type, quantity, filing_type): """Assert that the payment-request body filing type is as expected for a pay transaction type.""" # setup # test data = SBCPaymentClient.create_payment_data(pay_trans_type, quantity, '200000000', 'UT-PAY-0001') # check assert data assert data['filingInfo']['filingIdentifier'] == '200000000' assert data['filingInfo']['folioNumber'] == 'UT-PAY-0001' assert len(data['filingInfo']['filingTypes']) == 1 assert data['filingInfo']['filingTypes'][0]['quantity'] == quantity assert data['filingInfo']['filingTypes'][0][ 'filingTypeCode'] == filing_type assert data['businessInfo']['corpType'] == 'PPR'
def test_payment_data_staff_search(client, jwt, pay_trans_type, routing_slip, bcol_number, dat_number, waive_fees): """Assert that the staff payment payment-request body is as expected for a pay transaction type.""" transaction_info = {'transactionType': pay_trans_type} if pay_trans_type in (TransactionTypes.SEARCH_STAFF_CERTIFIED_NO_FEE.value, TransactionTypes.SEARCH_STAFF_NO_FEE.value): transaction_info['certified'] = True if routing_slip: transaction_info['routingSlipNumber'] = routing_slip if bcol_number: transaction_info['bcolAccountNumber'] = bcol_number if dat_number: transaction_info['datNumber'] = dat_number # test data = SBCPaymentClient.create_payment_staff_search_data( transaction_info, 'UT-PAY-0001') # check assert data if pay_trans_type in (TransactionTypes.SEARCH_STAFF_CERTIFIED_NO_FEE.value, TransactionTypes.SEARCH_STAFF_NO_FEE.value): assert len(data['filingInfo']['filingTypes']) == 2 else: assert len(data['filingInfo']['filingTypes']) == 1 if waive_fees: assert data['filingInfo']['filingTypes'][0]['waiveFees'] if pay_trans_type == TransactionTypes.SEARCH_STAFF_CERTIFIED_NO_FEE.value: assert data['filingInfo']['filingTypes'][1]['waiveFees'] else: assert 'waiveFees' not in data['filingInfo']['filingTypes'][0] if not routing_slip and not bcol_number: assert 'accountInfo' not in data elif routing_slip: assert 'accountInfo' in data and data['accountInfo'][ 'routingSlip'] == routing_slip elif bcol_number: assert 'accountInfo' in data and data['accountInfo'][ 'bcolAccountNumber'] == bcol_number if dat_number: assert data['accountInfo']['datNumber'] == dat_number
def get_search_report(search_id: str): """Generate a search result report.""" current_app.logger.info('Search report request id=' + search_id) search_detail = SearchResult.find_by_search_id(int(search_id), False) if search_detail is None: current_app.logger.info('No search report data found for id=' + search_id) raise ReportDataException('No search report data found for id=' + search_id) try: report_data = search_detail.json account_id = search_detail.search.account_id account_name = search_detail.account_name token = SBCPaymentClient.get_sa_token() return get_callback_pdf(report_data, account_id, ReportTypes.SEARCH_DETAIL_REPORT.value, token, account_name) except Exception as err: # pylint: disable=broad-except # noqa F841; current_app.logger.error('Search report generation failed for id=' + search_id) current_app.logger.error(repr(err)) raise ReportException('Search report generation failed for id=' + search_id)
def test_payment_data_staff_registration(client, jwt, pay_trans_type, routing_slip, bcol_number, dat_number, waive_fees): """Assert that the staff payment payment-request body is as expected for a pay transaction type.""" transaction_info = {'transactionType': pay_trans_type, 'feeQuantity': 1} if waive_fees: transaction_info['waiveFees'] = True if routing_slip: transaction_info['routingSlipNumber'] = routing_slip if bcol_number: transaction_info['bcolAccountNumber'] = bcol_number if dat_number: transaction_info['datNumber'] = dat_number # test data = SBCPaymentClient.create_payment_staff_registration_data( transaction_info, 'UT-PAY-0001') # check assert data assert len(data['filingInfo']['filingTypes']) == 1 assert data['filingInfo']['filingTypes'][0]['filingTypeCode'] assert data['filingInfo']['folioNumber'] == 'UT-PAY-0001' if waive_fees: assert 'waiveFees' in data['filingInfo']['filingTypes'][0] else: assert 'waiveFees' not in data['filingInfo']['filingTypes'][0] if not routing_slip and not bcol_number: assert 'accountInfo' not in data elif routing_slip: assert 'accountInfo' in data and data['accountInfo'][ 'routingSlip'] == routing_slip elif bcol_number: assert 'accountInfo' in data and data['accountInfo'][ 'bcolAccountNumber'] == bcol_number if dat_number: assert data['accountInfo']['datNumber'] == dat_number