Hello community,

here is the log from the commit of package python-aedir for openSUSE:Factory 
checked in at 2017-02-07 12:06:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-aedir (Old)
 and      /work/SRC/openSUSE:Factory/.python-aedir.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-aedir"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-aedir/python-aedir.changes        
2017-02-03 18:57:07.711804822 +0100
+++ /work/SRC/openSUSE:Factory/.python-aedir.new/python-aedir.changes   
2017-02-07 12:06:13.354235350 +0100
@@ -1,0 +2,15 @@
+Thu Feb  2 15:54:15 UTC 2017 - mich...@stroeder.com
+
+- update to 0.0.22
+
+-------------------------------------------------------------------
+Thu Feb  2 13:39:06 UTC 2017 - mich...@stroeder.com
+
+- update to 0.0.19
+
+-------------------------------------------------------------------
+Wed Feb  1 08:39:50 UTC 2017 - mich...@stroeder.com
+
+- update to 0.0.18
+
+-------------------------------------------------------------------

Old:
----
  aedir-0.0.17.tar.gz
  aedir-0.0.17.tar.gz.asc

New:
----
  aedir-0.0.22.tar.gz
  aedir-0.0.22.tar.gz.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-aedir.spec ++++++
--- /var/tmp/diff_new_pack.sh9IJX/_old  2017-02-07 12:06:13.746179897 +0100
+++ /var/tmp/diff_new_pack.sh9IJX/_new  2017-02-07 12:06:13.750179331 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           python-aedir
-Version:        0.0.17
+Version:        0.0.22
 Release:        0
 Summary:        Python module for AE-DIR
 License:        Apache-2.0

++++++ aedir-0.0.17.tar.gz -> aedir-0.0.22.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/PKG-INFO new/aedir-0.0.22/PKG-INFO
--- old/aedir-0.0.17/PKG-INFO   2017-01-18 22:56:52.000000000 +0100
+++ new/aedir-0.0.22/PKG-INFO   2017-02-02 16:51:06.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aedir
-Version: 0.0.17
+Version: 0.0.22
 Summary: AE-DIR library
 Home-page: https://ae-dir.com/python.html
 Author: Michael Stroeder
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir/__init__.py 
new/aedir-0.0.22/aedir/__init__.py
--- old/aedir-0.0.17/aedir/__init__.py  2017-01-17 12:09:26.000000000 +0100
+++ new/aedir-0.0.22/aedir/__init__.py  2017-02-02 16:36:32.000000000 +0100
@@ -17,6 +17,7 @@
 import logging
 import logging.handlers
 import logging.config
+import pprint
 
 # Imports from python-ldap
 import ldapurl
@@ -33,24 +34,21 @@
 from ldap.controls.openldap import SearchNoOpMixIn
 from ldap.controls.readentry import PreReadControl
 
-__version__ = '0.0.17'
-__author__ = 'Michael Stroeder <mich...@stroeder.com>'
-__license__ = 'Apache License, Version 2.0'
+from aedir.pkginfo import __version__, __author__, __license__
 
 # exported symbols
 __all__ = [
     'AEDirUrl',
     'AEDirObject',
     'AEDIR_SEARCH_BASE',
-    'NO_UNIQUE_ENTRY',
     'aedir_aehost_dn',
     'aedir_aeuser_dn',
     'extract_zone',
-    'ldap_strf_secs',
-    'ldap_strp_secs',
-    'logger_fileobj',
-    'parse_config_file',
+    'LoggerFileObj',
+    'parse_ldap_config_file',
     'random_string',
+    'init_logger',
+    'members2uids',
 ]
 
 # Timeout in seconds when connecting to local and remote LDAP servers
@@ -239,7 +237,7 @@
             cacert_filename=None,
             client_cert_filename=None,
             client_key_filename=None,
-            cache_time=0.0,
+            cache_ttl=0.0,
         ):
         """
         Opens connection, sets some LDAP options and binds according
@@ -269,7 +267,7 @@
             raise ValueError('Invalid value for ldap_url: %r' % ldap_url)
         who = who or self.ldap_url_obj.who
         cred = cred or self.ldap_url_obj.cred
-        self.cache_time = cache_time
+        self.cache_ttl = cache_ttl
         # Initialize the ldap.ldapobject.ReconnectLDAPObject instance
         ReconnectLDAPObject.__init__(
             self,
@@ -357,7 +355,6 @@
         if self._aeroot_dn:
             return self._aeroot_dn
         # read namingContexts from rootDSE
-        naming_contexts = self.get_naming_contexts()
         root_dse = self.read_rootdse_s(
             attrlist=['namingContexts', 'defaultNamingContext', 'aeRoot']
         )
@@ -365,6 +362,7 @@
         if aeroot_dn is not None:
             self._aeroot_dn = aeroot_dn
             return aeroot_dn
+        naming_contexts = root_dse.get('namingContexts',[])
         while naming_contexts:
             # last element
             naming_context = naming_contexts.pop(-1)
@@ -523,9 +521,10 @@
                         break
         return srvgroup_relations # get_user_srvgroup_relations()
 
-    def get_service_groups(self, service_dn):
+    def get_service_groups(self, service_dn, filterstr='', attrlist=None):
         """
-        returns DNs of all service groups the aeHost/aeService is member of
+        returns all service group entries the aeHost/aeService defined by
+        service_dn is member of
         """
         aeservice_entry = self.read_s(
             service_dn,
@@ -533,7 +532,19 @@
         ) or {}
         aesrvgroup_dn_list = [','.join(ldap.explode_dn(service_dn)[1:])]
         aesrvgroup_dn_list.extend(aeservice_entry.get('aeSrvGroup', []))
-        return aesrvgroup_dn_list
+        srvgroup_filter = '(&{0}{1})'.format(
+            '(|{0})'.format(''.join([
+                '(entryDN={0})'.format(dn)
+                for dn in aesrvgroup_dn_list
+            ])),
+            filterstr,
+        )
+        return self.search_ext_s(
+            self._aeroot_dn,
+            ldap.SCOPE_SUBTREE,
+            srvgroup_filter,
+            attrlist=attrlist or ['1.1'],
+        ) or []
 
     def get_user_service_relations(
             self,
@@ -547,7 +558,8 @@
 
         returns set of relationship attribute names
         """
-        aesrvgroup_dn_list = self.get_service_groups(service_dn)
+        aesrvgroups = self.get_service_groups(service_dn, attrlist=None)
+        aesrvgroup_dn_list = dict(aesrvgroups).keys()
         result = set()
         for aesrvgroup_dn in set(aesrvgroup_dn_list):
             result.update(
@@ -559,39 +571,66 @@
             )
         return result
 
-    def get_users(self, service_dn, attrlist=None, ref_attr='aeLoginGroups'):
+    def search_users(
+            self,
+            service_dn=None,
+            ae_status=0,
+            filterstr='(|(objectClass=aeUser)(objectClass=aeService))',
+            attrlist=None,
+            ref_attr='aeLoginGroups',
+            serverctrls=None,
+        ):
         """
-        returns all aeUser/aeService entries having the appropriate
-        relationship on given aeHost/aeService
+        starts async search for all aeUser/aeService entries having the
+        appropriate relationship on given aeHost/aeService
         """
-        aesrvgroup_dn_list = self.get_service_groups(service_dn)
-        srvgroup_filter = '(&{0}({1}=*))'.format(
-            '(|{0})'.format(''.join([
-                '(entryDN={0})'.format(dn)
-                for dn in aesrvgroup_dn_list
-            ])),
-            ref_attr,
-        )
-        srvgroups = self.search_ext_s(
-            self._aeroot_dn,
-            ldap.SCOPE_SUBTREE,
-            srvgroup_filter,
+        aesrvgroups = self.get_service_groups(
+            service_dn,
+            filterstr='({0}=*)'.format(ref_attr),
             attrlist=[ref_attr],
-        ) or []
+        )
         ref_attrs_groups = set()
-        for srvgroup_dn, srvgroup_entry in srvgroups:
+        for _, srvgroup_entry in aesrvgroups:
             ref_attrs_groups.update(map(str.lower, srvgroup_entry[ref_attr]))
-        user_group_filter = '(|{0})'.format(''.join([
-            '(memberOf={0})'.format(dn)
-            for dn in ref_attrs_groups
-        ]))
-        ae_user_entries = self.search_ext_s(
+        user_group_filter = '(&(aeStatus={0}){1}(|{2}))'.format(
+            str(int(ae_status)),
+            filterstr,
+            ''.join([
+                '(memberOf={0})'.format(escape_filter_chars(dn))
+                for dn in ref_attrs_groups
+            ]),
+        )
+        msg_id = self.search_ext(
             self._aeroot_dn,
             ldap.SCOPE_SUBTREE,
             user_group_filter,
             attrlist=attrlist,
+            serverctrls=serverctrls,
+        )
+        return msg_id
+
+    def get_users(
+            self,
+            service_dn,
+            ae_status=0,
+            filterstr='(|(objectClass=aeUser)(objectClass=aeService))',
+            attrlist=None,
+            ref_attr='aeLoginGroups',
+            serverctrls=None,
+        ):
+        """
+        returns all aeUser/aeService entries having the appropriate
+        relationship on given aeHost/aeService  as list of 2-tuples
+        """
+        msg_id = self.search_users(
+            service_dn,
+            ae_status=ae_status,
+            filterstr=filterstr,
+            attrlist=attrlist,
+            ref_attr=ref_attr,
+            serverctrls=serverctrls,
         )
-        return ae_user_entries
+        return self.result4(msg_id)
 
     def get_cache_hit_ratio(self):
         """
@@ -616,11 +655,13 @@
             clientctrls=None,
             timeout=-1,
             sizelimit=0,
-            nocache=0
+            cache_ttl=None,
         ):
         """
         caching variant of LDAPObject.search_ext_s()
         """
+        if cache_ttl is None:
+            cache_ttl = self.cache_ttl
         current_time = time.time()
         cache_key_args = (
             base,
@@ -633,16 +674,19 @@
             timeout,
             sizelimit
         )
-        try:
-            result_cache_time, result = self._cache[cache_key_args]
-        except KeyError:
-            result = None
-        else:
-            if nocache or current_time > result_cache_time:
-                del self._cache[cache_key_args]
-                result = None
+        result = None
+        if cache_ttl > 0:
+            # first look into cache for non-expired search results
+            try:
+                result_cache_time, result = self._cache[cache_key_args]
+            except KeyError:
+                pass
             else:
-                self._cache_hits += 1
+                if current_time > result_cache_time + cache_ttl:
+                    # cache entry is expired => remove it no matter what 
happens later
+                    del self._cache[cache_key_args]
+                else:
+                    self._cache_hits += 1
         if result is None:
             self._cache_misses += 1
             result = ReconnectLDAPObject.search_ext_s(
@@ -657,10 +701,12 @@
                 timeout,
                 sizelimit
             )
-            self._cache[cache_key_args] = (
-                current_time+self.cache_time,
-                result
-            )
+            if self.cache_ttl > 0:
+                # store result in cache if caching is enabled at all
+                self._cache[cache_key_args] = (
+                    current_time,
+                    result
+                )
         return result # search_ext_s()
 
     def flush_cache(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir/pkginfo.py 
new/aedir-0.0.22/aedir/pkginfo.py
--- old/aedir-0.0.17/aedir/pkginfo.py   1970-01-01 01:00:00.000000000 +0100
+++ new/aedir-0.0.22/aedir/pkginfo.py   2017-02-02 16:51:00.000000000 +0100
@@ -0,0 +1,6 @@
+"""
+meta attributes for packaging which does not import any dependencies
+"""
+__version__ = '0.0.22'
+__author__ = 'Michael Stroeder <mich...@stroeder.com>'
+__license__ = 'Apache License, Version 2.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/PKG-INFO 
new/aedir-0.0.22/aedir.egg-info/PKG-INFO
--- old/aedir-0.0.17/aedir.egg-info/PKG-INFO    1970-01-01 01:00:00.000000000 
+0100
+++ new/aedir-0.0.22/aedir.egg-info/PKG-INFO    2017-02-02 16:51:05.000000000 
+0100
@@ -0,0 +1,29 @@
+Metadata-Version: 1.1
+Name: aedir
+Version: 0.0.22
+Summary: AE-DIR library
+Home-page: https://ae-dir.com/python.html
+Author: Michael Stroeder
+Author-email: mich...@stroeder.com
+License: Apache License, Version 2.0
+Download-URL: https://pypi.python.org/pypi/aedir
+Description: AE-DIR library for Python:
+        This module contains
+        1. a wrapper class AEDirObject based on python-ldap's 
ReconnectLDAPObject and ldap.resiter.ResultProcessor
+        2. several utility functions
+        
+Keywords: AE-DIR,LDAP,OpenLDAP
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: No Input/Output (Daemon)
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Topic :: Database
+Classifier: Topic :: Internet
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Systems Administration :: 
Authentication/Directory :: LDAP
+Requires: ldap
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/SOURCES.txt 
new/aedir-0.0.22/aedir.egg-info/SOURCES.txt
--- old/aedir-0.0.17/aedir.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 
+0100
+++ new/aedir-0.0.22/aedir.egg-info/SOURCES.txt 2017-02-02 16:51:06.000000000 
+0100
@@ -0,0 +1,16 @@
+MANIFEST.in
+README.md
+setup.cfg
+setup.py
+aedir/__init__.py
+aedir/pkginfo.py
+aedir/process.py
+aedir.egg-info/PKG-INFO
+aedir.egg-info/SOURCES.txt
+aedir.egg-info/dependency_links.txt
+aedir.egg-info/not-zip-safe
+aedir.egg-info/requires.txt
+aedir.egg-info/top_level.txt
+dist/.place_holder
+examples/some_queries.py
+tests/t_aedir.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/dependency_links.txt 
new/aedir-0.0.22/aedir.egg-info/dependency_links.txt
--- old/aedir-0.0.17/aedir.egg-info/dependency_links.txt        1970-01-01 
01:00:00.000000000 +0100
+++ new/aedir-0.0.22/aedir.egg-info/dependency_links.txt        2017-02-02 
16:51:05.000000000 +0100
@@ -0,0 +1 @@
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/not-zip-safe 
new/aedir-0.0.22/aedir.egg-info/not-zip-safe
--- old/aedir-0.0.17/aedir.egg-info/not-zip-safe        1970-01-01 
01:00:00.000000000 +0100
+++ new/aedir-0.0.22/aedir.egg-info/not-zip-safe        2017-02-02 
16:41:59.000000000 +0100
@@ -0,0 +1 @@
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/requires.txt 
new/aedir-0.0.22/aedir.egg-info/requires.txt
--- old/aedir-0.0.17/aedir.egg-info/requires.txt        1970-01-01 
01:00:00.000000000 +0100
+++ new/aedir-0.0.22/aedir.egg-info/requires.txt        2017-02-02 
16:51:05.000000000 +0100
@@ -0,0 +1 @@
+setuptools
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/aedir.egg-info/top_level.txt 
new/aedir-0.0.22/aedir.egg-info/top_level.txt
--- old/aedir-0.0.17/aedir.egg-info/top_level.txt       1970-01-01 
01:00:00.000000000 +0100
+++ new/aedir-0.0.22/aedir.egg-info/top_level.txt       2017-02-02 
16:51:05.000000000 +0100
@@ -0,0 +1 @@
+aedir
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/examples/some_queries.py 
new/aedir-0.0.22/examples/some_queries.py
--- old/aedir-0.0.17/examples/some_queries.py   1970-01-01 01:00:00.000000000 
+0100
+++ new/aedir-0.0.22/examples/some_queries.py   2017-01-31 20:58:35.000000000 
+0100
@@ -0,0 +1,48 @@
+import aedir
+
+# connection to AE-DIR provider
+aedir_conn = aedir.AEDirObject(
+    
'ldapi://%2Fhome%2Fmichael%2FProj%2Fae-dir%2Fopenldap%2Fldapi-p/????x-saslmech=EXTERNAL',
+    trace_level=0,
+    cache_ttl=20.0,
+)
+
+aeroot_dn = aedir_conn.find_search_base()
+
+print "--------\nfind_search_base()", aeroot_dn
+
+print "--------\nfind_uid('msin') ->", aedir_conn.find_uid('msin')
+
+print "--------\nget_user_groups('msin') ->", 
aedir_conn.get_user_groups('msin')
+
+print "--------\nget_zoneadmins('uid=bccb,cn=test,ou=ae-dir',attrlist=['mail', 
'cn']) ->", 
aedir_conn.get_zoneadmins('uid=bccb,cn=test,ou=ae-dir',attrlist=['mail', 'cn'])
+
+aehost_dn, _ = aedir_conn.find_aehost('foo.example.com')
+
+print "--------\naehost_dn =", repr(aehost_dn)
+
+# connection to AE-DIR consumer
+aedir_conn = aedir.AEDirObject(
+    
'ldapi://%2Fhome%2Fmichael%2FProj%2Fae-dir%2Fopenldap%2Fldapi-p/????x-saslmech=EXTERNAL',
+    trace_level=0
+)
+
+print "--------\nfind_search_base()", aeroot_dn
+
+aedir_conn.sasl_external_bind_s(authz_id='dn:'+aehost_dn)
+
+aeroot_dn = aedir_conn.find_search_base()
+
+print "--------\nget_service_groups(aehost_dn) ->", 
aedir_conn.get_service_groups(aehost_dn)
+
+print "--------\nget_users(aehost_dn, ref_attr='aeLoginGroups') ->", 
aedir_conn.get_users(aehost_dn, attrlist=['uid', 'memberOf'], 
ref_attr='aeLoginGroups')
+
+print "--------\nfind_uid('bccb') ->", aedir_conn.find_uid('bccb')
+
+print "--------\nget_user_groups('bccb') ->", 
aedir_conn.get_user_groups('bccb')
+
+print "--------\nget_user_service_relations('bccb', aehost_dn) ->", 
aedir_conn.get_user_service_relations('bccb', aehost_dn)
+
+print "--------\nget_user_service_relations('bccb', aehost_dn, 
['aeLoginGroups']) ->", aedir_conn.get_user_service_relations('bccb', 
aehost_dn, ['aeLoginGroups'])
+
+print "--------\nget_cache_hit_ratio() ->", aedir_conn.get_cache_hit_ratio()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/setup.cfg new/aedir-0.0.22/setup.cfg
--- old/aedir-0.0.17/setup.cfg  2017-01-18 15:10:41.000000000 +0100
+++ new/aedir-0.0.22/setup.cfg  2017-02-02 16:51:06.000000000 +0100
@@ -2,13 +2,17 @@
 compile = 1
 optimize = 1
 
-# Linux distributors/packagers should adjust these settings
 [bdist_rpm]
 vendor = ae-dir.com
 provides = python-aedir
 requires = python python-ldap>=2.4.28
-# distribution_name = 
 release = 0
 packager = Michael Stroeder <mich...@stroeder.com>
 doc_files = README.md
 group = Development/Libraries
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/setup.py new/aedir-0.0.22/setup.py
--- old/aedir-0.0.17/setup.py   2017-01-18 22:56:47.000000000 +0100
+++ new/aedir-0.0.22/setup.py   2017-02-02 16:50:46.000000000 +0100
@@ -8,15 +8,25 @@
 import os
 from distutils.core import setup
 
-sys.path.insert(0, os.getcwd())
+try:
+    from setuptools import setup, Extension
+except ImportError:
+    from distutils.core import setup, Extension
+else:
+    setup_tools_kwargs = dict(
+      include_package_data = True,
+      install_requires = ['setuptools'],
+      zip_safe = False,
+    )
 
-import aedir
+sys.path.insert(0, os.path.join(os.getcwd(), 'aedir'))
+import pkginfo
 
 setup(
     #-- Package description
     name='aedir',
-    license='Apache License, Version 2.0',
-    version=aedir.__version__,
+    license=pkginfo.__license__,
+    version=pkginfo.__version__,
     description='AE-DIR library',
     long_description="""AE-DIR library for Python:
 This module contains
@@ -29,7 +39,7 @@
     maintainer_email='mich...@stroeder.com',
     url='https://ae-dir.com/python.html',
     download_url='https://pypi.python.org/pypi/aedir',
-    py_modules=['aedir', 'aedir.process'],
+    py_modules=['aedir', 'aedir.pkginfo', 'aedir.process'],
     keywords=['AE-DIR', 'LDAP', 'OpenLDAP'],
     requires=['ldap'],
     #provides=['aedir (%s)' % aedir.__version__],
@@ -46,5 +56,6 @@
         'Topic :: Internet',
         'Topic :: Software Development :: Libraries :: Python Modules',
         'Topic :: System :: Systems Administration :: Authentication/Directory 
:: LDAP',
-    ]
+    ],
+    **setup_tools_kwargs
 )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aedir-0.0.17/tests/t_aedir.py 
new/aedir-0.0.22/tests/t_aedir.py
--- old/aedir-0.0.17/tests/t_aedir.py   1970-01-01 01:00:00.000000000 +0100
+++ new/aedir-0.0.22/tests/t_aedir.py   2016-08-16 12:17:21.000000000 +0200
@@ -0,0 +1,159 @@
+# -*- coding: utf-8 -*-
+"""
+Automatic tests for module aedir
+
+See https://ae-dir.com/python.html for details.
+"""
+
+# from Python's standard lib
+import unittest
+
+# from python-ldap
+import ldap
+from ldap.dn import escape_dn_chars
+from ldap.filter import escape_filter_chars
+
+# import module to be tested herein
+import aedir
+
+# set python-ldap's trace level
+ldap._trace_level = 0
+
+
+class TestAedirFuncs(unittest.TestCase):
+    """
+    test all simple functions
+    """
+
+    def test_extract_zone(self):
+        """
+        test function extract_zone()
+        """
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foo,cn=bar,ou=ae-dir'
+            ),
+            'bar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foobar,ou=ae-dir'
+            ),
+            'foobar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'uid=xkcd,cn=foobar,ou=ae-dir'
+            ),
+            'foobar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foo,cn=bar,ou=ae-dir', aeroot_dn='ou=ae-dir'
+            ),
+            'bar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foobar,ou=ae-dir', aeroot_dn='ou=ae-dir'
+            ),
+            'foobar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'uid=xkcd,cn=foobar,ou=ae-dir', aeroot_dn='ou=ae-dir'
+            ),
+            'foobar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foo,cn=bar,dc=example,dc=com', 
aeroot_dn='dc=example,dc=com'
+            ),
+            'bar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'cn=foobar,dc=example,dc=com', aeroot_dn='dc=example,dc=com'
+            ),
+            'foobar'
+        )
+        self.assertEquals(
+            aedir.extract_zone(
+                'uid=xkcd,cn=foobar,dc=example,dc=com', 
aeroot_dn='dc=example,dc=com'
+            ),
+            'foobar'
+        )
+        with self.assertRaises(ValueError):
+            aedir.extract_zone(
+                'cn=foo,cn=bar,ou=ae-dir-x',
+                aeroot_dn='ou=ae-dir'
+            )
+
+    def test_aedir_aeuser_dn(self):
+        """
+        test function aedir_aeuser_dn()
+        """
+        self.assertEquals(
+            aedir.aedir_aeuser_dn('foo'),
+            'uid=foo,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aeuser_dn('foo', 'bar'),
+            'uid=foo,cn=bar,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aeuser_dn('foo@bar'),
+            'uid=foo,cn=bar,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aeuser_dn('foo', zone='bar'),
+            'uid=foo,cn=bar,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aeuser_dn(
+                'foo', zone='bar', aeroot_dn='dc=example,dc=com'
+            ),
+            'uid=foo,cn=bar,dc=example,dc=com'
+        )
+
+    def test_aedir_aehost_dn(self):
+        """
+        test function aedir_aehost_dn()
+        """
+        self.assertEquals(
+            aedir.aedir_aehost_dn('foo.example.com'),
+            'host=foo.example.com,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aehost_dn('foo.example.com', 'bar', 'bar'),
+            'host=foo.example.com,cn=bar,cn=bar,ou=ae-dir'
+        )
+        self.assertEquals(
+            aedir.aedir_aehost_dn(
+                'foo.example.com',
+                srvgrp='bar',
+                aeroot_dn='dc=example,dc=com'
+            ),
+            'host=foo.example.com,dc=example,dc=com'
+        )
+        self.assertEquals(
+            aedir.aedir_aehost_dn(
+                'foo.example.com',
+                srvgrp='bar1',
+                zone='bar2',
+                aeroot_dn='dc=example,dc=com'
+            ),
+            'host=foo.example.com,cn=bar1,cn=bar2,dc=example,dc=com'
+        )
+        self.assertEquals(
+            aedir.aedir_aehost_dn(
+                'foo.example.com',
+                zone='bar',
+                aeroot_dn='dc=example,dc=com'
+            ),
+            'host=foo.example.com,dc=example,dc=com'
+        )
+
+
+if __name__ == '__main__':
+    unittest.main()


Reply via email to