def test_withdraw(self):
     customerTest = Customer("Testing Customer")
     customerTest.set_balance(2000)
     self.assertEqual(customerTest.withdraw(1000), 1000)
     self.assertEqual(customerTest.withdraw(100), 900)
     self.assertEqual(customerTest.withdraw(25), 875)
     self.assertEqual(customerTest.withdraw(175), 700)
Ejemplo n.º 2
0
 def test_withdraw_no_balance(self):
     '''
     Checks that an error is raised if the balance attribute is not set
     '''
     with self.assertRaises(AttributeError):
         this_account = Customer("Lynn")
         this_account.withdraw(15)
Ejemplo n.º 3
0
 def test_withdraw_empty(self):
     '''
     Checks that withdraw raises an error when no amount is provided
     '''
     with self.assertRaises(TypeError):
         this_account = Customer("James")
         this_account.set_balance()
         this_account.withdraw()
Ejemplo n.º 4
0
 def test_withdraw_insufficient_funds(self):
     '''
     Checks that the withdraw method will raise an exception when given a value less than the current balance
     '''
     this_balance = 250.53
     withdrawal = 999.99
     sample_account = Customer("Taylor")
     sample_account.set_balance(this_balance)
     with self.assertRaises(RuntimeError):
         sample_account.withdraw(withdrawal)
Ejemplo n.º 5
0
 def test_withdraw(self):
     '''
     Checks that withdraw, when given a proper amount value, functions correctly
     Checks both the modified balance within class and the returned value by withdraw
     '''
     this_balance = 13.7
     withdrawal = 8.5
     sample_account = Customer("Jessie")
     sample_account.set_balance(this_balance)
     self.assertEqual(sample_account.withdraw(withdrawal),
                      this_balance - withdrawal)
     self.assertEqual(sample_account.balance, this_balance - withdrawal)
Ejemplo n.º 6
0
    def test_withdraw(self):
        #set the testing initial balance to 10 dollars.
        Customer.set_balance(sample, balance=10.0)

        #draw 5 dollars out of the balance
        Customer.withdraw(sample, 5.0)
        self.assertEqual(sample.balance, 5.0)

        #draw 4.50 dollars out of the balance
        Customer.withdraw(sample, 4.50)
        self.assertEqual(sample.balance, 0.50)

        #try to draw balance over than the previous balance and make sure
        #the error display is correct too.
        with self.assertRaises(Exception) as content:
            Customer.withdraw(sample, 1.00)

        #it has to be same display as the given error in sample_account.py
        self.assertTrue(
            'Amount greater than available balance.' in content.exception)