def test03_FixeCRD(self): cred = Credit(10000, 36, 0.02, Credit.taux_e.periodique, 0.0030, Credit.mode_e.fixe_CRD, 0, 0) start = 1 self.assertAlmostEqual(cred.get_capital_restant(start), 9731.43, 2) self.assertAlmostEqual(cred.get_amortissement(start), 268.57, 2) self.assertAlmostEqual(cred.get_interet(start), 16.67, 2) self.assertAlmostEqual(cred.get_mensualite_assurance(start), 2.50, 2) self.assertAlmostEqual(cred.get_mensualite_hors_assurance(start), 285.24, 2) self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2) start = 2 self.assertAlmostEqual(cred.get_capital_restant(start), 9462.34, 2) self.assertAlmostEqual(cred.get_amortissement(start), 269.09, 2) self.assertAlmostEqual(cred.get_interet(start), 16.22, 2) self.assertAlmostEqual(cred.get_mensualite_assurance(start), 2.43, 2) self.assertAlmostEqual(cred.get_mensualite_hors_assurance(start), 285.30, 2) self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2) start = 36 self.assertAlmostEqual(cred.get_amortissement(start), 287.19, 2) # 268.5706 self.assertAlmostEqual(cred.get_interet(start), 0.48, 2) self.assertAlmostEqual(cred.get_mensualite_assurance(start), 0.07, 2) self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2) self.assertAlmostEqual(cred.get_amortissement_total(), 10000, 2) self.assertAlmostEqual(cred.get_montant_interet_total(), 311.78, 2) self.assertAlmostEqual(cred.get_montant_assurance_total(), 46.77, 2) self.assertAlmostEqual(cred.get_mensualite_hors_assurance_total(), 10311.78, 2) self.assertAlmostEqual(cred.get_mensualite_avec_assurance_total(), 10358.54, 2)
def test04_DegressiveCRD(self): cred = Credit(81600, 240, 0.0115, Credit.taux_e.periodique, 0.0026, Credit.mode_e.degressive_CRD, 0, 0) self.assertAlmostEqual(cred.get_mensualite_hors_assurance(), 380.76, 2) self.assertAlmostEqual(cred.get_amortissement_total(), 81600, 2) self.assertAlmostEqual(cred.get_montant_interet_total(), 9782.33, 2) self.assertAlmostEqual(cred.get_montant_assurance_total(), 2211.66, 2) # 2234.76 self.assertAlmostEqual(cred.get_mensualite_hors_assurance_total(), 91382.33, 2) self.assertAlmostEqual(cred.get_mensualite_avec_assurance_total(), 93593.98, 2)
def test04_MensualiteAvecAssuranceTotal(self): cred = Credit(10000, 36, 0.02, Credit.taux_e.periodique, 0, Credit.mode_e.fixe_CI, 0, 0) self.assertAlmostEqual(cred.get_mensualite_avec_assurance_total(), 10311.33, 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)