def test_get_statement_report_for_empty_invoices(session): """Assert that the get statement report works for statement with no invoices.""" bcol_account = factory_premium_payment_account() bcol_account.save() payment = factory_payment() payment.save() i = factory_invoice(payment_account=bcol_account) i.save() factory_invoice_reference(i.id).save() factory_payment_line_item(invoice_id=i.id, fee_schedule_id=1).save() settings_model = factory_statement_settings( payment_account_id=bcol_account.id, frequency=StatementFrequency.DAILY.value) statement_model = factory_statement( payment_account_id=bcol_account.id, frequency=StatementFrequency.DAILY.value, statement_settings_id=settings_model.id) payment_account = PaymentAccount.find_by_id(bcol_account.id) statements = StatementService.find_by_account_id( payment_account.auth_account_id, page=1, limit=10) assert statements is not None report_response, report_name = StatementService.get_statement_report( statement_id=statement_model.id, content_type='application/pdf', auth=get_auth_premium_user()) assert report_response is not None
def test_create_account(session): """Test create_account.""" account = bcol_service.create_account( name=None, contact_info=None, account_info=None, authorization=get_auth_premium_user()) assert account is not None
def test_create_bcol_payment(session, public_user_mock): """Assert that the payment records are created.""" payment_response = PaymentService.create_invoice( get_payment_request_with_payment_method(payment_method='DRAWDOWN', business_identifier='CP0002000'), get_auth_premium_user()) assert payment_response is not None assert payment_response.get('payment_method') == 'DRAWDOWN' assert payment_response.get('status_code') == 'COMPLETED'
def test_premium_account_saved_from_new(session): """Assert that the payment is saved to the table.""" payment_account = factory_premium_payment_account() payment_account.save() pa = PaymentAccountService.find_account(get_auth_premium_user()) assert pa is not None assert pa.id is not None
def test_create_eft_payment(session, public_user_mock): """Assert that the payment records are created.""" factory_payment_account(payment_method_code=PaymentMethod.EFT.value).save() payment_response = PaymentService.create_invoice( get_payment_request_with_service_fees(business_identifier='CP0002000'), get_auth_premium_user()) assert payment_response is not None assert payment_response.get('payment_method') == PaymentMethod.EFT.value assert payment_response.get('status_code') == 'CREATED'
def test_premium_account_saved_from_new(session): """Assert that the payment is saved to the table.""" payment_account = factory_premium_payment_account() payment_account.save() pa = PaymentAccountService.find_account({}, get_auth_premium_user(), payment_system='BCOL', payment_method=PaymentMethod.DRAWDOWN.value) assert pa is not None assert pa.id is not None
def test_account_invalid_premium_account_lookup(session): """Invalid account test.""" business_info: Dict = {} p = PaymentAccountService.find_account(business_info, get_auth_premium_user(), 'BCOL') assert p is not None assert p.id is None import pytest from pay_api.exceptions import BusinessException from pay_api.utils.errors import Error with pytest.raises(BusinessException) as excinfo: PaymentAccountService.find_account(business_info, {}, 'BCOL') assert excinfo.value.status == Error.PAY015.status
def test_patch_online_banking_payment_to_cc(session, public_user_mock): """Assert that the payment records are created.""" payment_account = factory_payment_account( payment_method_code=PaymentMethod.ONLINE_BANKING.value).save() payment_account.save() # payment.save() payment_response = PaymentService.create_invoice( get_payment_request_with_service_fees(business_identifier='CP0002000'), get_auth_premium_user()) invoice_id = payment_response.get('id') factory_invoice_reference(invoice_id).save() request = {'paymentInfo': {'methodOfPayment': PaymentMethod.CC.value}} invoice_response = PaymentService.update_invoice(invoice_id, request) assert invoice_response.get('payment_method') == PaymentMethod.CC.value
def test_patch_online_banking_payment_to_direct_pay(session, public_user_mock): """Assert that the payment records are created.""" factory_payment_account( payment_method_code=PaymentMethod.ONLINE_BANKING.value).save() payment_response = PaymentService.create_invoice( get_payment_request_with_service_fees(business_identifier='CP0002000'), get_auth_premium_user()) assert payment_response is not None assert payment_response.get('payment_method') == 'ONLINE_BANKING' assert payment_response.get('status_code') == 'CREATED' invoice_id = payment_response.get('id') request = {'paymentInfo': {'methodOfPayment': PaymentMethod.CC.value}} invoice_response = PaymentService.update_invoice(invoice_id, request) assert invoice_response.get( 'payment_method') == PaymentMethod.DIRECT_PAY.value
def test_create_account(session): """Test create_account.""" account = bcol_service.create_account(None, None, get_auth_premium_user()) assert account is not None