Ignore:
Timestamp:
27 Jan 2015, 14:48:22 (10 years ago)
Author:
Henrik Bettermann
Message:

Add exporter methods and export page to filter student data exports by entering a list of student ids.

File:
1 edited

Legend:

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

    r12393 r12518  
    262262        return
    263263
     264    def test_export_selected(self):
     265        # we can export a filtered set of students (filtered by session/level)
     266        self.setup_student(self.student)
     267        self.app['students'].addStudent(self.student)
     268        notify(grok.ObjectModifiedEvent(self.student))
     269        exporter = StudentExporter()
     270        exporter.export_selected(
     271            self.app, self.outfile, selected=['A111111'])
     272        result1 = open(self.outfile, 'rb').read()
     273        exporter.export_selected(
     274            self.app, self.outfile, selected=[])
     275        result2 = open(self.outfile, 'rb').read()
     276        self.assertTrue(self.std_csv_entry in result1)
     277        self.assertFalse(self.std_csv_entry in result2)
     278        return
     279
    264280    def test_export_filtered_by_dept(self):
    265281        # we can export a set of students filtered by department
     
    405421        return
    406422
     423    def test_export_selected(self):
     424        # we can export a filtered set of students (filtered by session/level)
     425        self.setup_student(self.student)
     426        self.app['students'].addStudent(self.student)
     427        notify(grok.ObjectModifiedEvent(self.student))
     428        exporter = StudentStudyCourseExporter()
     429        exporter.export_selected(
     430            self.app, self.outfile, selected=['A111111'])
     431        result = open(self.outfile, 'rb').read()
     432        self.assertEqual(
     433            result,
     434            'certificate,current_level,current_session,current_verdict,'
     435            'entry_mode,entry_session,previous_verdict,student_id\r\n'
     436
     437            'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     438            )
     439        return
    407440
    408441
     
    502535        exporter.export_filtered(
    503536            self.student, self.outfile)
     537        result = open(self.outfile, 'rb').read()
     538        self.assertEqual(
     539            result,
     540            'gpa,level,level_session,level_verdict,total_credits,'
     541            'validated_by,validation_date,'
     542            'student_id,number_of_tickets,certcode\r\n'
     543            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
     544            )
     545        return
     546
     547    def test_export_selected(self):
     548        # we can export studylevels of a filtered set of students
     549        self.setup_student(self.student)
     550        self.app['students'].addStudent(self.student)
     551        notify(grok.ObjectModifiedEvent(self.student))
     552
     553        exporter = StudentStudyLevelExporter()
     554        exporter.export_selected(
     555            self.app, self.outfile, selected=['A111111'])
    504556        result = open(self.outfile, 'rb').read()
    505557        self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.