Ignore:
Timestamp:
8 Jan 2013, 13:33:14 (12 years ago)
Author:
Henrik Bettermann
Message:

Use keywords not only to filter students but also to restrict access to coursetickets which belong to the course so that lecturers (who gain access to courses) can download only coursetickets of their own course.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/tests
Files:
2 edited

Legend:

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

    r9843 r9844  
    28352835            )
    28362836
    2837     def test_course_export(self):
     2837    def test_course_export_students(self):
    28382838        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    28392839        course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1'
     
    28802880            '- discarded: job_id=%s' % job_id in logcontent
    28812881            )
     2882
     2883    def test_course_export_coursetickets(self):
     2884        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     2885        course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1'
     2886        self.browser.open(course1_path)
     2887        self.browser.getLink("Export student data").click()
     2888        self.browser.getControl("Configure new export").click()
     2889        self.browser.getControl(name="exporter").value = ['coursetickets']
     2890        self.browser.getControl(name="session").value = ['2004']
     2891        self.browser.getControl(name="level").value = ['100']
     2892        self.browser.getControl("Create CSV file").click()
     2893
     2894        # When the job is finished and we reload the page...
     2895        job_id = self.wait_for_export_job_completed()
     2896        self.browser.open(course1_path + '/exports')
     2897        # ... the csv file can be downloaded ...
     2898        self.browser.getLink("Download").click()
     2899        self.assertEqual(self.browser.headers['content-type'],
     2900            'text/csv; charset=UTF-8')
     2901        self.assertTrue(
     2902            'filename="WAeUP.Kofa_coursetickets_%s.csv' % job_id in
     2903            self.browser.headers['content-disposition'])
     2904        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     2905        job_id = self.app['datacenter'].running_exports[0][0]
     2906        # ... and discarded
     2907        self.browser.open(course1_path + '/exports')
     2908        self.browser.getControl("Discard").click()
     2909        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     2910        # Creation, downloading and discarding is logged
     2911        logfile = os.path.join(
     2912            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     2913        logcontent = open(logfile).read()
     2914        self.assertTrue(
     2915            'zope.mgr - students.browser.CourseExportJobContainerJobConfig '
     2916            '- exported: coursetickets (2004, 100, COURSE1), job_id=%s'
     2917            % job_id in logcontent
     2918            )
     2919        self.assertTrue(
     2920            'zope.mgr - students.browser.ExportJobContainerDownload '
     2921            '- downloaded: WAeUP.Kofa_coursetickets_%s.csv, job_id=%s'
     2922            % (job_id, job_id) in logcontent
     2923            )
     2924        self.assertTrue(
     2925            'zope.mgr - students.browser.ExportJobContainerOverview '
     2926            '- discarded: job_id=%s' % job_id in logcontent
     2927            )
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r9832 r9844  
    554554
    555555    def test_export_filtered(self):
    556         # we can export studylevels of a filtered set of students
     556        # we can export course tickets of a filtered set of students
    557557        self.setup_student(self.student)
    558558        self.app['students'].addStudent(self.student)
     
    568568            'passmark,score,semester,title,student_id,certcode\r\n'
    569569            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
     570            )
     571        # if the coursetickets catalog is used to filter students
     572        # and (course) code is not None
     573        # only course tickets which belong to this course are exported
     574        exporter.export_filtered(
     575            self.student, self.outfile, cat='coursetickets', code='CRS1')
     576        result = open(self.outfile, 'rb').read()
     577        self.assertEqual(
     578            result,
     579            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
     580            'passmark,score,semester,title,student_id,certcode\r\n'
     581            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
     582            )
     583        exporter.export_filtered(
     584            self.student, self.outfile, cat='coursetickets', code='any code')
     585        result = open(self.outfile, 'rb').read()
     586        self.assertEqual(
     587            result,
     588            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
     589            'passmark,score,semester,title,student_id,certcode\r\n'
    570590            )
    571591        return
Note: See TracChangeset for help on using the changeset viewer.