Amended wallet.py code


# code source: https://semaphoreci.com/community/tutorials/testing-python-applications-with-pytest

# ***TASK: Amend the code so that the tests fail.***

class InsufficientAmount(Exception):
    pass

class Wallet(object):

    def __init__(self, initial_amount=0):
        self.balance = initial_amount + 5 # '+ 5' added so that test_default_initial_amount() and
                                          # test_setting_initial_amount() tests fail.

    def spend_cash(self, amount):
        if self.balance > amount: # '<' changed to '>' so that test_wallet_spend_cash() and
                                  # test_wallet_spend_cash_raises_exception_on_insufficient_amount()
                                  # tests fail.
            raise InsufficientAmount('Not enough available to spend {}'.format(amount))
        self.balance -= amount

    def add_cash(self, amount):
        self.balance -= amount # '+=' changed to '-=' so that test_wallet_add_cash() test fails.