summaryrefslogtreecommitdiffstats
path: root/tests/functional/test_wap_client/test_001_connect.py
blob: 42b8aa3fc4014cbea4d8e7fc56b7039a60debd21 (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
import unittest

import pykolab
from pykolab import wap_client

class TestConnect(unittest.TestCase):
    @classmethod
    def setup_class(self, *args, **kw):
        conf = pykolab.getConf()
        conf.finalize_conf(fatal=False)

        self.login = conf.get('ldap', 'bind_dn')
        self.password = conf.get('ldap', 'bind_pw')
        self.domain = conf.get('kolab', 'primary_domain')

    def test_001_authenticate(self):
        result = wap_client.authenticate(self.login, self.password, self.domain)

    def test_002_response_ok(self):
        result = wap_client.request_raw('POST', 'domains.list')
        self.assertTrue(result.has_key('status'))
        self.assertTrue(result.has_key('result'))
        self.assertEqual(result['status'], "OK")

    def test_003_response_fail(self):
        result = wap_client.request_raw('POST', 'service.method')
        self.assertTrue(result.has_key('status'))
        self.assertTrue(result.has_key('reason'))
        self.assertTrue(result.has_key('code'))
        self.assertEqual(result['status'], "ERROR")
        self.assertEqual(result['reason'], "Unknown service")
        self.assertEqual(result['code'], 400)

    def test_003_domains_list(self):
        result = wap_client.domains_list()
        self.assertTrue(result.has_key('count'))
        self.assertTrue(result.has_key('list'))
        self.assertEqual(result['count'], len(result['list']))