Skip to content

Commit

Permalink
Tests de non régression
Browse files Browse the repository at this point in the history
  • Loading branch information
bsongis committed Mar 1, 2017
1 parent 504f9e4 commit dd42f6e
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions tests/nonreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def AddFrere(self, inscrit, naissance):
inscrit.famille.freres_soeurs.append(result)
return result

def assertPrec2Equals(self, montant1, montant2):
self.assertEquals("%.2f" % montant1, "%.2f" % montant2)


class DatabaseTests(unittest.TestCase):
def test_creation(self):
Expand Down Expand Up @@ -225,10 +228,10 @@ def test_nospetitspouces(self):
inscription.reference[3].AddActivity(96, 180, 0, -1)
inscription.reference[4].AddActivity(96, 180, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 6), NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % cotisation.cotisation_mensuelle), 1001.95)
facture = Facture(inscrit, 2010, 9, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 1001.95)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 6), NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 1001.95)
facture = Facture(inscrit, 2010, 9, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 1001.95)

def test_microcosmos(self):
creche.mode_facturation = FACTURATION_PAJE
Expand All @@ -248,11 +251,11 @@ def test_microcosmos(self):
inscription.reference[4].AddActivity(96, 180, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2014, 10, 15), NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % cotisation.cotisation_mensuelle), 1516.67)
facture = Facture(inscrit, 2014, 10, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 831.72)
facture = Facture(inscrit, 2014, 11, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 1516.67)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 1516.67)
facture = Facture(inscrit, 2014, 10, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 831.72)
facture = Facture(inscrit, 2014, 11, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 1516.67)

def test_123_apetitspas(self):
creche.mode_facturation = FACTURATION_PAJE
Expand All @@ -279,16 +282,16 @@ def test_123_apetitspas(self):
self.AddJourneePresence(inscrit, datetime.date(2014, 9, 24), 144, 204)
self.AddJourneePresence(inscrit, datetime.date(2014, 9, 25), 144, 204)
self.AddJourneePresence(inscrit, datetime.date(2014, 9, 26), 144, 204)
cotisation = Cotisation(inscrit, datetime.date(2014, 10, 1), NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % cotisation.cotisation_mensuelle), 0)
cotisation = Cotisation(inscrit, datetime.date(2014, 10, 7), NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % cotisation.cotisation_mensuelle), 1054.69)
facture = Facture(inscrit, 2014, 9, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 268.75)
facture = Facture(inscrit, 2014, 10, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 1075.55)
facture = Facture(inscrit, 2014, 11, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 1054.69)
cotisation = Cotisation(inscrit, datetime.date(2014, 10, 1), NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 0)
cotisation = Cotisation(inscrit, datetime.date(2014, 10, 7), NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 1054.69)
facture = Facture(inscrit, 2014, 9, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 268.75)
facture = Facture(inscrit, 2014, 10, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 1075.55)
facture = Facture(inscrit, 2014, 11, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 1054.69)


class MarmousetsTests(GertrudeTestCase):
Expand Down Expand Up @@ -321,7 +324,7 @@ def test_1(self):
conge.debut, conge.fin = "01/02/2010", "20/02/2010"
inscrit.AddConge(conge)
cotisation = Cotisation(inscrit, datetime.date(2010, 1, 4), NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % cotisation.heures_semaine), 37.0)
self.assertPrec2Equals(cotisation.heures_semaine, 37.0)
self.assertEquals(cotisation.heures_periode, 971.0)
self.assertEquals(cotisation.nombre_factures, 7)

Expand Down Expand Up @@ -359,7 +362,7 @@ def test_24aout_31dec(self):
inscription.reference[4].AddActivity(102, 210, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 1))
self.assertEquals(float("%.2f" % cotisation.heures_semaine), 45.0)
self.assertPrec2Equals(cotisation.heures_semaine, 45.0)
self.assertEquals(cotisation.heures_mois, 196.0)
self.assertEquals(cotisation.nombre_factures, 4)

Expand All @@ -375,7 +378,7 @@ def test_9sept_31dec(self):
inscription.reference[4].AddActivity(102, 210, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 1))
self.assertEquals(float("%.2f" % cotisation.heures_semaine), 45.0)
self.assertPrec2Equals(cotisation.heures_semaine, 45.0)
self.assertEquals(cotisation.heures_mois, 183.0)
self.assertEquals(cotisation.nombre_factures, 4)

Expand All @@ -391,12 +394,12 @@ def test_1janv_31dec(self):
inscription.reference[4].AddActivity(102, 222, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 1))
self.assertEquals(float("%.2f" % cotisation.heures_semaine), 48.0)
self.assertPrec2Equals(cotisation.heures_semaine, 48.0)
self.assertEquals(cotisation.heures_mois, 199.0)
self.assertEquals(cotisation.nombre_factures, 11)
facture = Facture(inscrit, 2010, 9)
self.assertEquals(facture.total_contractualise, 248.75)
self.assertEquals(facture.total_facture, 248.75)
self.assertPrec2Equals(facture.total_contractualise, 248.75)
self.assertPrec2Equals(facture.total_facture, 248.75)

def test_heures_supp_sur_arrondi(self):
inscrit = self.AddInscrit()
Expand All @@ -419,7 +422,7 @@ def test_heures_supp_2_plages_horaires_sur_1_jour(self):
inscription.reference[2].AddActivity(102, 222, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2010, 9, 1))
# self.assertEquals(float("%.2f" % cotisation.heures_semaine), 5.0)
# self.assertPrec2Equals(cotisation.heures_semaine, 5.0)
self.AddJourneePresence(inscrit, datetime.date(2010, 9, 8), 88, 94)
facture = Facture(inscrit, 2010, 9)
self.assertEquals(facture.heures_supplementaires, 1.0)
Expand Down Expand Up @@ -473,14 +476,14 @@ def test_1janv_15fev(self):
inscription.reference[4].AddActivity(102, 222, 0, -1)
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2013, 1, 1))
self.assertEquals(float("%.2f" % cotisation.heures_semaine), 30.0)
self.assertEquals(float("%.2f" % cotisation.heures_mois), 128.18)
self.assertPrec2Equals(cotisation.heures_semaine, 30.0)
self.assertPrec2Equals(cotisation.heures_mois, 128.18)
self.assertEquals(cotisation.nombre_factures, 11)
self.assertEquals(float("%.2f" % cotisation.cotisation_mensuelle), 302.51)
facture = Facture(inscrit, 2013, 1, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 302.51)
facture = Facture(inscrit, 2013, 2, NO_ADDRESS|NO_PARENTS)
self.assertEquals(float("%.2f" % facture.total), 166.38+354)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 302.51)
facture = Facture(inscrit, 2013, 1, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 302.51)
facture = Facture(inscrit, 2013, 2, NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(facture.total, 166.38+43.64)


class LoupandisesTests(GertrudeTestCase):
Expand Down Expand Up @@ -509,7 +512,7 @@ def test_facture_periode_adaptation(self):
self.assertEquals(round(facture.heures_contractualisees, 2), 29.0)
self.assertEquals(round(facture.heures_supplementaires, 2), 6.0)
self.assertEquals(round(facture.heures_realisees, 2), 29.0)
self.assertEquals(facture.total, 36.25)
self.assertPrec2Equals(facture.total, 36.25)


class FacturationDebutMoisContratTests(GertrudeTestCase):
Expand Down Expand Up @@ -560,8 +563,8 @@ def test_temps_partiel(self):
self.assertEquals(facture.total, (4*4+12*10)*7.0)
facture = Facture(inscrit, 2011, 3)
self.assertEquals(facture.total, 1120.0)
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 14), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 15), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 14), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 15), 90, 189) # 8h15
facture = Facture(inscrit, 2011, 3)
self.assertEquals(facture.total, 1120.0 - (1.75 * 2) * 7.0)

Expand All @@ -570,19 +573,19 @@ def test_halte_garderie(self):
inscription = Inscription(inscrit, creation=False)
inscription.mode = MODE_HALTE_GARDERIE
inscription.debut = datetime.date(2010, 3, 1)
inscription.reference[0].AddActivity(93, 213, 0, -1) # 10h
inscription.reference[1].AddActivity(93, 213, 0, -1) # 10h
inscription.reference[2].AddActivity(93, 141, 0, -1) # 4h
inscription.reference[3].AddActivity(93, 213, 0, -1) # 10h
inscription.reference[0].AddActivity(93, 213, 0, -1) # 10h
inscription.reference[1].AddActivity(93, 213, 0, -1) # 10h
inscription.reference[2].AddActivity(93, 141, 0, -1) # 4h
inscription.reference[3].AddActivity(93, 213, 0, -1) # 10h
inscrit.inscriptions.append(inscription)
facture = Facture(inscrit, 2010, 3)
self.assertEquals(facture.total, (5*4+14*10)*9.5)
facture = Facture(inscrit, 2011, 2)
self.assertEquals(facture.total, 1292.0)
facture = Facture(inscrit, 2011, 3)
self.assertEquals(facture.total, 1520.0)
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 14), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 15), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 14), 90, 189) # 8h15
self.AddJourneePresence(inscrit, datetime.date(2011, 2, 15), 90, 189) # 8h15
facture = Facture(inscrit, 2011, 3)
self.assertEquals(facture.total, 1520.0 - (1.75 * 2) * 9.5)

Expand Down Expand Up @@ -732,7 +735,7 @@ def test_heures_supplementaires(self):
self.AddJourneePresence(inscrit, datetime.date(2011, 1, 26), 102, 204) # 8h30
self.AddJourneePresence(inscrit, datetime.date(2011, 1, 26), 102, 204) # 8h30
facture = Facture(inscrit, 2011, 1)
self.assertEquals("10.46", "%.2f" % facture.total)
self.assertPrec2Equals(facture.total, 10.46)


class BebebulTests(GertrudeTestCase):
Expand Down Expand Up @@ -765,7 +768,7 @@ def test_halte_garderie(self):
self.AddActivite(inscrit, datetime.date(2012, 10, 23), 105, 147, ABSENCE_NON_PREVENUE) # 3h30 absence non prevenue
self.AddActivite(inscrit, datetime.date(2012, 10, 25), 105, 147, 1) # 3h30 permanence
facture = Facture(inscrit, 2012, 10)
self.assertEquals("%.2f" % facture.total, "18.73")
self.assertPrec2Equals(facture.total, 18.73)

def test_adaptation_sur_presence_supplementaire(self):
inscrit = self.AddInscrit()
Expand All @@ -779,7 +782,7 @@ def test_adaptation_sur_presence_supplementaire(self):
self.AddJourneePresence(inscrit, datetime.date(2012, 10, 25), 105, 147) # 3h00
self.AddActivite(inscrit, datetime.date(2012, 10, 25), 105, 147, 1) # 3h00 adaptation
facture = Facture(inscrit, 2012, 10)
self.assertEquals("%.2f" % facture.total, "0.00")
self.assertPrec2Equals(facture.total, 0.00)


class RibambelleTests(GertrudeTestCase):
Expand Down Expand Up @@ -822,7 +825,7 @@ def test_adaptation(self):
inscription.reference[4].AddActivity(93, 213, 0, -1) # 10h
inscrit.inscriptions.append(inscription)
facture = Facture(inscrit, 2015, 10)
self.assertEquals(facture.total, 275 - 10*1.25)
self.assertPrec2Equals(facture.total, 275 - 10*1.25)


class LaCabaneAuxFamillesTests(GertrudeTestCase):
Expand Down Expand Up @@ -858,9 +861,9 @@ def test_arrivee_et_depart_en_cours_de_mois(self):
cotisation = Cotisation(inscrit, datetime.date(2015, 1, 20), NO_ADDRESS | NO_PARENTS)
self.assertEquals(cotisation.cotisation_mensuelle, 1468.75)
facture = Facture(inscrit, 2015, 1)
self.assertEquals(facture.total, 568.55)
self.assertPrec2Equals(facture.total, 568.55)
facture = Facture(inscrit, 2016, 1)
self.assertEquals(facture.total, 663.31)
self.assertPrec2Equals(facture.total, 663.31)


class OPagaioTests(GertrudeTestCase):
Expand All @@ -887,8 +890,8 @@ def test_adaptation_a_cheval_sur_2_mois(self):
inscrit.inscriptions.append(inscription)
cotisation = Cotisation(inscrit, datetime.date(2016, 9, 26), NO_ADDRESS | NO_PARENTS)
self.assertEquals(cotisation.cotisation_mensuelle, 0.0)
cotisation = Cotisation(inscrit, datetime.date(2016, 10, 3), NO_ADDRESS | NO_PARENTS | TRACES)
self.assertEquals("%.2f" % cotisation.cotisation_mensuelle, "538.48")
cotisation = Cotisation(inscrit, datetime.date(2016, 10, 3), NO_ADDRESS | NO_PARENTS)
self.assertPrec2Equals(cotisation.cotisation_mensuelle, 538.48)
facture = Facture(inscrit, 2016, 9)
self.assertEquals(facture.total, 0.0)
facture = Facture(inscrit, 2016, 10)
Expand Down

0 comments on commit dd42f6e

Please sign in to comment.