Changeset View
Changeset View
Standalone View
Standalone View
tests/functional/test_kolabd/test_002_user_rename.py
import time | import time | ||||
import unittest | import unittest | ||||
import pykolab | import pykolab | ||||
from pykolab import wap_client | from pykolab import wap_client | ||||
from pykolab.auth import Auth | from pykolab.auth import Auth | ||||
from pykolab.imap import IMAP | from pykolab.imap import IMAP | ||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
class TestKolabDaemon(unittest.TestCase): | class TestKolabDaemon(unittest.TestCase): | ||||
@classmethod | @classmethod | ||||
def setup_class(self, *args, **kw): | def setup_class(self, *args, **kw): | ||||
from tests.functional.purge_users import purge_users | from tests.functional.purge_users import purge_users | ||||
purge_users() | purge_users() | ||||
self.user = { | self.user = { | ||||
'local': 'john.doe', | 'local': 'john.doe', | ||||
Show All 15 Lines | def test_001_user_rename(self): | ||||
policy is applied, and the IMAP INBOX folder for the user is | policy is applied, and the IMAP INBOX folder for the user is | ||||
renamed. | renamed. | ||||
""" | """ | ||||
auth = Auth() | auth = Auth() | ||||
auth.connect() | auth.connect() | ||||
recipient = auth.find_recipient('john.doe@example.org') | recipient = auth.find_recipient('john.doe@example.org') | ||||
user_info = wap_client.user_info(recipient) | user_info = wap_client.user_info(recipient) | ||||
if not user_info.has_key('mailhost'): | if 'mailhost' not in user_info: | ||||
from tests.functional.synchronize import synchronize_once | from tests.functional.synchronize import synchronize_once | ||||
synchronize_once() | synchronize_once() | ||||
imap = IMAP() | imap = IMAP() | ||||
imap.connect() | imap.connect() | ||||
folders = imap.lm('user/john.doe@example.org') | folders = imap.lm('user/john.doe@example.org') | ||||
self.assertEqual(len(folders), 1) | self.assertEqual(len(folders), 1) | ||||
auth = Auth() | auth = Auth() | ||||
auth.connect() | auth.connect() | ||||
recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) | recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) | ||||
user_info = wap_client.user_info(recipient) | user_info = wap_client.user_info(recipient) | ||||
user_info['sn'] = 'Sixpack' | user_info['sn'] = 'Sixpack' | ||||
user_info['givenname'] = 'Joe' | user_info['givenname'] = 'Joe' | ||||
user_info['uid'] = 'sixpack' | user_info['uid'] = 'sixpack' | ||||
user_edit = wap_client.user_edit(recipient, user_info) | user_edit = wap_client.user_edit(recipient, user_info) | ||||
time.sleep(2) | time.sleep(2) | ||||
print imap.lm() | print imap.lm() | ||||
user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') | user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') | ||||
Lint: PEP8 E501: line too long (83 > 79 characters) | |||||
if not user_info['mail'] == 'joe.sixpack@example.org': | if not user_info['mail'] == 'joe.sixpack@example.org': | ||||
from tests.functional.synchronize import synchronize_once | from tests.functional.synchronize import synchronize_once | ||||
synchronize_once() | synchronize_once() | ||||
user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') | user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') | ||||
Lint: PEP8 E501 line too long (87 > 79 characters) Lint: PEP8 E501: line too long (87 > 79 characters) | |||||
self.assertEqual(user_info['mail'], 'joe.sixpack@example.org') | self.assertEqual(user_info['mail'], 'joe.sixpack@example.org') | ||||
print imap.lm() | print imap.lm() | ||||
folders = imap.lm('user/john.doe@example.org') | folders = imap.lm('user/john.doe@example.org') | ||||
self.assertEqual(len(folders), 0, "INBOX for john.doe still exists") | self.assertEqual(len(folders), 0, "INBOX for john.doe still exists") | ||||
folders = imap.lm('user/joe.sixpack@example.org') | folders = imap.lm('user/joe.sixpack@example.org') | ||||
self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist") | self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist") | ||||
Lint: PEP8 E501 line too long (81 > 79 characters) Lint: PEP8 E501: line too long (81 > 79 characters) | |||||
line too long (83 > 79 characters)