Ignore:
Timestamp:
26 May 2014, 16:27:50 (10 years ago)
Author:
uli
Message:

Deliver images on demand and test this.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

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

    r11666 r11668  
    395395             'fingerprints': {},
    396396             'img': None,
     397             'img_name': None,
    397398             })
     399
     400    def test_get_student_fingerprints_passport(self):
     401        # we get a photograph of the student if avail.
     402        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     403        self.setup_student(self.student)
     404        self.create_passport_img(self.student)
     405        result = server.get_student_fingerprints(self.student.student_id)
     406        self.assertTrue(
     407            isinstance(result['img'], xmlrpclib.Binary))
     408        self.assertEqual(result['img_name'], 'passport_K1000000.jpg')
    398409
    399410    def test_get_student_fingerprints_block_unauthorized(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py

    r11667 r11668  
    1717##
    1818import grok
     19import os
    1920import xmlrpclib
    2021from zope.component import getUtility, queryUtility
     
    241242            firstname=student.firstname,
    242243            lastname=student.lastname,
     244            fingerprints={},
     245            img_name=None,
    243246            img=None,
    244             fingerprints={},
    245247            )
    246248        file_store = getUtility(IExtFileStore)
    247         for num in [str(x+1) for x in range(10)]:
     249        img = file_store.getFileByContext(student, attr='passport.jpg')
     250        if img is not None:
     251            result.update(
     252                img=xmlrpclib.Binary(img.read()),
     253                img_name=os.path.basename(img.name))
     254
     255
     256        for num in [str(x + 1) for x in range(10)]:
    248257            fp_file = getUtility(IExtFileStore).getFileByContext(
    249258                student, attr='%s.fpm' % num)
Note: See TracChangeset for help on using the changeset viewer.