1 | import datetime |
---|
2 | from zope.component import queryUtility |
---|
3 | from zope.interface.verify import verifyObject, verifyClass |
---|
4 | from waeup.kofa.interfaces import ICSVExporter |
---|
5 | from waeup.kofa.students.export import ( |
---|
6 | StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter, |
---|
7 | CourseTicketExporter, PaymentsExporter, BedTicketsExporter) |
---|
8 | from waeup.kofa.students.payments import StudentOnlinePayment |
---|
9 | from waeup.kofa.students.accommodation import BedTicket |
---|
10 | from waeup.kofa.students.studycourse import StudentStudyCourse |
---|
11 | from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket |
---|
12 | from waeup.kofa.students.tests.test_batching import StudentImportExportSetup |
---|
13 | from waeup.kofa.testing import FunctionalLayer |
---|
14 | |
---|
15 | class StudentsExporterTest(StudentImportExportSetup): |
---|
16 | |
---|
17 | layer = FunctionalLayer |
---|
18 | |
---|
19 | def setUp(self): |
---|
20 | super(StudentsExporterTest, self).setUp() |
---|
21 | self.setup_for_export() |
---|
22 | return |
---|
23 | |
---|
24 | def test_ifaces(self): |
---|
25 | # make sure we fullfill interface contracts |
---|
26 | obj = StudentsExporter() |
---|
27 | verifyObject(ICSVExporter, obj) |
---|
28 | verifyClass(ICSVExporter, StudentsExporter) |
---|
29 | return |
---|
30 | |
---|
31 | def test_get_as_utility(self): |
---|
32 | # we can get an student exporter as utility |
---|
33 | result = queryUtility(ICSVExporter, name="students") |
---|
34 | self.assertTrue(result is not None) |
---|
35 | return |
---|
36 | |
---|
37 | def test_export(self): |
---|
38 | # we can really export students |
---|
39 | # set values we can expect in export file |
---|
40 | self.setup_student(self.student) |
---|
41 | exporter = StudentsExporter() |
---|
42 | exporter.export([self.student], self.outfile) |
---|
43 | result = open(self.outfile, 'rb').read() |
---|
44 | self.assertTrue( |
---|
45 | 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' |
---|
46 | 'firstname,lastname,matric_number,middlename,nationality,' |
---|
47 | 'perm_address,phone,reg_number,sex,student_id,suspended,password,' |
---|
48 | 'state,history,certcode,is_postgrad,current_level,current_session\r\n' |
---|
49 | |
---|
50 | 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' |
---|
51 | 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' |
---|
52 | '+234-123-12345#,123,f,A111111,0,,created' |
---|
53 | in result |
---|
54 | ) |
---|
55 | return |
---|
56 | |
---|
57 | def test_export_all(self): |
---|
58 | # we can really export students |
---|
59 | # set values we can expect in export file |
---|
60 | self.setup_student(self.student) |
---|
61 | exporter = StudentsExporter() |
---|
62 | exporter.export_all(self.app, self.outfile) |
---|
63 | result = open(self.outfile, 'rb').read() |
---|
64 | self.assertTrue( |
---|
65 | 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' |
---|
66 | 'firstname,lastname,matric_number,middlename,nationality,' |
---|
67 | 'perm_address,phone,reg_number,sex,student_id,suspended,password,' |
---|
68 | 'state,history,certcode,is_postgrad,current_level,current_session\r\n' |
---|
69 | |
---|
70 | 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' |
---|
71 | 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' |
---|
72 | '+234-123-12345#,123,f,A111111,0,,created' |
---|
73 | in result |
---|
74 | ) |
---|
75 | return |
---|
76 | |
---|
77 | def test_export_student(self): |
---|
78 | # we can export a single student |
---|
79 | self.setup_student(self.student) |
---|
80 | exporter = StudentsExporter() |
---|
81 | exporter.export_student(self.student, self.outfile) |
---|
82 | result = open(self.outfile, 'rb').read() |
---|
83 | self.assertTrue( |
---|
84 | 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' |
---|
85 | 'firstname,lastname,matric_number,middlename,nationality,' |
---|
86 | 'perm_address,phone,reg_number,sex,student_id,suspended,password,' |
---|
87 | 'state,history,certcode,is_postgrad,current_level,current_session\r\n' |
---|
88 | |
---|
89 | 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' |
---|
90 | 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' |
---|
91 | '+234-123-12345#,123,f,A111111,0,,created' |
---|
92 | in result |
---|
93 | ) |
---|
94 | return |
---|
95 | |
---|
96 | |
---|
97 | class StudentStudyCourseExporterTest(StudentImportExportSetup): |
---|
98 | |
---|
99 | layer = FunctionalLayer |
---|
100 | |
---|
101 | def setUp(self): |
---|
102 | super(StudentStudyCourseExporterTest, self).setUp() |
---|
103 | self.setup_for_export() |
---|
104 | return |
---|
105 | |
---|
106 | def test_ifaces(self): |
---|
107 | # make sure we fullfill interface contracts |
---|
108 | obj = StudentStudyCourseExporter() |
---|
109 | verifyObject(ICSVExporter, obj) |
---|
110 | verifyClass(ICSVExporter, StudentStudyCourseExporter) |
---|
111 | return |
---|
112 | |
---|
113 | def test_get_as_utility(self): |
---|
114 | # we can get an student exporter as utility |
---|
115 | result = queryUtility(ICSVExporter, name="studentstudycourses") |
---|
116 | self.assertTrue(result is not None) |
---|
117 | return |
---|
118 | |
---|
119 | def test_export_empty(self): |
---|
120 | # we can export a nearly empty study course |
---|
121 | study_course = StudentStudyCourse() |
---|
122 | exporter = StudentStudyCourseExporter() |
---|
123 | exporter.export([study_course], self.outfile) |
---|
124 | result = open(self.outfile, 'rb').read() |
---|
125 | self.assertEqual( |
---|
126 | result, |
---|
127 | 'certificate,current_level,current_session,current_verdict,' |
---|
128 | 'entry_mode,entry_session,previous_verdict,student_id\r\n' |
---|
129 | |
---|
130 | ',,,0,,,0,\r\n' |
---|
131 | ) |
---|
132 | return |
---|
133 | |
---|
134 | def test_export(self): |
---|
135 | # we can really export study courses. |
---|
136 | # set values we can expect in export file |
---|
137 | self.setup_student(self.student) |
---|
138 | study_course = self.student.get('studycourse') |
---|
139 | exporter = StudentStudyCourseExporter() |
---|
140 | exporter.export([study_course], self.outfile) |
---|
141 | result = open(self.outfile, 'rb').read() |
---|
142 | self.assertEqual( |
---|
143 | result, |
---|
144 | 'certificate,current_level,current_session,current_verdict,' |
---|
145 | 'entry_mode,entry_session,previous_verdict,student_id\r\n' |
---|
146 | |
---|
147 | 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' |
---|
148 | ) |
---|
149 | return |
---|
150 | |
---|
151 | def test_export_all(self): |
---|
152 | # we can really export students |
---|
153 | # set values we can expect in export file |
---|
154 | self.setup_student(self.student) |
---|
155 | exporter = StudentStudyCourseExporter() |
---|
156 | exporter.export_all(self.app, self.outfile) |
---|
157 | result = open(self.outfile, 'rb').read() |
---|
158 | self.assertEqual( |
---|
159 | result, |
---|
160 | 'certificate,current_level,current_session,current_verdict,' |
---|
161 | 'entry_mode,entry_session,previous_verdict,student_id\r\n' |
---|
162 | |
---|
163 | 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' |
---|
164 | ) |
---|
165 | return |
---|
166 | |
---|
167 | def test_export_student(self): |
---|
168 | # we can export studycourse of a certain student |
---|
169 | self.setup_student(self.student) |
---|
170 | exporter = StudentStudyCourseExporter() |
---|
171 | exporter.export_student(self.student, self.outfile) |
---|
172 | result = open(self.outfile, 'rb').read() |
---|
173 | self.assertEqual( |
---|
174 | result, |
---|
175 | 'certificate,current_level,current_session,current_verdict,' |
---|
176 | 'entry_mode,entry_session,previous_verdict,student_id\r\n' |
---|
177 | |
---|
178 | 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' |
---|
179 | ) |
---|
180 | return |
---|
181 | |
---|
182 | class StudentStudyLevelExporterTest(StudentImportExportSetup): |
---|
183 | |
---|
184 | layer = FunctionalLayer |
---|
185 | |
---|
186 | def setUp(self): |
---|
187 | super(StudentStudyLevelExporterTest, self).setUp() |
---|
188 | self.setup_for_export() |
---|
189 | return |
---|
190 | |
---|
191 | def test_ifaces(self): |
---|
192 | # make sure we fullfill interface contracts |
---|
193 | obj = StudentStudyLevelExporter() |
---|
194 | verifyObject(ICSVExporter, obj) |
---|
195 | verifyClass(ICSVExporter, StudentStudyLevelExporter) |
---|
196 | return |
---|
197 | |
---|
198 | def test_get_as_utility(self): |
---|
199 | # we can get an student exporter as utility |
---|
200 | result = queryUtility(ICSVExporter, name="studentstudylevels") |
---|
201 | self.assertTrue(result is not None) |
---|
202 | return |
---|
203 | |
---|
204 | def test_export_empty(self): |
---|
205 | # we can export a nearly empty study level |
---|
206 | study_level = StudentStudyLevel() |
---|
207 | exporter = StudentStudyLevelExporter() |
---|
208 | exporter.export([study_level], self.outfile) |
---|
209 | result = open(self.outfile, 'rb').read() |
---|
210 | self.assertEqual( |
---|
211 | result, |
---|
212 | 'level,level_session,level_verdict,validated_by,validation_date,' |
---|
213 | 'student_id,number_of_tickets,certcode\r\n' |
---|
214 | ',,0,,,,0,\r\n' |
---|
215 | ) |
---|
216 | return |
---|
217 | |
---|
218 | def test_export(self): |
---|
219 | # we can really export study levels. |
---|
220 | # set values we can expect in export file |
---|
221 | self.setup_student(self.student) |
---|
222 | study_course = self.student.get('studycourse') |
---|
223 | study_level = study_course[study_course.keys()[0]] |
---|
224 | exporter = StudentStudyLevelExporter() |
---|
225 | exporter.export([study_level], self.outfile) |
---|
226 | result = open(self.outfile, 'rb').read() |
---|
227 | self.assertEqual( |
---|
228 | result, |
---|
229 | 'level,level_session,level_verdict,validated_by,validation_date,' |
---|
230 | 'student_id,number_of_tickets,certcode\r\n' |
---|
231 | '100,2012,A,,,A111111,1,CERT1\r\n' |
---|
232 | ) |
---|
233 | return |
---|
234 | |
---|
235 | def test_export_all(self): |
---|
236 | # we can really export study levels |
---|
237 | # set values we can expect in export file |
---|
238 | self.setup_student(self.student) |
---|
239 | exporter = StudentStudyLevelExporter() |
---|
240 | exporter.export_all(self.app, self.outfile) |
---|
241 | result = open(self.outfile, 'rb').read() |
---|
242 | self.assertEqual( |
---|
243 | result, |
---|
244 | 'level,level_session,level_verdict,validated_by,validation_date,' |
---|
245 | 'student_id,number_of_tickets,certcode\r\n' |
---|
246 | '100,2012,A,,,A111111,1,CERT1\r\n' |
---|
247 | ) |
---|
248 | return |
---|
249 | |
---|
250 | def test_export_student(self): |
---|
251 | # we can really export study levels of a certain student |
---|
252 | self.setup_student(self.student) |
---|
253 | exporter = StudentStudyLevelExporter() |
---|
254 | exporter.export_student(self.student, self.outfile) |
---|
255 | result = open(self.outfile, 'rb').read() |
---|
256 | self.assertEqual( |
---|
257 | result, |
---|
258 | 'level,level_session,level_verdict,validated_by,validation_date,' |
---|
259 | 'student_id,number_of_tickets,certcode\r\n' |
---|
260 | '100,2012,A,,,A111111,1,CERT1\r\n' |
---|
261 | ) |
---|
262 | return |
---|
263 | |
---|
264 | class CourseTicketExporterTest(StudentImportExportSetup): |
---|
265 | |
---|
266 | layer = FunctionalLayer |
---|
267 | |
---|
268 | def setUp(self): |
---|
269 | super(CourseTicketExporterTest, self).setUp() |
---|
270 | self.setup_for_export() |
---|
271 | return |
---|
272 | |
---|
273 | def test_ifaces(self): |
---|
274 | # make sure we fullfill interface contracts |
---|
275 | obj = CourseTicketExporter() |
---|
276 | verifyObject(ICSVExporter, obj) |
---|
277 | verifyClass(ICSVExporter, CourseTicketExporter) |
---|
278 | return |
---|
279 | |
---|
280 | def test_get_as_utility(self): |
---|
281 | # we can get an student exporter as utility |
---|
282 | result = queryUtility(ICSVExporter, name="coursetickets") |
---|
283 | self.assertTrue(result is not None) |
---|
284 | return |
---|
285 | |
---|
286 | def test_export_empty(self): |
---|
287 | # we can export a nearly empty course ticket |
---|
288 | ticket = CourseTicket() |
---|
289 | exporter = CourseTicketExporter() |
---|
290 | exporter.export([ticket], self.outfile) |
---|
291 | result = open(self.outfile, 'rb').read() |
---|
292 | self.assertEqual( |
---|
293 | result, |
---|
294 | 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' |
---|
295 | 'passmark,score,semester,title,student_id,certcode\r\n' |
---|
296 | '0,0,,,,,,0,,0,,,,\r\n' |
---|
297 | ) |
---|
298 | return |
---|
299 | |
---|
300 | def test_export(self): |
---|
301 | # we can really export course tickets. |
---|
302 | # set values we can expect in export file |
---|
303 | self.setup_student(self.student) |
---|
304 | study_course = self.student.get('studycourse') |
---|
305 | study_level = study_course[study_course.keys()[0]] |
---|
306 | ticket = study_level['CRS1'] |
---|
307 | exporter = CourseTicketExporter() |
---|
308 | exporter.export([ticket], self.outfile) |
---|
309 | result = open(self.outfile, 'rb').read() |
---|
310 | self.assertEqual( |
---|
311 | result, |
---|
312 | 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' |
---|
313 | 'passmark,score,semester,title,student_id,certcode\r\n' |
---|
314 | '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n' |
---|
315 | ) |
---|
316 | return |
---|
317 | |
---|
318 | def test_export_all(self): |
---|
319 | # we can really export all course tickets |
---|
320 | # set values we can expect in export file |
---|
321 | self.setup_student(self.student) |
---|
322 | exporter = CourseTicketExporter() |
---|
323 | exporter.export_all(self.app, self.outfile) |
---|
324 | result = open(self.outfile, 'rb').read() |
---|
325 | self.assertEqual( |
---|
326 | result, |
---|
327 | 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' |
---|
328 | 'passmark,score,semester,title,student_id,certcode\r\n' |
---|
329 | '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n' |
---|
330 | ) |
---|
331 | return |
---|
332 | |
---|
333 | def test_export_student(self): |
---|
334 | # we can really export all course tickets of a certain student |
---|
335 | self.setup_student(self.student) |
---|
336 | exporter = CourseTicketExporter() |
---|
337 | exporter.export_student(self.student, self.outfile) |
---|
338 | result = open(self.outfile, 'rb').read() |
---|
339 | self.assertEqual( |
---|
340 | result, |
---|
341 | 'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,' |
---|
342 | 'passmark,score,semester,title,student_id,certcode\r\n' |
---|
343 | '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n' |
---|
344 | ) |
---|
345 | return |
---|
346 | |
---|
347 | class PaymentsExporterTest(StudentImportExportSetup): |
---|
348 | |
---|
349 | layer = FunctionalLayer |
---|
350 | |
---|
351 | def setUp(self): |
---|
352 | super(PaymentsExporterTest, self).setUp() |
---|
353 | self.setup_for_export() |
---|
354 | return |
---|
355 | |
---|
356 | def test_ifaces(self): |
---|
357 | # make sure we fullfill interface contracts |
---|
358 | obj = PaymentsExporter() |
---|
359 | verifyObject(ICSVExporter, obj) |
---|
360 | verifyClass(ICSVExporter, PaymentsExporter) |
---|
361 | return |
---|
362 | |
---|
363 | def test_get_as_utility(self): |
---|
364 | # we can get a payments exporter as utility |
---|
365 | result = queryUtility(ICSVExporter, name="studentpayments") |
---|
366 | self.assertTrue(result is not None) |
---|
367 | return |
---|
368 | |
---|
369 | def test_export_empty(self): |
---|
370 | # we can export a nearly empty payment |
---|
371 | payment = StudentOnlinePayment() |
---|
372 | payment.creation_date = datetime.datetime(2012, 4, 1, 13, 12, 1) |
---|
373 | exporter = PaymentsExporter() |
---|
374 | exporter.export([payment], self.outfile) |
---|
375 | result = open(self.outfile, 'rb').read() |
---|
376 | self.assertEqual( |
---|
377 | result, |
---|
378 | 'ac,amount_auth,creation_date,p_category,p_current,p_id,' |
---|
379 | 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' |
---|
380 | 'r_code,r_desc,student_id,student_state,current_session\r\n' |
---|
381 | |
---|
382 | ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,,,\r\n' |
---|
383 | ) |
---|
384 | return |
---|
385 | |
---|
386 | def test_export(self): |
---|
387 | # we can really export student payments. |
---|
388 | # set values we can expect in export file |
---|
389 | self.setup_student(self.student) |
---|
390 | payment = self.student['payments']['my-payment'] |
---|
391 | exporter = PaymentsExporter() |
---|
392 | exporter.export([payment], self.outfile) |
---|
393 | result = open(self.outfile, 'rb').read() |
---|
394 | self.assertEqual( |
---|
395 | result, |
---|
396 | 'ac,amount_auth,creation_date,p_category,p_current,p_id,' |
---|
397 | 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' |
---|
398 | 'r_code,r_desc,student_id,student_state,current_session\r\n' |
---|
399 | |
---|
400 | '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' |
---|
401 | 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' |
---|
402 | 'r-code,,A111111,created,2012\r\n' |
---|
403 | ) |
---|
404 | return |
---|
405 | |
---|
406 | def test_export_all(self): |
---|
407 | # we can really export all payments |
---|
408 | # set values we can expect in export file |
---|
409 | self.setup_student(self.student) |
---|
410 | exporter = PaymentsExporter() |
---|
411 | exporter.export_all(self.app, self.outfile) |
---|
412 | result = open(self.outfile, 'rb').read() |
---|
413 | self.assertEqual( |
---|
414 | result, |
---|
415 | 'ac,amount_auth,creation_date,p_category,p_current,p_id,' |
---|
416 | 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' |
---|
417 | 'r_code,r_desc,student_id,student_state,current_session\r\n' |
---|
418 | |
---|
419 | '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' |
---|
420 | 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' |
---|
421 | 'r-code,,A111111,created,2012\r\n' |
---|
422 | ) |
---|
423 | return |
---|
424 | |
---|
425 | def test_export_student(self): |
---|
426 | # we can really export all payments of a certain student |
---|
427 | # set values we can expect in export file |
---|
428 | self.setup_student(self.student) |
---|
429 | exporter = PaymentsExporter() |
---|
430 | exporter.export_student(self.student, 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 | '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' |
---|
439 | 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' |
---|
440 | 'r-code,,A111111,created,2012\r\n' |
---|
441 | ) |
---|
442 | return |
---|
443 | |
---|
444 | class BedTicketsExporterTest(StudentImportExportSetup): |
---|
445 | |
---|
446 | layer = FunctionalLayer |
---|
447 | |
---|
448 | def setUp(self): |
---|
449 | super(BedTicketsExporterTest, self).setUp() |
---|
450 | self.setup_for_export() |
---|
451 | return |
---|
452 | |
---|
453 | def test_ifaces(self): |
---|
454 | # make sure we fullfill interface contracts |
---|
455 | obj = BedTicketsExporter() |
---|
456 | verifyObject(ICSVExporter, obj) |
---|
457 | verifyClass(ICSVExporter, BedTicketsExporter) |
---|
458 | return |
---|
459 | |
---|
460 | def test_get_as_utility(self): |
---|
461 | # we can get a bedtickets exporter as utility |
---|
462 | result = queryUtility(ICSVExporter, name="bedtickets") |
---|
463 | self.assertTrue(result is not None) |
---|
464 | return |
---|
465 | |
---|
466 | def test_export_empty(self): |
---|
467 | # we can export a nearly empty bedticket |
---|
468 | bedticket = BedTicket() |
---|
469 | bed = self.app['hostels']['hall-1']['hall-1_A_101_A'] |
---|
470 | bedticket.bed = bed |
---|
471 | exporter = BedTicketsExporter() |
---|
472 | exporter.export([bedticket], self.outfile) |
---|
473 | result = open(self.outfile, 'rb').read() |
---|
474 | self.assertMatches( |
---|
475 | result, |
---|
476 | 'bed,bed_coordinates,bed_type,booking_code,booking_date,' |
---|
477 | 'booking_session,student_id,actual_bed_type\r\n' |
---|
478 | 'hall-1_A_101_A,,,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,,,regular_male_fr\r\n' |
---|
479 | ) |
---|
480 | return |
---|
481 | |
---|
482 | def test_export(self): |
---|
483 | # we can really export student bedtickets. |
---|
484 | # set values we can expect in export file |
---|
485 | self.setup_student(self.student) |
---|
486 | bedticket = self.student['accommodation']['2004'] |
---|
487 | exporter = BedTicketsExporter() |
---|
488 | exporter.export([bedticket], self.outfile) |
---|
489 | result = open(self.outfile, 'rb').read() |
---|
490 | self.assertMatches( |
---|
491 | result, |
---|
492 | 'bed,bed_coordinates,bed_type,booking_code,booking_date,' |
---|
493 | 'booking_session,student_id,actual_bed_type\r\n' |
---|
494 | 'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,' |
---|
495 | 'A111111,regular_male_fr\r\n' |
---|
496 | ) |
---|
497 | return |
---|
498 | |
---|
499 | def test_export_all(self): |
---|
500 | # we can really export all bedtickets |
---|
501 | # set values we can expect in export file |
---|
502 | self.setup_student(self.student) |
---|
503 | exporter = BedTicketsExporter() |
---|
504 | exporter.export_all(self.app, self.outfile) |
---|
505 | result = open(self.outfile, 'rb').read() |
---|
506 | self.assertMatches( |
---|
507 | result, |
---|
508 | 'bed,bed_coordinates,bed_type,booking_code,booking_date,' |
---|
509 | 'booking_session,student_id,actual_bed_type\r\n' |
---|
510 | 'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,' |
---|
511 | 'A111111,regular_male_fr\r\n' |
---|
512 | ) |
---|
513 | return |
---|
514 | |
---|
515 | def test_export_student(self): |
---|
516 | # we can really export all bedtickets of a certain student |
---|
517 | # set values we can expect in export file |
---|
518 | self.setup_student(self.student) |
---|
519 | exporter = BedTicketsExporter() |
---|
520 | exporter.export_student(self.student, self.outfile) |
---|
521 | result = open(self.outfile, 'rb').read() |
---|
522 | self.assertMatches( |
---|
523 | result, |
---|
524 | 'bed,bed_coordinates,bed_type,booking_code,booking_date,' |
---|
525 | 'booking_session,student_id,actual_bed_type\r\n' |
---|
526 | 'hall-1_A_101_A,,any bed type,,<YYYY-MM-DD hh:mm:ss>.<6-DIGITS>,2004,' |
---|
527 | 'A111111,regular_male_fr\r\n' |
---|
528 | ) |
---|
529 | return |
---|