Ignore:
Timestamp:
7 Feb 2013, 09:51:37 (12 years ago)
Author:
Henrik Bettermann
Message:

Export passport file path.

File:
1 edited

Legend:

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

    r9936 r9937  
     1import os
    12import grok
    23import datetime
    3 from zope.component import queryUtility
     4from cStringIO import StringIO
     5from zope.component import queryUtility, getUtility
    46from zope.event import notify
    57from zope.interface.verify import verifyObject, verifyClass
    6 from waeup.kofa.interfaces import ICSVExporter
     8from waeup.kofa.interfaces import (
     9    ICSVExporter, IExtFileStore, IFileStoreNameChooser)
    710from waeup.kofa.students.catalog import StudentsQuery
    811from waeup.kofa.students.export import (
     
    941944        return
    942945
     946    def create_passport_img(self, student):
     947        # create some passport file for `student`
     948        storage = getUtility(IExtFileStore)
     949        image_path = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
     950        self.image_contents = open(image_path, 'rb').read()
     951        file_id = IFileStoreNameChooser(student).chooseName(
     952            attr='passport.jpg')
     953        storage.createFile(file_id, StringIO(self.image_contents))
     954
    943955    def test_export_all(self):
    944956        self.setup_student(self.student)
     957        self.create_passport_img(self.student)
    945958        exporter = ComboCardDataExporter()
    946959        exporter.export_all(self.app, self.outfile)
    947960        result = open(self.outfile, 'rb').read()
    948961        self.assertTrue(
    949             'display_fullname,matric_number,certificate,faculty,department\r\n'
    950             'Anna M. Tester,234,Unnamed Certificate,Faculty of Unnamed '
    951             'Faculty (NA),Department of Unnamed Department (NA)'
     962            'display_fullname,student_id,matric_number,certificate,faculty,'
     963            'department,passport_path\r\nAnna M. Tester,A111111,234,'
     964            'Unnamed Certificate,Faculty of Unnamed Faculty (NA),'
     965            'Department of Unnamed Department (NA),'
     966            'students/00110/A111111/passport_A111111.jpg\r\n'
    952967            in result
    953968            )
Note: See TracChangeset for help on using the changeset viewer.