ldapcherry/tests/test_Roles.py

45 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement
from __future__ import unicode_literals
import pytest
import sys
from ldapcherry.roles import Roles
2015-05-12 01:41:32 +02:00
from ldapcherry.exceptions import DumplicateRoleKey, MissingKey, DumplicateRoleContent
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
class TestError(object):
def testNominal(self):
inv = Roles('./tests/cfg/roles.yml')
print inv.roles
return True
def testMissingDisplayName(self):
try:
2015-05-12 01:41:32 +02:00
inv = Roles('./tests/cfg/roles_missing_diplay_name.yml')
except MissingKey:
return
else:
raise AssertionError("expected an exception")
def testRoleKeyDuplication(self):
try:
inv = Roles('./tests/cfg/roles_key_dup.yml')
except DumplicateRoleKey:
return
else:
raise AssertionError("expected an exception")
def testRoleContentDuplication(self):
try:
inv = Roles('./tests/cfg/roles_content_dump.yml')
except DumplicateRoleContent:
return
else:
raise AssertionError("expected an exception")