1 | # Tests for applicant webservices |
---|
2 | from zope.app.testing.xmlrpc import ServerProxy |
---|
3 | from waeup.kofa.testing import FunctionalLayer |
---|
4 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
---|
5 | |
---|
6 | |
---|
7 | class 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 |
---|