1
0
Fork 0
mirror of https://github.com/kakwa/ldapcherry synced 2025-07-03 11:57:41 +02:00

adding method and unit tests to get all the attributes of one backend

This commit is contained in:
kakwa 2015-05-22 09:49:50 +02:00
parent 5b03596ed7
commit 74ed8fa0d4
2 changed files with 27 additions and 2 deletions

View file

@ -8,7 +8,7 @@ import pytest
import sys
from sets import Set
from ldapcherry.attributes import Attributes
from ldapcherry.exceptions import MissingAttributesFile, MissingKey, WrongAttributeType
from ldapcherry.exceptions import MissingAttributesFile, MissingKey, WrongAttributeType, WrongBackend
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
class TestError(object):
@ -30,6 +30,22 @@ class TestError(object):
expected = Set(['ldap', 'ad'])
assert ret == expected
def testGetBackendAttributes(self):
inv = Attributes('./tests/cfg/attributes.yml')
ret = inv.get_backend_attributes('ldap')
expected = ['shell', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword', 'givenName', 'email', 'sn']
assert ret == expected
def testWrongGetBackendAttributes(self):
inv = Attributes('./tests/cfg/attributes.yml')
try:
ret = inv.get_backend_attributes('notabackend')
except WrongBackend:
return
else:
raise AssertionError("expected an exception")
def testNoFile(self):
try:
inv = Attributes('./tests/cfg/dontexist')