diff --git a/attributs_tests.py b/attributs_tests.py index 304f89a..10bc97e 100644 --- a/attributs_tests.py +++ b/attributs_tests.py @@ -50,8 +50,43 @@ class nomTest(LDAPTest): attrify_light(u"Space Man", "nom") self.assertRaises(Exception, attrify_light, "Stringman", "nom") self.assertRaises(Exception, attrify_light, u" Spaceman", "nom") + +class prenomTest(LDAPTest): + """Tests sur l'attribut prenom""" + tests = ["acceptPrenom"] + def acceptPrenom(self): + """Accepte les prénoms de la liste définie""" + attrify_light(u"Nicolas", "prenom") + attrify_light(u"Gérard", "prenom") + attrify_light(u"John-Éric", "prenom") + attrify_light(u"Charles Jean", "prenom") + self.assertRaises(Exception, attrify_light, "String", "prenom") + self.assertRaises(Exception, attrify_light, u" Space", "prenom") + +class telTest(LDAPTest): + """Tests sur l'attribut tel""" + tests = ["acceptTel", "normalizeTel"] + def acceptTel(self): + """Accepte les numéros de la liste définie""" + attrify_light(u"01 23 45 67 89", "tel") + attrify_light(u"0000000000", "tel") + attrify_light(u"00 33 1 23 45 67 89", "tel") + attrify_light(u"+42 (0) 1 23456789", "tel") + self.assertRaises(Exception, attrify_light, "", "tel") + self.assertRaises(Exception, attrify_light, u"caracteres?!", "nom") + + def normalizeTel(self): + """Normalise correctement les numéros de téléphone""" + attr = attrify_light(u"01 23 45 67 89", "tel") + self.assertEqual(str(attr), "0123456789") + attr = attrify_light(u"0000000000", "tel") + self.assertEqual(str(attr), "0000000000") + attr = attrify_light(u"00 33 1 23 45 67 89", "tel") + self.assertEqual(str(attr), "0033123456789") + attr = attrify_light(u"+42 (0) 1 23456789", "tel") + self.assertEqual(str(attr), "0042123456789") + - def auto_suite(testcase): """Suite de tests 'automatique'""" suite = unittest.TestSuite()