Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin attributes handling manipulation
- Loading branch information
Showing
6 changed files
with
141 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from ldapcherry.attributes import Attributes | ||
from ldapcherry.exceptions import DumplicateRoleKey, MissingKey, DumplicateRoleContent, MissingRolesFile | ||
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError | ||
from yaml import load, dump | ||
import yaml | ||
|
||
try: | ||
from yaml import CLoader as Loader, CDumper as Dumper | ||
except ImportError: | ||
from yaml import Loader, Dumper | ||
|
||
class CustomDumper(yaml.SafeDumper): | ||
"A custom YAML dumper that never emits aliases" | ||
|
||
def ignore_aliases(self, _data): | ||
return True | ||
|
||
inv = Attributes('./conf/attributes.yml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../conf/attributes.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import with_statement | ||
from __future__ import unicode_literals | ||
|
||
import pytest | ||
import sys | ||
from sets import Set | ||
from ldapcherry.attributes import Attributes | ||
from ldapcherry.exceptions import MissingAttributesFile | ||
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError | ||
|
||
class TestError(object): | ||
|
||
def testNominal(self): | ||
inv = Attributes('./tests/cfg/attributes.yml') | ||
return True | ||
|
||
def testNoFile(self): | ||
try: | ||
inv = Attributes('./tests/cfg/dontexist') | ||
except MissingAttributesFile: | ||
return | ||
else: | ||
raise AssertionError("expected an exception") | ||
|
||
# def testMissingDisplayName(self): | ||
# try: | ||
# inv = Attributes('./tests/cfg/attributes_missing_diplay_name.yml') | ||
# except MissingKey: | ||
# return | ||
# else: | ||
# raise AssertionError("expected an exception") | ||
# | ||
# def testAttrKeyDuplication(self): | ||
# try: | ||
# inv = Attributes('./tests/cfg/attributes_key_dup.yml') | ||
# except DumplicateAttrKey: | ||
# return | ||
# else: | ||
# raise AssertionError("expected an exception") | ||
# | ||
|
||
# def testGetDisplayNameMissingAttr(self): | ||
# inv = Attributes('./tests/cfg/attributes.yml') | ||
# try: | ||
# res = inv.get_display_name('notarole') | ||
# except MissingAttr: | ||
# return | ||
# else: | ||
# raise AssertionError("expected an exception") | ||
# | ||
# def testGetDisplayName(self): | ||
# inv = Attributes('./tests/cfg/attributes.yml') | ||
# res = inv.get_display_name('users') | ||
# expected = 'Simple Users' | ||
# assert res == expected | ||
# |