class BankAccountTest(unittest.TestCase):
    def setUp(self):
        self.account = BankAccount("Rado", 0, "$")

    def test_can_create_bank_account(self):
        self.assertTrue(isinstance(self.account, BankAccount))

    def test_get_name(self):
        self.assertEqual(self.account.holder(), "Rado")

    def test_initial_zero_balance(self):
        self.assertEqual(self.account.balance(), 0)

    def test_negative_initial_amount(self):
        with self.assertRaises(ValueError):
            BankAccount("Test", -100, "$")

    def test_deposit_in_empty_account(self):
        self.account.deposit(500)
        self.assertEqual(self.account.balance(), 500)

    def test_deposit_in_not_empty_account(self):
        account = BankAccount("Ivo", 1000, "$")
        account.deposit(500)
        self.assertEqual(account.balance(), 1500)

    def test_deposit_negative_amount(self):
        with self.assertRaises(ValueError):
            self.account.deposit(-100)

    def test_withdraw_from_not_empty_account(self):
        self.account.deposit(100)
        result = self.account.withdraw(50)

        self.assertTrue(result)
        self.assertEqual(self.account.balance(), 50)

    def test_withdraw_from_empty_account(self):
        result = self.account.withdraw(50)

        self.assertIsNotNone(result)
        self.assertFalse(result)

    def test_history(self):
        account = BankAccount("Test", 0, "$")
        account.deposit(20)
        account.balance()
        int(account)
        expected = ["Account was created", "Deposited 20$",
                    "Balance check -> 20$", "__int__ check -> 20$"]

        self.assertEqual(account.history(), expected)

    def test_transfer(self):
        account1 = BankAccount("Rado", 100, "$")
        account2 = BankAccount("Ivo", 0, "$")
        result = account1.transfer_to(account2, 50)
        self.assertTrue(result)
class BankAccountTest(unittest.TestCase):
    def setUp(self):
        self.account = BankAccount("Rado", 0, "$")

    def test_can_create_bank_account(self):
        self.assertTrue(isinstance(self.account, BankAccount))

    def test_get_name(self):
        self.assertEqual(self.account.holder(), "Rado")

    def test_initial_zero_balance(self):
        self.assertEqual(self.account.balance(), 0)

    def test_negative_initial_amount(self):
        with self.assertRaises(ValueError):
            BankAccount("Test", -100, "$")

    def test_deposit_in_empty_account(self):
        self.account.deposit(500)
        self.assertEqual(self.account.balance(), 500)

    def test_deposit_in_not_empty_account(self):
        account = BankAccount("Ivo", 1000, "$")
        account.deposit(500)
        self.assertEqual(account.balance(), 1500)

    def test_deposit_negative_amount(self):
        with self.assertRaises(ValueError):
            self.account.deposit(-100)

    def test_withdraw_from_not_empty_account(self):
        self.account.deposit(100)
        result = self.account.withdraw(50)

        self.assertTrue(result)
        self.assertEqual(self.account.balance(), 50)

    def test_withdraw_from_empty_account(self):
        result = self.account.withdraw(50)

        self.assertIsNotNone(result)
        self.assertFalse(result)

    def test_history(self):
        account = BankAccount("Test", 0, "$")
        account.deposit(20)
        account.balance()
        int(account)
        expected = ["Account was created", "Deposited 20$",
                    "Balance check -> 20$", "__int__ check -> 20$"]

        self.assertEqual(account.history(), expected)
示例#3
0
    def test_get_name_when_name_not_string_but_object(self):
        name = ("Radoslav", "Georgiev")
        account = BankAccount(name, 0, "%")

        self.assertEqual(str(name), account.holder())
示例#4
0
    def test_get_name(self):
        name = "Test"
        account = BankAccount(name, 0, "$")

        self.assertEqual(account.holder(), name)
示例#5
0
 def test_holder(self):
     account = BankAccount("Tester", 0, "$")
     self.assertEqual(account.holder(), "Tester")
示例#6
0
    def test_get_name_when_name_not_string_but_object(self):
        name = ("Radoslav", "Georgiev")
        account = BankAccount(name, 0, "%")

        self.assertEqual(str(name), account.holder())
示例#7
0
    def test_get_name(self):
        name = "Test"
        account = BankAccount(name, 0, "$")

        self.assertEqual(account.holder(), name)