Exemplo n.º 1
0
class TestAccount(unittest.TestCase):
    def setUp(self):
        self.bank = Bank()
        self.account_1 = Account(001, 50)
        self.account_2 = Account(002, 100)

    def test_bank_is_initially_empty(self):

        self.assertEqual({}, self.bank.accounts)
        self.assertEqual(len(self.bank.accounts), 0)

    def test_add_account(self):
        # bank = Bank()

        self.bank.add_account(self.account_1)
        self.bank.add_account(self.account_2)

        self.assertEqual(len(self.bank.accounts), 2)

    def test_get_account_balance(self):
        # bank = Bank()

        # self.account_1 = Account(001, 50)

        self.bank.add_account(self.account_1)

        self.assertEqual(self.bank.get_account_balance(001), 50)
Exemplo n.º 2
0
    def test_get_account_balance(self):
        bank = Bank()

        account_1 = Account(001, 50)

        bank.add_account(account_1)

        self.assertEqual(bank.get_account_balance(001), 50)
Exemplo n.º 3
0
    def test_get_account_balance(self):
        bank = Bank()

        account_1 = Account("001", 50)
        bank.add_account(account_1)

        self.assertEqual(bank.get_account_balance("001"), 50)
Exemplo n.º 4
0
    def test_get_account_balance(self):
        """Test get account balance """
        bank = Bank()

        account_1 = Account('001', 50)
        bank.add_account(account_1)

        self.assertEqual(bank.get_account_balance('001'), 50)
Exemplo n.º 5
0
    def test_bank_allow_withdraw(self):
        bank = Bank()
        account_test = Account("003", 100)

        bank.add_account(account_test)
        bank.withdraw_amount("003",5)
     
        self.assertEqual(int(bank.get_account_balance("003")) - 5, 95)
Exemplo n.º 6
0
class BankTest(unittest.TestCase):

    def setUp(self):
        self.bank = Bank()

    def test_bank_is_initially_empty(self):
        self.assertEqual({}, self.bank.accounts)
        self.assertEqual(len(self.bank.accounts),0)
    
    def test_add_account(self):

        account_1 = Account("001",50)
        account_2 = Account("002", 100)
        
        self.bank.add_account(account_1)
        self.bank.add_account(account_2)
        
        self.assertEqual(len(self.bank.accounts),2)
        #self.assertEqual(len(self.bank.accounts),500)

    def test_get_account_balance(self):
        account_1 = Account("001", 50)

        self.bank.add_account(account_1)

        self.assertEqual(self.bank.get_account_balance("001"), 50)

    def test_withdraw_from_account(self):

        account_2 = Account("002", 100)

        self.bank.add_account(account_2)

        self.assertEqual(self.bank.withdraw_from("002", 50), 50)
        
    def test_withdraw_from_method_raises_typeerror_if_not_ints(self):
        
        account_2 = Account("002", 100)
        
        self.bank.add_account(account_2)

        self.assertRaises(TypeError, self.bank.withdraw_from, "002", "50")



    def test_withdraw_from_method_insufficient_amount(self):

        account_2 = Account("002", 100)

        self.bank.add_account(account_2)

        self.assertEqual(self.bank.withdraw_from("002", 120), 'Insufficient Funds') 
Exemplo n.º 7
0
class TestBank(unittest.TestCase):

    def setUp(self):
        self.bank = Bank()

    def test_bank_is_initially_empty(self):
        self.assertEquals({}, self.bank.accounts)
        self.assertEquals(len(self.bank.accounts), 0)

    def test_add_account(self):
        account_1 = Account("001", 50)
        self.bank.add_account(account_1)
        self.assertEquals(self.bank.get_account_balance("001"), 50)
Exemplo n.º 8
0
 def test_account_withdraw(self):
     bank = Bank()
     account_1 = Account(001, 50)
     bank.add_account(account_1)
     bank.account_withdraw(001,30)
     self.assertEqual(bank.get_account_balance(001), 20)