[global] Passage à tout unicode et quelques corrections mineures.

* Typos
 * Docstrings unicode
 * Erreurs unicode
 * Ajout de _post_delete et _post_create
 * ?
This commit is contained in:
Pierre-Elliott Bécue 2013-05-27 23:18:24 +02:00
parent b2abbef3b4
commit 60ded9f830
7 changed files with 244 additions and 237 deletions

36
test.py
View file

@ -9,15 +9,15 @@ import string
import os
import sys
## import dans /usr/scripts/
sys.path.append("/usr/scripts/")
from gestion.affich_tools import anim, OK, cprint, ERREUR
## import locaux
import lc_ldap
import shortcuts
import variables
## import dans /usr/scripts/
sys.path.append("/usr/scripts/")
from gestion.affich_tools import anim, OK, cprint, ERREUR
show_traceback = False
if "--traceback" in sys.argv:
show_traceback = True
@ -30,28 +30,28 @@ def randomMAC():
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
return ':'.join(map(lambda x: "%02x" % x, mac))
return u':'.join(map(lambda x: u"%02x" % x, mac))
def randomStr(n=10):
return ''.join( random.choice(string.lowercase + string.digits) for i in range(n))
adherent_ldif = {
'prenom' : ['toto'],
'nom' : ['passoir'],
'chbre' : ['EXT'],
'tel' : ['0000000000'],
'mail' : ['nobody@test.org'],
'etudes' : ['ENS', '1', 'A0'],
'prenom' : [u'Totoé'],
'nom' : [u'passoir'],
'chbre' : [u'EXT'],
'tel' : [u'0000000000'],
'mail' : [u'nobody@test.org'],
'etudes' : [u'ÉNS', u'1', u'A0'],
}
machine_ldif = {
'macAddress' : [randomMAC()],
'host' : ["autotest-%s.crans.org" % randomStr() ]
'host' : [u"autotest-%s.crans.org" % randomStr() ]
}
club_ldif = {
'nom' : [ 'autotest-club' ],
'chbre' : [ 'EXT' ],
'nom' : [ u'autotest-club' ],
'chbre' : [ u'EXT' ],
}
facture_ldif = {}
@ -109,7 +109,7 @@ def tests_machines(parent_dn, realm_list, ipsec=False):
anim("Creation de machines %s" % realm)
try:
machine = conn.newMachine(parent_dn, realm, machine_ldif)
if ipsec: machine['ipsec'] = 'auto'
if ipsec: machine['ipsec'] = u'auto'
machine.create()
except Exception as error:
print ERREUR
@ -127,11 +127,9 @@ def tests_machines(parent_dn, realm_list, ipsec=False):
else: print "\t%r" % error
else: print OK
print "Test de la librairie lc_ldap"
print "Connection"
print "Connexion"
conn = shortcuts.lc_ldap_test()
print u"Tests effectués avec les droits %s " % ', '.join(conn.droits)
@ -211,7 +209,7 @@ tests_machines(variables.base_dn, ["bornes"])
anim("Creation d'un club")
try:
club = conn.newClub(club_ldif)
club['responsable'] = str(adherent['aid'][0])
club['responsable'] = unicode(adherent['aid'][0])
club.create()
except Exception:
print ERREUR