source: main/waeup.kofa/branches/0.2/src/waeup/kofa/applicants/tests/test_webservices.py

Last change on this file was 10521, checked in by Henrik Bettermann, 11 years ago

Add webservice which can be used to update user data and enroll user in Moodle courses via webservices.

File size: 1.9 KB
Line 
1# Tests for applicant webservices
2from zope.app.testing.xmlrpc import ServerProxy
3from waeup.kofa.testing import FunctionalLayer
4from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
5
6
7class XMLRPCTests(ApplicantsFullSetup):
8    # check XMLRPC services for university portal
9
10    layer = FunctionalLayer
11
12    def setup_applicant(self, applicant):
13        applicant.firstname = u'Bob'
14        applicant.lastname = u'Bubble'
15        applicant.email = 'bob@sample.com'
16        pass
17
18    def test_check_applicant_credentials_valid(self):
19        # make sure we can get applicant infos providing valid creds
20        server = ServerProxy('http://mgr:mgrpw@localhost/app')
21        self.setup_applicant(self.applicant)
22        apl_id = self.applicant.applicant_id
23        result = server.check_applicant_credentials(apl_id, 'apwd')
24        self.assertEqual(
25            result, {
26                'description': 'Bob Bubble',
27                'email': 'bob@sample.com',
28                'id': apl_id,
29                'type': 'applicant'}
30            )
31        return
32
33    def test_check_applicant_credentials_invalid(self):
34        # invalid creds will give no results
35        server = ServerProxy('http://mgr:mgrpw@localhost/app')
36        self.setup_applicant(self.applicant)
37        apl_id = self.applicant.applicant_id
38        result = server.check_applicant_credentials(apl_id, 'wrong-pw')
39        self.assertEqual(result, None)
40        return
41
42    def test_get_moodle_data(self):
43        # make sure we can get applicant infos providing valid creds
44        server = ServerProxy('http://mgr:mgrpw@localhost/app')
45        self.setup_applicant(self.applicant)
46        apl_id = self.applicant.applicant_id
47        result = server.get_applicant_moodle_data(apl_id)
48        self.assertEqual(
49            result, {
50                'lastname': 'Bubble',
51                'email': 'bob@sample.com',
52                'firstname': 'Bob',
53                }
54            )
55        return
56
Note: See TracBrowser for help on using the repository browser.