class CompoundInterestTest(unittest.TestCase):
    def setUp(self):
        self.calc_1 = CompoundInterest(100, 20, 0.1)

    # Tests

    def test_part_one(self):
        get_part_one = self.calc_1.part_one_of_equation(
            self.calc_1.interest_rate)
        self.assertEqual(1.0083333333, get_part_one)

    def test_part_two(self):
        get_part_two = self.calc_1.part_two_of_equation(self.calc_1.years)
        self.assertEqual(240, get_part_two)

    # Should return 732.81 given 100 principal, 10 percent, 20 years
    def test_compound_interest_calc(self):
        get_compound_interest = self.calc_1.compound_interest_calc(
            self.calc_1.principal_amount, self.calc_1.years,
            self.calc_1.interest_rate)
        self.assertEqual(732.81, get_compound_interest)

    # Should return 181.94 given 100 principal, 6 percent, 10 years

    def test_compound_interest_calc__example_2(self):
        calc_2 = CompoundInterest(100, 10, 0.06)
        get_compound_interest = calc_2.compound_interest_calc(
            calc_2.principal_amount, calc_2.years, calc_2.interest_rate)
        self.assertEqual(181.94, get_compound_interest)

    # Should return 149,058.55 given 100000 principal, 5 percent, 8 years

    def test_compound_interest_calc__example_3(self):
        calc_3 = CompoundInterest(100000, 8, 0.05)
        get_compound_interest = calc_3.compound_interest_calc(
            calc_3.principal_amount, calc_3.years, calc_3.interest_rate)
        self.assertEqual(149058.55, get_compound_interest)

    # Should return 0.00 given 0 principal, 10 percent, 1 year

    def test_compound_interest_calc__example_4(self):
        calc_4 = CompoundInterest(0, 1, 0.1)
        get_compound_interest = calc_4.compound_interest_calc(
            calc_4.principal_amount, calc_4.years, calc_4.interest_rate)
        self.assertEqual(0.00, get_compound_interest)
コード例 #2
0
    def test_compound_interest__100_returns_732(self):
        investment = {
            "principal": 100,
            "rate": 0.1,
            "years": 20,
            "per_year": 12,
            "investment_per_month": 1000
        }

        self.assertEqual(732.81,
                         CompoundInterest.get_interest_total(investment))
コード例 #3
0
    def test_compound_interest__add_monthly_investment(self):
        investment = {
            "principal": 100,
            "rate": 0.05,
            "years": 10,
            "per_year": 12,
            "investment_per_month": 1000
        }

        self.assertEqual(
            156093.99,
            CompoundInterest.get_interest_total_deposits(investment))
コード例 #4
0
class CompoundInterestTest(unittest.TestCase):
    def setUp(self):
        self.compound_interest = CompoundInterest(100, 10, 20)

    # Tests

    def test_rate_divided_by_years(self):
        self.assertEqual(0.5, self.compound_interest.rate_divided_by_years())

    def test_principal_multiply_rate_and_years(self):
        self.assertEqual(
            150, self.compound_interest.principal_multiply_rate_and_years())

    def test_number_of_iterations_multiply_time_in_years(self):
        self.assertEqual(
            240,
            self.compound_interest.number_of_iterations_multiply_time_in_years(
            ))

    def test_compound_interest(self):
        self.assertEqual(
            732.81,
            (self.compound_interest.principal_multiply_rate_and_years)**
            self.compound_interest.number_of_iterations_multiply_time_in_years)
 def test_compound_interest_calc__example_4(self):
     calc_4 = CompoundInterest(0, 1, 0.1)
     get_compound_interest = calc_4.compound_interest_calc(
         calc_4.principal_amount, calc_4.years, calc_4.interest_rate)
     self.assertEqual(0.00, get_compound_interest)
コード例 #6
0
 def test_returns_compound_interest__scenario_4(self):
     compound_interest = CompoundInterest(0, 10, 1)
     self.assertEqual(0.00, compound_interest.calculate_final_investment())
コード例 #7
0
 def test_returns_compound_interest__scenario_2(self):
     compound_interest = CompoundInterest(100, 6, 10)
     self.assertEqual(181.94, compound_interest.calculate_final_investment())
コード例 #8
0
 def test_calculate_final_amount__116028_26_7_5__8_2006(self):
     compound_interest = CompoundInterest(116028.86, 7.5, 8)
     self.assertEqual(
         475442.59,
         compound_interest.calculate_final_amount_with_contributions(2006))
コード例 #9
0
 def test_calculate_final_amount__100_0_10(self):
     compound_interest = CompoundInterest(100, 5, 8)
     self.assertEqual(
         118380.16,
         compound_interest.calculate_final_amount_with_contributions(1000))
コード例 #10
0
 def test_calculate_final_amount__0_10_1(self):
     compound_interest = CompoundInterest(0, 10, 1)
     self.assertEqual(0.00, compound_interest.calculate_final_amount())
コード例 #11
0
 def test_calculate_final_amount__100_10_20(self):
     compound_interest = CompoundInterest(100, 10, 20)
     self.assertEqual(732.81, compound_interest.calculate_final_amount())
 def test_can_find_interest(self):
     compound_interest = CompoundInterest(100, 20, 0.1)
     self.assertEqual(0.1, compound_interest.i)
コード例 #13
0
 def setUp(self):
     self.compound_interest = CompoundInterest(100, 10, 20)
 def setUp(self):
     self.calc_1 = CompoundInterest(100, 20, 0.1)
コード例 #15
0
 def test_can_find_interest(self):
     compound_interest = CompoundInterest(100, 20, 10)
     self.assertEqual(10, compound_interest.interest)
 def test_returns_732_point81_given_100(self):
     compound_interest = CompoundInterest(100, 20, 0.1)
     self.assertEqual(732.81, compound_interest.amount_returned())
コード例 #17
0
 def test_output_of_one_plus_rate_over_times_compounded(self):
     compound_interest = CompoundInterest(100, 20, 10)
     self.assertEqual(round(1.83, 2),
                      round((1 + compound_interest.interest / 12), 2))
 def test_returns_181point94_point81_given_above(self):
     compound_interest = CompoundInterest(100, 10, 0.06)
     self.assertEqual(181.94, compound_interest.amount_returned())
コード例 #19
0
 def test_calculate_final_amount__100000_5_8(self):
     compound_interest = CompoundInterest(100000, 5, 8)
     self.assertEqual(149058.55, compound_interest.calculate_final_amount())
 def test_returns_149058point55_given_above(self):
     compound_interest = CompoundInterest(100000, 8, 0.05)
     self.assertEqual(149058.55, compound_interest.amount_returned())
コード例 #21
0
 def test_calculate_final_amount__100_0_10(self):
     compound_interest = CompoundInterest(100, 0, 10)
     self.assertEqual(100.00, compound_interest.calculate_final_amount())
 def test_returns_0_given_0_input(self):
     compound_interest = CompoundInterest(0, 1, 0.1)
     self.assertEqual(0, compound_interest.amount_returned())
コード例 #23
0
 def test_calculate_final_amount__100_5_10_1000(self):
     compound_interest = CompoundInterest(100, 5, 10)
     self.assertEqual(
         156093.99,
         compound_interest.calculate_final_amount_with_contributions(1000))
 def test_returns_100_given_100_input(self):
     compound_interest = CompoundInterest(100, 10, 0)
     self.assertEqual(100, compound_interest.amount_returned())
コード例 #25
0
 def test_calculate_final_amount__116028_26_7_5_12_2006(self):
     compound_interest = CompoundInterest(116028.86, 9, 12)
     self.assertEqual(
         718335.97,
         compound_interest.calculate_final_amount_with_contributions(1456))
コード例 #26
0
 def test_can_find_principle(self):
     compound_interest = CompoundInterest(100, 20, 10)
     self.assertEqual(100, compound_interest.principle)
コード例 #27
0
 def test_returns_compound_interest__scenario_3(self):
     compound_interest = CompoundInterest(100000, 5, 8)
     self.assertEqual(149,058.55, compound_interest.calculate_final_investment())
コード例 #28
0
 def test_can_find_years(self):
     compound_interest = CompoundInterest(100, 20, 10)
     self.assertEqual(20, compound_interest.years)
コード例 #29
0
 def test_returns_compound_interest__scenario_1(self):
     compound_interest = CompoundInterest(100, 10, 20)
     self.assertEqual(732.81, compound_interest.calculate_final_investment())
 def test_compound_interest_calc__example_3(self):
     calc_3 = CompoundInterest(100000, 8, 0.05)
     get_compound_interest = calc_3.compound_interest_calc(
         calc_3.principal_amount, calc_3.years, calc_3.interest_rate)
     self.assertEqual(149058.55, get_compound_interest)