From ffdafa9008dac20b2c4591321e444bd3cfc85c8f Mon Sep 17 00:00:00 2001 From: "Jeroen van Meeuwen (Kolab Systems)" Date: Mon, 24 Dec 2012 17:09:12 +0100 Subject: Provide purge_users and synchronize short cut calls --- tests/functional/purge_users.py | 37 +++++++++++++++++++++++++++++++++++++ tests/functional/synchronize.py | 6 ++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/functional/purge_users.py create mode 100644 tests/functional/synchronize.py diff --git a/tests/functional/purge_users.py b/tests/functional/purge_users.py new file mode 100644 index 0000000..1b18cb0 --- /dev/null +++ b/tests/functional/purge_users.py @@ -0,0 +1,37 @@ +import pykolab + +from pykolab import wap_client +from pykolab.auth import Auth +from pykolab.imap import IMAP + +conf = pykolab.getConf() + +def purge_users(): + wap_client.authenticate(conf.get("ldap", "bind_dn"), conf.get("ldap", "bind_pw")) + + users = wap_client.users_list() + for user in users['list']: + wap_client.user_delete({'user': user}) + + auth = Auth() + domains = auth.list_domains() + + imap = IMAP() + imap.connect() + + folders = [] + + for domain,aliases in domains: + folders.extend(imap.lm("user/%%@%s" % (domain))) + + for folder in folders: + user = folder.replace('user/','') + + recipient = auth.find_recipient(user) + + if len(recipient) == 0 or recipient == []: + try: + imap.dm(folder) + except: + pass + diff --git a/tests/functional/synchronize.py b/tests/functional/synchronize.py new file mode 100644 index 0000000..7046db2 --- /dev/null +++ b/tests/functional/synchronize.py @@ -0,0 +1,6 @@ +from pykolab.auth import Auth + +def synchronize_once(): + auth = Auth() + auth.connect() + auth.synchronize(mode='_paged_search') -- cgit v1.1