def test_get_net_turnover(): """Test.""" person1 = Person("Ellina", "Gedrojets", 18) bank1 = Bank("Swed") acc1 = Account(200, person1, bank1) acc1.deposit(10) acc1.withdraw(50) assert acc1.get_net_turnover(datetime.date.today(), datetime.date.today()) == -40
def test_debit_turnover(): """Test get_debit_turnover method in Account class.""" p1 = Person('Jack', 'Jackson', 19) b1 = Bank('NotSwedBank') p1_acc = Account(100, p1, b1) expected = 600 p1_acc.deposit(500) p1_acc.deposit(100) p1_acc.withdraw(150) assert p1_acc.get_debit_turnover(datetime.date.today(), datetime.date.today()) == expected
def test_deposit(): """Test deposit method in Account class.""" p1 = Person('Jack', 'Jackson', 19) p2 = Person('Anna', 'Dark', 194) b1 = Bank('NotSwedBank') b2 = Bank('CoolerThanLHV') p1_acc = Account(100, p1, b1) p2_acc = Account(25, p2, b2) with pytest.raises(TransactionError): assert p1_acc.deposit(-15) p1_acc.deposit(15) tr1 = Transaction(15, datetime.date.today(), p1_acc, p1_acc, True) assert str(p1_acc.transactions[0]) == str(tr1) p2_acc.deposit(20, is_from_atm=False) assert p2_acc.balance == 45
def test_deposit(): """Test deposit.""" person1 = Person("Ellina", "Gedrojets", 18) person2 = Person("Robert", "Soidla", 19) bank1 = Bank("Swed") bank2 = Bank("LHV") acc1 = Account(20, person1, bank1) acc2 = Account(100, person2, bank2) with pytest.raises(TransactionError): assert acc1.deposit(-10) acc2.deposit(2, True) tr1 = Transaction(2, datetime.date.today(), acc2, acc2, True) assert str(acc2.transactions[0]) == str(tr1) acc1.deposit(10, False) assert acc1.balance == 30
def test_net_turnover(): """Test get_net_turnover method in Account class.""" p1 = Person('Jack', 'Jackson', 19) b1 = Bank('NotSwedBank') p1_acc = Account(100, p1, b1) p1_acc = Account(100, p1, b1) expected1 = 450 p1_acc.deposit(500) p1_acc.withdraw(50) assert p1_acc.get_net_turnover(datetime.date.today(), datetime.date.today()) == expected1 p2 = Person('Anna', 'Dark', 194) p2_acc = Account(200, p2, b1) expected2 = -50 p2_acc.deposit(100) p2_acc.withdraw(150) assert p2_acc.get_net_turnover(datetime.date.today(), datetime.date.today()) == expected2
if acc in users: print("User already Exists") else: user = Account(acc, first, last, balance) users[acc] = user else: print("\nAccount Number cannot be zero\n") elif option == 2: accNum = int(input("Enter your account number\n")) amt = float(input("Enter amount you want to deposit\n")) if accNum in users: if amt > 0: user.deposit(amt) print(user.getBalance()) else: print("The amount is too small to be Withdrawn") else: print("User Account doesnot exist") elif option == 3: accNum = int(input("Enter your account number\n")) amt = float(input("Enter amount you want to withdraw\n")) if accNum in users: if amt <= user.getBalance(): user.withdraw(amt)