Changeset 9427 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 26 Oct 2012, 17:57:26 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9316 r9427 5 5 from waeup.kofa.students.export import ( 6 6 StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter, 7 CourseTicketExporter, PaymentsExporter )7 CourseTicketExporter, PaymentsExporter, BedTicketsExporter) 8 8 from waeup.kofa.students.payments import StudentOnlinePayment 9 from waeup.kofa.students.accommodation import BedTicket 9 10 from waeup.kofa.students.studycourse import StudentStudyCourse 10 11 from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket … … 440 441 ) 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
Note: See TracChangeset for help on using the changeset viewer.