[attributs_tests] Prénom et Téléphone

This commit is contained in:
Nicolas Dandrimont 2010-10-16 17:24:03 +02:00
parent 4bbb0ed051
commit 72e7f49f6c

View file

@ -50,8 +50,43 @@ class nomTest(LDAPTest):
attrify_light(u"Space Man", "nom") attrify_light(u"Space Man", "nom")
self.assertRaises(Exception, attrify_light, "Stringman", "nom") self.assertRaises(Exception, attrify_light, "Stringman", "nom")
self.assertRaises(Exception, attrify_light, u" Spaceman", "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): def auto_suite(testcase):
"""Suite de tests 'automatique'""" """Suite de tests 'automatique'"""
suite = unittest.TestSuite() suite = unittest.TestSuite()