def test_activate_bcol_change_to_pad(session):
    """Test Activate account."""
    # Create a pending account first, then call the job
    account = factory_create_pad_account(
        auth_account_id='1', payment_method=PaymentMethod.DRAWDOWN.value)
    CreateAccountTask.create_accounts()
    account = PaymentAccount.find_by_id(account.id)
    cfs_account: CfsAccount = CfsAccount.find_effective_by_account_id(
        account.id)
    assert cfs_account.status == CfsAccountStatus.PENDING_PAD_ACTIVATION.value, 'Created account has pending pad status'
    assert account.payment_method == PaymentMethod.DRAWDOWN.value

    ActivatePadAccountTask.activate_pad_accounts()
    cfs_account: CfsAccount = CfsAccount.find_effective_by_account_id(
        account.id)
    assert cfs_account.status == CfsAccountStatus.PENDING_PAD_ACTIVATION.value, \
        'Same day Job runs and shouldnt change anything.'
    account = PaymentAccount.find_by_id(account.id)
    assert account.payment_method == PaymentMethod.DRAWDOWN.value

    time_delay = current_app.config['PAD_CONFIRMATION_PERIOD_IN_DAYS']
    with freeze_time(datetime.today() + timedelta(days=time_delay, minutes=1)):
        ActivatePadAccountTask.activate_pad_accounts()
        assert cfs_account.status == CfsAccountStatus.ACTIVE.value, \
            'After the confirmation period is over , status should be active'
        account = PaymentAccount.find_by_id(account.id)
        assert account.payment_method == PaymentMethod.PAD.value
Ejemplo n.º 2
0
def run(job_name):
    from tasks.cfs_create_account_task import CreateAccountTask
    from tasks.cfs_create_invoice_task import CreateInvoiceTask
    from tasks.distribution_task import DistributionTask
    from tasks.stale_payment_task import StalePaymentTask
    from tasks.statement_notification_task import StatementNotificationTask
    from tasks.statement_task import StatementTask
    from tasks.activate_pad_account_task import ActivatePadAccountTask
    from tasks.ejv_partner_distribution_task import EjvPartnerDistributionTask
    from tasks.unpaid_invoice_notify_task import UnpaidInvoiceNotifyTask
    from tasks.ejv_payment_task import EjvPaymentTask

    application = create_app()

    application.app_context().push()
    if job_name == 'UPDATE_GL_CODE':
        DistributionTask.update_failed_distributions()
        application.logger.info(f'<<<< Completed Updating GL Codes >>>>')
    elif job_name == 'GENERATE_STATEMENTS':
        StatementTask.generate_statements()
        application.logger.info(f'<<<< Completed Generating Statements >>>>')
    elif job_name == 'SEND_NOTIFICATIONS':
        StatementNotificationTask.send_notifications()
        application.logger.info(f'<<<< Completed Sending notifications >>>>')
    elif job_name == 'UPDATE_STALE_PAYMENTS':
        StalePaymentTask.update_stale_payments()
        application.logger.info(f'<<<< Completed Updating stale payments >>>>')
    elif job_name == 'CREATE_CFS_ACCOUNTS':
        CreateAccountTask.create_accounts()
        application.logger.info(f'<<<< Completed creating cfs accounts >>>>')
    elif job_name == 'CREATE_INVOICES':
        CreateInvoiceTask.create_invoices()
        application.logger.info(f'<<<< Completed creating cfs invoices >>>>')
    elif job_name == 'ACTIVATE_PAD_ACCOUNTS':
        ActivatePadAccountTask.activate_pad_accounts()
        application.logger.info(f'<<<< Completed Activating PAD accounts >>>>')
    elif job_name == 'EJV_PARTNER':
        EjvPartnerDistributionTask.create_ejv_file()
        application.logger.info(f'<<<< Completed Creating EJV File for partner distribution>>>>')
    elif job_name == 'NOTIFY_UNPAID_INVOICE_OB':
        UnpaidInvoiceNotifyTask.notify_unpaid_invoices()
        application.logger.info(f'<<<< Completed Sending notification for OB invoices >>>>')
    elif job_name == 'EJV_PAYMENT':
        EjvPaymentTask.create_ejv_file()
        application.logger.info(f'<<<< Completed running EJV payment >>>>')

    else:
        application.logger.debug('No valid args passed.Exiting job without running any ***************')
def test_activate_pad_accounts(session):
    """Test Activate PAD Accounts."""
    ActivatePadAccountTask.activate_pad_accounts()
    assert True