Beispiel #1
0
def test_add_money():
    """
    Add minimum of funds to wallet
    """
    test_wallet = Wallet(10)
    test_wallet.add_money(1)
    assert test_wallet.balance() == 11
Beispiel #2
0
def test_make_wrong_add_money_parameter():
    """
    Payment with negative amount
    """
    test_wallet = Wallet(10)
    test_wallet.add_money(-1)
    assert test_wallet.balance() == 10
Beispiel #3
0
def test_make_loop_back_payment():
    """
    Money transfer from wallet to the same wallet
    """
    test_wallet = Wallet(10)
    test_wallet.make_payment(test_wallet, 20)
    assert test_wallet.balance() == 10
Beispiel #4
0
def test_make_loop_payment(count):
    """
    Loop of transactions
    """
    test_wallet = Wallet(10)
    for i in range(count):
        test_wallet.add_money(1)
    assert test_wallet.balance() == 10 + count
Beispiel #5
0
def test_make_wrong_payment_amount():
    """
    Wrong argument for payment method
    """
    first_wallet = Wallet(10)
    second_wallet = Wallet(2)
    try:
        second_wallet.make_payment(first_wallet, 'asd')

    except TypeError:
        assert False
    finally:
        assert False
Beispiel #6
0
def test_cross_params(wallet_a, wallet_b):
    """
    Cross-test of payment method for several test data sets
    """
    first_wallet = Wallet(wallet_a)
    second_wallet = Wallet(wallet_b)
    first_wallet.make_payment(second_wallet, wallet_b)
    assert first_wallet.balance() == (wallet_a - wallet_b)
    assert second_wallet.balance() == (wallet_b + wallet_b)
Beispiel #7
0
def test_make_payment_more_that_wallet():
    """
    Wrong payment value more that wallet balance
    """
    first_wallet = Wallet(10)
    second_wallet = Wallet(2)
    second_wallet.make_payment(first_wallet, 5)
    assert second_wallet.balance() >= 0
Beispiel #8
0
def test_make_payment():
    """
    Make simple transaction
    """
    first_wallet = Wallet(10)
    second_wallet = Wallet(2)
    second_wallet.make_payment(first_wallet, 2)
    assert second_wallet.balance() == 0
Beispiel #9
0
def test_make_some_transfer(wallet_a, amount, wallet_b, expected):
    """
    Method for transfer money tests
    First wallet amount
    Transfer amount
    Second wallet initial value
    Expected second wallet amount
    """
    first_wallet = Wallet(wallet_a)
    second_wallet = Wallet(wallet_b)
    first_wallet.make_payment(second_wallet, amount)
    assert second_wallet.balance() == expected
def test_setting_initial_amount():
    wallet = Wallet(100)
    assert wallet.balance == 100
def test_default_initial_amount():
    wallet = Wallet()
    assert wallet.balance == 0
def test_wallet_spend_cash():
    wallet = Wallet(20)
    wallet.spend_cash(10)
    assert wallet.balance == 10
def test_wallet_add_cash():
    wallet = Wallet(10)
    wallet.add_cash(90)
    assert wallet.balance == 100
Beispiel #14
0
def test_make_wallet():
    """
    Simple wallet initialization
    """
    test_wallet = Wallet(10)
    assert test_wallet.balance() == 10
Beispiel #15
0
def test_make_not_empty_wallet():
    """
    Make wallet by negative of funds amount
    """
    test_wallet = Wallet(-1)
    assert test_wallet.balance() == 0
Beispiel #16
0
def test_make_empty_wallet():
    """
    Empty wallet test
    """
    test_wallet = Wallet(0)
    assert test_wallet.balance() == 0