summaryrefslogtreecommitdiffstats
path: root/tests/functional/test_wap_client/test_003_user_add_fr_FR.py
blob: b9ef51093a5c917413ef14dd4eb250d77e3de0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-

import time
import unittest

import pykolab
from pykolab import wap_client
from pykolab.auth import Auth
from pykolab.imap import IMAP

conf = pykolab.getConf()

class TestUserAddFrFR(unittest.TestCase):
    @classmethod
    def setup_class(self, *args, **kw):
        from tests.functional.purge_users import purge_users
        purge_users()

        self.user = {
                'local': 'etienne-nicolas.mehul',
                'domain': 'example.org'
            }

        from tests.functional.user_add import user_add
        user_add("Étienne-Nicolas", "Méhul", 'fr_FR')
        from tests.functional.synchronize import synchronize_once
        synchronize_once()

    @classmethod
    def teardown_class(self, *args, **kw):
        from tests.functional.purge_users import purge_users
        purge_users()

    def test_001_inbox_created(self):

        time.sleep(2)
        imap = IMAP()
        imap.connect()

        folders = imap.lm('user/%(local)s@%(domain)s' % (self.user))
        self.assertEqual(len(folders), 1)

    def test_002_fr_FR_user_recipient_policy(self):
        auth = Auth()
        auth.connect()
        recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user))
        if hasattr(self, 'assertIsInstance'):
            self.assertIsInstance(recipient, str)

        self.assertEqual(recipient, "uid=mehul,ou=People,dc=example,dc=org")

        result = wap_client.user_info(recipient)
        print result

        self.assertEqual(result['mail'], 'etienne-nicolas.mehul@example.org')
        self.assertEqual(sorted(result['alias']), ['e.mehul@example.org', 'mehul@example.org'])