Ignore:
Timestamp:
28 May 2014, 13:19:03 (10 years ago)
Author:
uli
Message:

Provide xmlrpc service for uploading .fpm files.

File:
1 edited

Legend:

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

    r11670 r11674  
    384384        return
    385385
     386    def test_put_student_fingerprints_no_stud(self):
     387        # invalid student ids will result in `False`
     388        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     389        self.assertRaises(
     390            xmlrpclib.Fault, server.put_student_fingerprints,
     391            'invalid id', {})
     392
     393    def test_put_student_fingerprints_non_dict(self):
     394        # fingerprints must be passed in in a dict
     395        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     396        self.setup_student(self.student)
     397        self.assertRaises(
     398            xmlrpclib.Fault, server.put_student_fingerprints,
     399            self.student.student_id, 'not-a-dict')
     400
     401    def test_put_student_fingerprints_non_num_keys_ignored(self):
     402        # non-numeric keys in fingerprint dict are ignored
     403        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     404        self.setup_student(self.student)
     405        result = server.put_student_fingerprints(
     406            self.student.student_id, {'not-a-num': 'foo',
     407                                      '12.2': 'bar',
     408                                      '123': 'baz'})
     409        self.assertEqual(result, False)
     410
     411    def test_put_student_fingerprints_non_fpm_data(self):
     412        # we cannot pass non-.fpm files as values
     413        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     414        self.setup_student(self.student)
     415        self.assertRaises(
     416            xmlrpclib.Fault, server.put_student_fingerprints,
     417            self.student.student_id, {'1': 'not-a-fingerprint'})
     418
     419    def test_put_student_fingerprints_invalid_file_format(self):
     420        # invalid files will result in `False`
     421        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     422        self.setup_student(self.student)
     423        invalid_fpm = xmlrpclib.Binary('invalid file')
     424        self.assertRaises(
     425            xmlrpclib.Fault, server.put_student_fingerprints,
     426            self.student.student_id, {'1': invalid_fpm})
     427
     428    def test_put_student_fingerprints(self):
     429        # we can store fingerprints
     430        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     431        self.setup_student(self.student)
     432        fpm = xmlrpclib.Binary('FP1faked_fpm')
     433        result = server.put_student_fingerprints(
     434            self.student.student_id, {'1': fpm})
     435        self.assertEqual(result, True)
     436        stored_file = getUtility(IExtFileStore).getFileByContext(
     437            self.student, attr="1.fpm")
     438        self.assertEqual(stored_file.read(), 'FP1faked_fpm')
     439
    386440    def test_get_student_fingerprints_no_stud(self):
    387441        # invalid student ids result in empty dict
Note: See TracChangeset for help on using the changeset viewer.