def test07_CoutTotal(self): cred = Credit(10000, 36, 0.02, Credit.taux_e.periodique, 0.0030, Credit.mode_e.fixe_CI, 100, 200) self.assertAlmostEqual(cred.get_cout_total(), 701.33, 2) cred = Credit(136000, 240, 0.018, Credit.taux_e.periodique, 0.0036, Credit.mode_e.fixe_CI, 40, 60) self.assertAlmostEqual(cred.get_cout_total(), 35938.52, 2)
def testExemple2(self): ''' www.lacentraledefinancement.fr ''' credit = Credit(10000, 60, 0.01, Credit.taux_e.periodique, 0.0020, Credit.mode_e.fixe_CRD, 0, 0) # self.assertAlmostEqual(credit.get_montant_interet_total(), 308, 0) # self.assertAlmostEqual(credit.get_montant_assurance_total(), 100, 0) self.assertAlmostEqual(credit.get_cout_total(), 308, 2) mois = 1 self.assertAlmostEqual(credit.get_capital_restant(mois), 9838.20, 2) self.assertAlmostEqual(credit.get_amortissement(mois), 161.80, 2) self.assertAlmostEqual(credit.get_interet(mois), 8.33, 2) self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.67, 2) self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.13, 2) self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2) mois = 2 self.assertAlmostEqual(credit.get_capital_restant(mois), 9676.24, 2) self.assertAlmostEqual(credit.get_amortissement(mois), 161.96, 2) self.assertAlmostEqual(credit.get_interet(mois), 8.20, 2) self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.64, 2) self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.16, 2) self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2) mois = 13 self.assertAlmostEqual(credit.get_capital_restant(mois), 7883.93, 2) self.assertAlmostEqual(credit.get_amortissement(mois), 163.75, 2) self.assertAlmostEqual(credit.get_interet(mois), 6.71, 2) self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.34, 2) self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.46, 2) self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2)
class TestCredit_FixeCRD(unittest.TestCase): def setUp(self): self.credit = Credit(50000, 240, 0.0115, Credit.taux_e.periodique, 0.0026, Credit.mode_e.fixe_CRD, 0, 0) def testTotal(self): self.assertAlmostEqual(self.credit.get_montant_interet_total(), 6043.69, 2) self.assertAlmostEqual(self.credit.get_montant_assurance_total(), 1366.40, 2) self.assertAlmostEqual(self.credit.get_amortissement_total(), 50000, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance_total(), 56043.69, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance_total(), 57410.09, 2) self.assertAlmostEqual(self.credit.get_cout_total(), 7410.09, 2) def testRangeNone(self): self.assertAlmostEqual(self.credit.get_amortissement(), 180.46, 2) self.assertAlmostEqual(self.credit.get_interet(), 47.92, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(), 10.83, 2) self.assertAlmostEqual(self.credit.get_mensualite_hors_assurance(), 228.38, 2) self.assertAlmostEqual(self.credit.get_mensualite_avec_assurance(), 239.21, 2) def testRange1(self): self.assertAlmostEqual(self.credit.get_amortissement(1), 180.46, 2) self.assertAlmostEqual(self.credit.get_interet(1), 47.92, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(1), 10.83, 2) self.assertAlmostEqual(self.credit.get_mensualite_hors_assurance(1), 228.38, 2) self.assertAlmostEqual(self.credit.get_mensualite_avec_assurance(1), 239.21, 2) def testRange2(self): start = 2 self.assertAlmostEqual(self.credit.get_amortissement(start), 180.67, 2) self.assertAlmostEqual(self.credit.get_interet(start), 47.74, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(start), 10.79, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start), 228.41, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start), 239.21, 2) def testRange12(self): start = 12 self.assertAlmostEqual(self.credit.get_amortissement(start), 182.80, 2) self.assertAlmostEqual(self.credit.get_interet(start), 46, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(start), 10.40, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start), 228.81, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start), 239.21, 2) def testRange228(self): start = 228 self.assertAlmostEqual(self.credit.get_amortissement(start), 235.58, 2) self.assertAlmostEqual(self.credit.get_interet(start), 2.96, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(start), 0.67, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start), 238.54, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start), 239.21, 2) def testRange240(self): start = 240 self.assertAlmostEqual(self.credit.get_amortissement(start), 238.93, 2) self.assertAlmostEqual(self.credit.get_interet(start), 0.23, 2) self.assertAlmostEqual(self.credit.get_mensualite_assurance(start), 0.05, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start), 239.16, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start), 239.21, 2) def testRange1_2(self): start = 1 stop = 2 self.assertAlmostEqual(self.credit.get_amortissement(start, stop), 180.46 + 180.67, 2) self.assertAlmostEqual(self.credit.get_interet(start, stop), 47.92 + 47.74, 2) self.assertAlmostEqual( self.credit.get_mensualite_assurance(start, stop), 10.83 + 10.80, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start, stop), 228.38 + 228.41, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start, stop), 239.21 + 239.21, 2) def testRange1_240(self): start = 1 stop = 240 self.assertAlmostEqual(self.credit.get_amortissement(start, stop), 50000, 2) self.assertAlmostEqual(self.credit.get_interet(start, stop), 6043.69, 2) self.assertAlmostEqual( self.credit.get_mensualite_assurance(start, stop), 1366.40, 2) self.assertAlmostEqual( self.credit.get_mensualite_hors_assurance(start, stop), 56043.69, 2) self.assertAlmostEqual( self.credit.get_mensualite_avec_assurance(start, stop), 57410.09, 2)