source: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py @ 9761

Last change on this file since 9761 was 9761, checked in by Henrik Bettermann, 12 years ago

Show entry_sesssion in export. Show only level_session to ease post-processing with Excel.

  • Property svn:keywords set to Id
File size: 26.0 KB
Line 
1import grok
2import datetime
3from zope.component import queryUtility
4from zope.event import notify
5from zope.interface.verify import verifyObject, verifyClass
6from waeup.kofa.interfaces import ICSVExporter
7from waeup.kofa.students.export import (
8    StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter,
9    CourseTicketExporter, PaymentsExporter, BedTicketsExporter,
10    StudentPaymentsOverviewExporter, StudentStudyLevelsOverviewExporter,
11    get_students, StudentsExportFilter)
12from waeup.kofa.students.accommodation import BedTicket
13from waeup.kofa.students.interfaces import ICSVStudentExporter
14from waeup.kofa.students.payments import StudentOnlinePayment
15from waeup.kofa.students.student import Student
16from waeup.kofa.students.studycourse import StudentStudyCourse
17from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket
18from waeup.kofa.students.tests.test_batching import StudentImportExportSetup
19from waeup.kofa.testing import FunctionalLayer
20
21curr_year = datetime.datetime.now().year
22year_range = range(curr_year - 9, curr_year + 1)
23year_range_str = ','.join([str(i) for i in year_range])
24
25class ExportHelperTests(StudentImportExportSetup):
26    layer = FunctionalLayer
27    def setUp(self):
28        super(ExportHelperTests, self).setUp()
29        student = Student()
30        self.app['students'].addStudent(student)
31        student = self.setup_student(student)
32        notify(grok.ObjectModifiedEvent(student))
33        self.student = self.app['students'][student.student_id]
34        return
35
36    def test_get_students_plain(self):
37        # without a filter we get all students
38        result = get_students(self.app)
39        self.assertEqual(len(list(result)), 1)
40        return
41
42    def test_get_students_by_session(self):
43        # we can filter out students of a certain session
44        my_filter1 = StudentsExportFilter(session=2012)
45        result = get_students(self.app, stud_filter=my_filter1)
46        self.assertEqual(len(list(result)), 1)
47
48        my_filter2 = StudentsExportFilter(session=1964)
49        result = get_students(self.app, stud_filter=my_filter2)
50        self.assertEqual(len(list(result)), 0)
51        return
52
53    def test_get_students_by_level(self):
54        # we can filter out students of a certain level
55        my_filter1 = StudentsExportFilter(level=200)
56        result = get_students(self.app, stud_filter=my_filter1)
57        self.assertEqual(len(list(result)), 1)
58
59        my_filter2 = StudentsExportFilter(level=300)
60        result = get_students(self.app, stud_filter=my_filter2)
61        self.assertEqual(len(list(result)), 0)
62        return
63
64class StudentsExporterTest(StudentImportExportSetup):
65
66    layer = FunctionalLayer
67
68    def setUp(self):
69        super(StudentsExporterTest, self).setUp()
70        self.setup_for_export()
71        return
72
73    def test_ifaces(self):
74        # make sure we fullfill interface contracts
75        obj = StudentsExporter()
76        verifyObject(ICSVStudentExporter, obj)
77        verifyClass(ICSVStudentExporter, StudentsExporter)
78        return
79
80    def test_get_as_utility(self):
81        # we can get an student exporter as utility
82        result = queryUtility(ICSVExporter, name="students")
83        self.assertTrue(result is not None)
84        return
85
86    def test_export(self):
87        # we can really export students
88        # set values we can expect in export file
89        self.setup_student(self.student)
90        exporter = StudentsExporter()
91        exporter.export([self.student], self.outfile)
92        result = open(self.outfile, 'rb').read()
93        self.assertTrue(
94            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
95            'firstname,lastname,matric_number,middlename,nationality,officer_comment,'
96            'perm_address,personal_updated,'
97            'phone,reg_number,sex,student_id,suspended,suspended_comment,password,'
98            'state,history,certcode,is_postgrad,current_level,current_session\r\n'
99
100            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
101            'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,'
102            '+234-123-12345#,123,f,A111111,0,,,created'
103            in result
104            )
105        return
106
107    def test_export_all(self):
108        # we can really export students
109        # set values we can expect in export file
110        self.setup_student(self.student)
111        exporter = StudentsExporter()
112        exporter.export_all(self.app, self.outfile)
113        result = open(self.outfile, 'rb').read()
114        self.assertTrue(
115            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
116            'firstname,lastname,matric_number,middlename,nationality,officer_comment,'
117            'perm_address,personal_updated'
118            ',phone,reg_number,sex,student_id,suspended,suspended_comment,password,'
119            'state,history,certcode,is_postgrad,current_level,current_session\r\n'
120
121            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
122            'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,'
123            '+234-123-12345#,123,f,A111111,0,,,created'
124            in result
125            )
126        return
127
128    def test_export_student(self):
129        # we can export a single student
130        self.setup_student(self.student)
131        exporter = StudentsExporter()
132        exporter.export_student(self.student, self.outfile)
133        result = open(self.outfile, 'rb').read()
134        self.assertTrue(
135            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
136            'firstname,lastname,matric_number,middlename,nationality,officer_comment,'
137            'perm_address,personal_updated'
138            ',phone,reg_number,sex,student_id,suspended,suspended_comment,password,'
139            'state,history,certcode,is_postgrad,current_level,current_session\r\n'
140
141            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
142            'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,'
143            '+234-123-12345#,123,f,A111111,0,,,created'
144            in result
145            )
146        return
147
148
149class StudentStudyCourseExporterTest(StudentImportExportSetup):
150
151    layer = FunctionalLayer
152
153    def setUp(self):
154        super(StudentStudyCourseExporterTest, self).setUp()
155        self.setup_for_export()
156        return
157
158    def test_ifaces(self):
159        # make sure we fullfill interface contracts
160        obj = StudentStudyCourseExporter()
161        verifyObject(ICSVExporter, obj)
162        verifyClass(ICSVExporter, StudentStudyCourseExporter)
163        return
164
165    def test_get_as_utility(self):
166        # we can get an student exporter as utility
167        result = queryUtility(ICSVExporter, name="studentstudycourses")
168        self.assertTrue(result is not None)
169        return
170
171    def test_export_empty(self):
172        # we can export a nearly empty study course
173        study_course = StudentStudyCourse()
174        exporter = StudentStudyCourseExporter()
175        exporter.export([study_course], self.outfile)
176        result = open(self.outfile, 'rb').read()
177        self.assertEqual(
178            result,
179            'certificate,current_level,current_session,current_verdict,'
180            'entry_mode,entry_session,previous_verdict,student_id\r\n'
181
182            ',,,0,,,0,\r\n'
183            )
184        return
185
186    def test_export(self):
187        # we can really export study courses.
188        # set values we can expect in export file
189        self.setup_student(self.student)
190        study_course = self.student.get('studycourse')
191        exporter = StudentStudyCourseExporter()
192        exporter.export([study_course], self.outfile)
193        result = open(self.outfile, 'rb').read()
194        self.assertEqual(
195            result,
196            'certificate,current_level,current_session,current_verdict,'
197            'entry_mode,entry_session,previous_verdict,student_id\r\n'
198
199            'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
200            )
201        return
202
203    def test_export_all(self):
204        # we can really export students
205        # set values we can expect in export file
206        self.setup_student(self.student)
207        exporter = StudentStudyCourseExporter()
208        exporter.export_all(self.app, self.outfile)
209        result = open(self.outfile, 'rb').read()
210        self.assertEqual(
211            result,
212            'certificate,current_level,current_session,current_verdict,'
213            'entry_mode,entry_session,previous_verdict,student_id\r\n'
214
215            'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
216            )
217        return
218
219    def test_export_student(self):
220        # we can export studycourse of a certain student
221        self.setup_student(self.student)
222        exporter = StudentStudyCourseExporter()
223        exporter.export_student(self.student, self.outfile)
224        result = open(self.outfile, 'rb').read()
225        self.assertEqual(
226            result,
227            'certificate,current_level,current_session,current_verdict,'
228            'entry_mode,entry_session,previous_verdict,student_id\r\n'
229
230            'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
231            )
232        return
233
234class StudentStudyLevelExporterTest(StudentImportExportSetup):
235
236    layer = FunctionalLayer
237
238    def setUp(self):
239        super(StudentStudyLevelExporterTest, self).setUp()
240        self.setup_for_export()
241        return
242
243    def test_ifaces(self):
244        # make sure we fullfill interface contracts
245        obj = StudentStudyLevelExporter()
246        verifyObject(ICSVExporter, obj)
247        verifyClass(ICSVExporter, StudentStudyLevelExporter)
248        return
249
250    def test_get_as_utility(self):
251        # we can get an student exporter as utility
252        result = queryUtility(ICSVExporter, name="studentstudylevels")
253        self.assertTrue(result is not None)
254        return
255
256    def test_export_empty(self):
257        # we can export a nearly empty study level
258        study_level = StudentStudyLevel()
259        exporter = StudentStudyLevelExporter()
260        exporter.export([study_level], self.outfile)
261        result = open(self.outfile, 'rb').read()
262        self.assertEqual(
263            result,
264            'gpa,level,level_session,level_verdict,total_credits,'
265            'validated_by,validation_date,'
266            'student_id,number_of_tickets,certcode\r\n'
267            '0.0,,,0,0,,,,0,\r\n'
268            )
269        return
270
271    def test_export(self):
272        # we can really export study levels.
273        # set values we can expect in export file
274        self.setup_student(self.student)
275        study_course = self.student.get('studycourse')
276        study_level = study_course[study_course.keys()[0]]
277        exporter = StudentStudyLevelExporter()
278        exporter.export([study_level], self.outfile)
279        result = open(self.outfile, 'rb').read()
280        self.assertEqual(
281            result,
282            'gpa,level,level_session,level_verdict,total_credits,'
283            'validated_by,validation_date,'
284            'student_id,number_of_tickets,certcode\r\n'
285            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
286            )
287        return
288
289    def test_export_all(self):
290        # we can really export study levels
291        # set values we can expect in export file
292        self.setup_student(self.student)
293        exporter = StudentStudyLevelExporter()
294        exporter.export_all(self.app, self.outfile)
295        result = open(self.outfile, 'rb').read()
296        self.assertEqual(
297            result,
298            'gpa,level,level_session,level_verdict,total_credits,'
299            'validated_by,validation_date,'
300            'student_id,number_of_tickets,certcode\r\n'
301            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
302            )
303        return
304
305    def test_export_student(self):
306        # we can really export study levels of a certain student
307        self.setup_student(self.student)
308        exporter = StudentStudyLevelExporter()
309        exporter.export_student(self.student, self.outfile)
310        result = open(self.outfile, 'rb').read()
311        self.assertEqual(
312            result,
313            'gpa,level,level_session,level_verdict,total_credits,'
314            'validated_by,validation_date,'
315            'student_id,number_of_tickets,certcode\r\n'
316            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
317            )
318        return
319
320class CourseTicketExporterTest(StudentImportExportSetup):
321
322    layer = FunctionalLayer
323
324    def setUp(self):
325        super(CourseTicketExporterTest, self).setUp()
326        self.setup_for_export()
327        return
328
329    def test_ifaces(self):
330        # make sure we fullfill interface contracts
331        obj = CourseTicketExporter()
332        verifyObject(ICSVExporter, obj)
333        verifyClass(ICSVExporter, CourseTicketExporter)
334        return
335
336    def test_get_as_utility(self):
337        # we can get an student exporter as utility
338        result = queryUtility(ICSVExporter, name="coursetickets")
339        self.assertTrue(result is not None)
340        return
341
342    def test_export_empty(self):
343        # we can export a nearly empty course ticket
344        ticket = CourseTicket()
345        exporter = CourseTicketExporter()
346        exporter.export([ticket], self.outfile)
347        result = open(self.outfile, 'rb').read()
348        self.assertEqual(
349            result,
350            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
351            'passmark,score,semester,title,student_id,certcode\r\n'
352            '0,0,,,,,,0,,,,,,\r\n'
353            )
354        return
355
356    def test_export(self):
357        # we can really export course tickets.
358        # set values we can expect in export file
359        self.setup_student(self.student)
360        study_course = self.student.get('studycourse')
361        study_level = study_course[study_course.keys()[0]]
362        ticket = study_level['CRS1']
363        exporter = CourseTicketExporter()
364        exporter.export([ticket], self.outfile)
365        result = open(self.outfile, 'rb').read()
366        self.assertEqual(
367            result,
368            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
369            'passmark,score,semester,title,student_id,certcode\r\n'
370            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
371            )
372        return
373
374    def test_export_all(self):
375        # we can really export all course tickets
376        # set values we can expect in export file
377        self.setup_student(self.student)
378        exporter = CourseTicketExporter()
379        exporter.export_all(self.app, self.outfile)
380        result = open(self.outfile, 'rb').read()
381        self.assertEqual(
382            result,
383            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
384            'passmark,score,semester,title,student_id,certcode\r\n'
385            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
386            )
387        return
388
389    def test_export_student(self):
390        # we can really export all course tickets of a certain student
391        self.setup_student(self.student)
392        exporter = CourseTicketExporter()
393        exporter.export_student(self.student, self.outfile)
394        result = open(self.outfile, 'rb').read()
395        self.assertEqual(
396            result,
397            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
398            'passmark,score,semester,title,student_id,certcode\r\n'
399            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
400            )
401        return
402
403class PaymentsExporterTest(StudentImportExportSetup):
404
405    layer = FunctionalLayer
406
407    def setUp(self):
408        super(PaymentsExporterTest, self).setUp()
409        self.setup_for_export()
410        return
411
412    def test_ifaces(self):
413        # make sure we fullfill interface contracts
414        obj = PaymentsExporter()
415        verifyObject(ICSVExporter, obj)
416        verifyClass(ICSVExporter, PaymentsExporter)
417        return
418
419    def test_get_as_utility(self):
420        # we can get a payments exporter as utility
421        result = queryUtility(ICSVExporter, name="studentpayments")
422        self.assertTrue(result is not None)
423        return
424
425    def test_export_empty(self):
426        # we can export a nearly empty payment
427        payment = StudentOnlinePayment()
428        payment.creation_date = datetime.datetime(2012, 4, 1, 13, 12, 1)
429        exporter = PaymentsExporter()
430        exporter.export([payment], self.outfile)
431        result = open(self.outfile, 'rb').read()
432        self.assertEqual(
433            result,
434            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
435            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
436            'r_code,r_desc,student_id,student_state,current_session\r\n'
437
438            ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,,,\r\n'
439            )
440        return
441
442    def test_export(self):
443        # we can really export student payments.
444        # set values we can expect in export file
445        self.setup_student(self.student)
446        payment = self.student['payments']['my-payment']
447        exporter = PaymentsExporter()
448        exporter.export([payment], self.outfile)
449        result = open(self.outfile, 'rb').read()
450        self.assertEqual(
451            result,
452            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
453            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
454            'r_code,r_desc,student_id,student_state,current_session\r\n'
455
456            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
457            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
458            'r-code,,A111111,created,2012\r\n'
459            )
460        return
461
462    def test_export_all(self):
463        # we can really export all payments
464        # set values we can expect in export file
465        self.setup_student(self.student)
466        exporter = PaymentsExporter()
467        exporter.export_all(self.app, self.outfile)
468        result = open(self.outfile, 'rb').read()
469        self.assertEqual(
470            result,
471            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
472            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
473            'r_code,r_desc,student_id,student_state,current_session\r\n'
474
475            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
476            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
477            'r-code,,A111111,created,2012\r\n'
478            )
479        return
480
481    def test_export_student(self):
482        # we can really export all payments of a certain student
483        # set values we can expect in export file
484        self.setup_student(self.student)
485        exporter = PaymentsExporter()
486        exporter.export_student(self.student, self.outfile)
487        result = open(self.outfile, 'rb').read()
488        self.assertEqual(
489            result,
490            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
491            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
492            'r_code,r_desc,student_id,student_state,current_session\r\n'
493
494            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
495            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
496            'r-code,,A111111,created,2012\r\n'
497            )
498        return
499
500class BedTicketsExporterTest(StudentImportExportSetup):
501
502    layer = FunctionalLayer
503
504    def setUp(self):
505        super(BedTicketsExporterTest, self).setUp()
506        self.setup_for_export()
507        return
508
509    def test_ifaces(self):
510        # make sure we fullfill interface contracts
511        obj = BedTicketsExporter()
512        verifyObject(ICSVExporter, obj)
513        verifyClass(ICSVExporter, BedTicketsExporter)
514        return
515
516    def test_get_as_utility(self):
517        # we can get a bedtickets exporter as utility
518        result = queryUtility(ICSVExporter, name="bedtickets")
519        self.assertTrue(result is not None)
520        return
521
522    def test_export_empty(self):
523        # we can export a nearly empty bedticket
524        bedticket = BedTicket()
525        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
526        bedticket.bed = bed
527        exporter = BedTicketsExporter()
528        exporter.export([bedticket], self.outfile)
529        result = open(self.outfile, 'rb').read()
530        self.assertMatches(
531            result,
532            'bed,bed_coordinates,bed_type,booking_code,booking_date,'
533            'booking_session,student_id,actual_bed_type\r\n'
534            'hall-1_A_101_A,,,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,,,regular_male_fr\r\n'
535            )
536        return
537
538    def test_export(self):
539        # we can really export student bedtickets.
540        # set values we can expect in export file
541        self.setup_student(self.student)
542        bedticket = self.student['accommodation']['2004']
543        exporter = BedTicketsExporter()
544        exporter.export([bedticket], self.outfile)
545        result = open(self.outfile, 'rb').read()
546        self.assertMatches(
547            result,
548            'bed,bed_coordinates,bed_type,booking_code,booking_date,'
549            'booking_session,student_id,actual_bed_type\r\n'
550            'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,'
551            'A111111,regular_male_fr\r\n'
552            )
553        return
554
555    def test_export_all(self):
556        # we can really export all bedtickets
557        # set values we can expect in export file
558        self.setup_student(self.student)
559        exporter = BedTicketsExporter()
560        exporter.export_all(self.app, self.outfile)
561        result = open(self.outfile, 'rb').read()
562        self.assertMatches(
563            result,
564            'bed,bed_coordinates,bed_type,booking_code,booking_date,'
565            'booking_session,student_id,actual_bed_type\r\n'
566            'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,'
567            'A111111,regular_male_fr\r\n'
568            )
569        return
570
571    def test_export_student(self):
572        # we can really export all bedtickets of a certain student
573        # set values we can expect in export file
574        self.setup_student(self.student)
575        exporter = BedTicketsExporter()
576        exporter.export_student(self.student, self.outfile)
577        result = open(self.outfile, 'rb').read()
578        self.assertMatches(
579            result,
580            'bed,bed_coordinates,bed_type,booking_code,booking_date,'
581            'booking_session,student_id,actual_bed_type\r\n'
582            'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,'
583            'A111111,regular_male_fr\r\n'
584            )
585        return
586
587class StudentPaymentsOverviewExporterTest(StudentImportExportSetup):
588
589    layer = FunctionalLayer
590
591    def setUp(self):
592        super(StudentPaymentsOverviewExporterTest, self).setUp()
593        self.setup_for_export()
594        return
595
596    def test_ifaces(self):
597        # make sure we fullfill interface contracts
598        obj = StudentPaymentsOverviewExporter()
599        verifyObject(ICSVExporter, obj)
600        verifyClass(ICSVExporter, StudentPaymentsOverviewExporter)
601        return
602
603    def test_get_as_utility(self):
604        # we can get a payments exporter as utility
605        result = queryUtility(ICSVExporter, name="paymentsoverview")
606        self.assertTrue(result is not None)
607        return
608
609    def test_export(self):
610        self.setup_student(self.student)
611        exporter = StudentPaymentsOverviewExporter()
612        exporter.export([self.student], self.outfile)
613        result = open(self.outfile, 'rb').read()
614        self.assertEqual(
615            'student_id,state,certcode,faccode,depcode,is_postgrad,'
616            'current_level,current_session,'
617            '%s\r\n'
618            'A111111,created,CERT1,NA,NA,0,200,2012,'
619            ',,,,,,,,,\r\n' % year_range_str,
620            result
621            )
622        return
623
624    def test_export_all(self):
625        # we can really export students
626        # set values we can expect in export file
627        self.setup_student(self.student)
628        # We add successful payments
629        payment = StudentOnlinePayment()
630        payment.p_id = 'my-id'
631        payment.p_session = 2009
632        payment.amount_auth = 12.12
633        payment.p_state = u'paid'
634        self.student['payments']['my-2ndpayment'] = payment
635        exporter = StudentPaymentsOverviewExporter()
636        exporter.export_all(self.app, self.outfile)
637        result = open(self.outfile, 'rb').read()
638        self.assertEqual(
639            'student_id,state,certcode,faccode,depcode,is_postgrad,'
640            'current_level,current_session,'
641            '%s\r\nA111111,created,CERT1,NA,NA,0,'
642            '200,2012,,,,,,,12.12,,,\r\n' % year_range_str,
643            result
644            )
645        return
646
647class StudentStudyLevelsOverviewExporterTest(StudentImportExportSetup):
648
649    layer = FunctionalLayer
650
651    def setUp(self):
652        super(StudentStudyLevelsOverviewExporterTest, self).setUp()
653        self.setup_for_export()
654        return
655
656    def test_ifaces(self):
657        obj = StudentStudyLevelsOverviewExporter()
658        verifyObject(ICSVExporter, obj)
659        verifyClass(ICSVExporter, StudentStudyLevelsOverviewExporter)
660        return
661
662    def test_get_as_utility(self):
663        result = queryUtility(ICSVExporter, name="studylevelsoverview")
664        self.assertTrue(result is not None)
665        return
666
667    def test_export(self):
668        self.setup_student(self.student)
669        exporter = StudentStudyLevelsOverviewExporter()
670        exporter.export([self.student], self.outfile)
671        result = open(self.outfile, 'rb').read()
672        self.assertEqual(
673             'student_id,state,certcode,faccode,depcode,is_postgrad,'
674             'entry_session,current_level,current_session,'
675             '10,100,110,120,200,210,220,300,310,320,400,410,420,500,'
676             '510,520,600,610,620,700,710,720,800,810,820,900,910,920,999\r\n'
677             'A111111,created,CERT1,NA,NA,0,2010,200,2012,,2012'
678             ',,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n',
679            result
680            )
681        return
682
683    def test_export_all(self):
684        self.setup_student(self.student)
685        exporter = StudentStudyLevelsOverviewExporter()
686        exporter.export_all(self.app, self.outfile)
687        result = open(self.outfile, 'rb').read()
688        self.assertEqual(
689            'student_id,state,certcode,faccode,depcode,is_postgrad,'
690            'entry_session,current_level,current_session,'
691            '10,100,110,120,200,210,220,300,310,320,400,410,420,500,'
692            '510,520,600,610,620,700,710,720,800,810,820,900,910,920,999\r\n'
693            'A111111,created,CERT1,NA,NA,0,2010,200,2012,,2012'
694            ',,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n',
695            result
696            )
697        return
Note: See TracBrowser for help on using the repository browser.