Ignore:
Timestamp:
26 May 2014, 13:32:57 (11 years ago)
Author:
uli
Message:

Tests for webservice offering fingerprints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py

    r10842 r11666  
    376376        self.assertEqual(xmlout, RESPONSE_XML)
    377377        return
     378
     379    def test_get_student_fingerprints_no_stud(self):
     380        # invalid student ids result in empty dict
     381        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     382        result = server.get_student_fingerprints('invalid id')
     383        self.assertEqual(result, {})
     384
     385    def test_get_student_fingerprints_no_files(self):
     386        # we get student data, but no fingerprints if not stored before
     387        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     388        self.setup_student(self.student)
     389        result = server.get_student_fingerprints(self.student.student_id)
     390        self.assertEqual(
     391            result,
     392            {'lastname': 'Tester',
     393             'email': 'aa@aa.ng',
     394             'firstname': 'Anna',
     395             'fingerprints': {},
     396             'img': None,
     397             })
     398
     399    def test_get_student_fingerprints_block_unauthorized(self):
     400        # requests from unauthorized users are blocked
     401        # no username nor password
     402        server = ServerProxy('http://localhost/app')
     403        self.setup_student(self.student)
     404        stud_id = self.student.student_id
     405        self.assertRaises(
     406            xmlrpclib.ProtocolError, server.get_student_id, stud_id)
     407        # wrong password
     408        server = ServerProxy('http://mgr:WRONGPW@localhost/app')
     409        self.assertRaises(
     410            xmlrpclib.ProtocolError, server.get_student_id, stud_id)
     411        # wrong username
     412        server = ServerProxy('http://WRONGUSER:mgrpw@localhost/app')
     413        self.assertRaises(
     414            xmlrpclib.ProtocolError, server.get_student_id, stud_id)
     415        return
Note: See TracChangeset for help on using the changeset viewer.