From 72e7f49f6cde17f14f6780fa5214a5ccbc9a6953 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sat, 16 Oct 2010 17:24:03 +0200 Subject: [PATCH] =?UTF-8?q?[attributs=5Ftests]=20Pr=C3=A9nom=20et=20T?= =?UTF-8?q?=C3=A9l=C3=A9phone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs_tests.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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()