From 982f356470bd956a566eda392678c54ddc356bf5 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Sun, 1 Dec 2024 20:29:13 +0700 Subject: [PATCH] Create test_loans.py --- tests/test_loans.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_loans.py diff --git a/tests/test_loans.py b/tests/test_loans.py new file mode 100644 index 000000000..4bff072b2 --- /dev/null +++ b/tests/test_loans.py @@ -0,0 +1,23 @@ +import unittest +from loans import LoanManager # Assuming you have a LoanManager class + +class TestLoanManager(unittest.TestCase): + def setUp(self): + self.loan_manager = LoanManager() + + def test_create_loan(self): + loan = self.loan_manager.create_loan("Alice", 1000, 5) + self.assertIsNotNone(loan) + self.assertEqual(loan.amount, 1000) + + def test_loan_repayment(self): + loan = self.loan_manager.create_loan("Bob", 500, 3) + self.loan_manager.repay_loan(loan.id, 200) + self.assertEqual(loan.remaining_balance, 300) + + def test_loan_not_found(self): + with self.assertRaises(ValueError): + self.loan_manager.repay_loan("nonexistent_id", 100) + +if __name__ == "__main__": + unittest.main()