Esempio n. 1
0
def test_create_account_success():
    account_num = 1234567
    account_name = "Alex"

    expected_transaction = Transaction("NEW", account_num, "000", "0000000", account_name).create_transaction_line()
    transaction = createAccount(account_num, account_name).create_transaction_line()

    assert transaction == expected_transaction
Esempio n. 2
0
def deposit(account_num, amount, mode, deposits):
    new_daily_deposits = validateDepositAmount(account_num, amount, mode,
                                               deposits)
    if (new_daily_deposits == False):
        print("Invalid deposit amount")
        return False, deposits
    else:
        return Transaction("DEP", account_num, amount, "0000000",
                           '***'), deposits
Esempio n. 3
0
def test_create_account_success():
    master_accounts_list = {}
    assert master_accounts_list == {}

    transaction = Transaction('NEW', 1234567, 100, 0000000, 'testaccount')
    master_accounts_list = backendController(transaction, master_accounts_list)

    assert master_accounts_list[1234567].balance == 0
    assert master_accounts_list[1234567].account_name == 'testaccount'
    assert master_accounts_list[1234567].account_number == 1234567
Esempio n. 4
0
def transfer(mode, account_num1, account_num2, amount, transfers):
    # transaction object
    new_daily_transfers = validateTransferAmount(amount, int(account_num1),
                                                 mode, transfers)
    if (new_daily_transfers == False):
        print("Invalid transfer amount")
        return False, transfers
    else:
        return Transaction("XFR", account_num2, amount, account_num1,
                           '***'), transfers
Esempio n. 5
0
def withdraw(account_num, amount, mode, withdrawals):
    # updated this function to match deposit above
    new_daily_withdrawals = validateWithdrawAmount(account_num, amount, mode,
                                                   withdrawals)
    if (new_daily_withdrawals == False):
        print("Invalid withdrawal amount")
        return False, withdrawals
    else:
        return Transaction("WDR", account_num, amount, "0000000",
                           '***'), withdrawals
    '''
Esempio n. 6
0
def test_withdraw_success_agent():
    daily_withdrawals = {1234567: 0}
    account_num = 1234567
    amount = 10000
    #agent mode
    mode = 1

    transaction, new_daily_withdrawals = withdraw(account_num, amount, mode,
                                                  daily_withdrawals)
    expected_transaction = Transaction("WDR", account_num, amount, "0000000",
                                       '***').create_transaction_line()
    transaction = transaction.create_transaction_line()
    daily_withdrawals[account_num] = amount

    assert transaction == expected_transaction
    assert daily_withdrawals == new_daily_withdrawals
Esempio n. 7
0
def test_deposit_success_agent():
    daily_deposits = {1234567: 0}
    account_num = 1234567
    amount = 10000
    # Agent mode
    mode = 1

    # Call our deposit function
    transaction, new_daily_deposits = deposit(account_num, amount, mode,
                                              daily_deposits)
    # Create an expected Transaction
    expected_transaction = Transaction("DEP", account_num, amount, "0000000",
                                       '***').create_transaction_line()
    # We will compare the strings
    transaction = transaction.create_transaction_line()
    # update our initial daily_deposits dict to be our expected dict
    daily_deposits[account_num] = amount

    assert transaction == expected_transaction
    assert daily_deposits == new_daily_deposits
Esempio n. 8
0
def test_transfer_success_agent():
    daily_transfer = {1234567: 0}
    account_num_from = 1234567
    account_num_to = 1122334
    amount = 10
    # Agent mode
    mode = 1

    # Call our deposit function
    transaction, new_daily_transfers = transfer(mode, account_num_from,
                                                account_num_to, amount,
                                                daily_transfer)
    # Create an expected Transaction
    expected_transaction = Transaction("XFR", account_num_to, amount,
                                       account_num_from,
                                       '***').create_transaction_line()
    # We will compare the strings
    transaction = transaction.create_transaction_line()
    # update our initial daily_deposits dict to be our expected dict
    daily_transfer[account_num_from] = amount

    assert transaction == expected_transaction
    assert daily_transfer == new_daily_transfers
Esempio n. 9
0
def test_withdraw_valid_amount():
    master_accounts_list = {}
    master_accounts_list[1234567] = MasterAccount(1234567, 1000, 'testaccount')
    transaction = Transaction('WDR', 1234567, 100, 0000000, '***')
    backendController(transaction, master_accounts_list)
    assert master_accounts_list[1234567].balance == 900