Changeset 9937 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 7 Feb 2013, 09:51:37 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9936 r9937 1 import os 1 2 import grok 2 3 import datetime 3 from zope.component import queryUtility 4 from cStringIO import StringIO 5 from zope.component import queryUtility, getUtility 4 6 from zope.event import notify 5 7 from zope.interface.verify import verifyObject, verifyClass 6 from waeup.kofa.interfaces import ICSVExporter 8 from waeup.kofa.interfaces import ( 9 ICSVExporter, IExtFileStore, IFileStoreNameChooser) 7 10 from waeup.kofa.students.catalog import StudentsQuery 8 11 from waeup.kofa.students.export import ( … … 941 944 return 942 945 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 943 955 def test_export_all(self): 944 956 self.setup_student(self.student) 957 self.create_passport_img(self.student) 945 958 exporter = ComboCardDataExporter() 946 959 exporter.export_all(self.app, self.outfile) 947 960 result = open(self.outfile, 'rb').read() 948 961 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' 952 967 in result 953 968 )
Note: See TracChangeset for help on using the changeset viewer.