def test_find_by_invalid_corp_number_and_corp_type_and_system(session): """Assert find works. Start with a blank database. """ payment_account = factory_payment_account() payment_account.save() assert PaymentAccount.find_by_corp_number_and_corp_type_and_system('CP0001234', 'CP', 'BCOL') is None assert PaymentAccount.find_by_corp_number_and_corp_type_and_system(None, None, None) is None
def test_rollback(session): """Assert rollback works. Start with a blank database. """ payment_account = factory_payment_account() payment_account.flush() assert PaymentAccount.find_by_corp_number_and_corp_type_and_system('CP0001234', 'CP', 'PAYBC') is not None payment_account.rollback() assert PaymentAccount.find_by_corp_number_and_corp_type_and_system('CP0001234', 'CP', 'PAYBC') is None
def test_create_payment_record(session): """Assert that the payment records are created.""" payment_response = PaymentService.create_payment(get_payment_request(), 'test') account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system('CP1234', 'CP', 'PAYBC') account_id = account_model.id assert account_id is not None assert payment_response.get('id') is not None # Create another payment with same request, the account should be the same PaymentService.create_payment(get_payment_request(), 'test') account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system('CP1234', 'CP', 'PAYBC') assert account_id == account_model.id
def test_create_zero_dollar_payment_record(session, public_user_mock): """Assert that the payment records are created and completed.""" payment_response = PaymentService.create_payment( get_zero_dollar_payment_request()) account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system( 'CP0001234', 'CP', 'INTERNAL') account_id = account_model.id assert account_id is not None assert payment_response.get('id') is not None assert payment_response.get('status_code') == 'COMPLETED' # Create another payment with same request, the account should be the same PaymentService.create_payment(get_zero_dollar_payment_request()) account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system( 'CP0001234', 'CP', 'INTERNAL') assert account_id == account_model.id assert payment_response.get('status_code') == 'COMPLETED'
def test_find_by_corp_number_and_corp_type_and_system(session): """Assert find works. Start with a blank database. """ payment_account = factory_payment_account() payment_account.save() assert PaymentAccount.find_by_corp_number_and_corp_type_and_system( 'CP1234', 'CP', 'PAYBC') is not None
def find_account(cls, corp_number: str, corp_type: str, payment_system: str): """Find payment account by corp number, corp type and payment system code.""" current_app.logger.debug('<find_payment_account') if not corp_number and not corp_type and not payment_system: raise BusinessException(Error.PAY004) account_dao = PaymentAccountModel.find_by_corp_number_and_corp_type_and_system( corp_number, corp_type, payment_system) payment_account = PaymentAccount() payment_account._dao = account_dao # pylint: disable=protected-access current_app.logger.debug('>find_payment_account') return payment_account