1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

fix behavior of get_attributes()

* make sure it returns an ordered list in both python 2 and python 3
This commit is contained in:
kakwa 2019-02-09 16:22:42 +01:00
parent 10747cff93
commit 79983c078f
2 changed files with 4 additions and 1 deletions

View File

@ -130,7 +130,9 @@ class Attributes:
def get_backend_attributes(self, backend): def get_backend_attributes(self, backend):
if backend not in self.backends: if backend not in self.backends:
raise WrongBackend(backend) raise WrongBackend(backend)
return self.backend_attributes[backend].keys() ret = list(self.backend_attributes[backend].keys())
ret.sort()
return ret
def get_backend_key(self, backend): def get_backend_key(self, backend):
if backend not in self.backends: if backend not in self.backends:

View File

@ -42,6 +42,7 @@ class TestError(object):
inv = Attributes('./tests/cfg/attributes.yml') inv = Attributes('./tests/cfg/attributes.yml')
ret = inv.get_backend_attributes('ldap') ret = inv.get_backend_attributes('ldap')
expected = ['shell', 'cn', 'userPassword', 'uidNumber', 'gidNumber', 'sn', 'home', 'givenName', 'email', 'uid'] expected = ['shell', 'cn', 'userPassword', 'uidNumber', 'gidNumber', 'sn', 'home', 'givenName', 'email', 'uid']
expected.sort()
assert ret == expected assert ret == expected
def testGetKey(self): def testGetKey(self):