Ignore:
Timestamp:
9 Dec 2019, 10:44:57 (5 years ago)
Author:
Henrik Bettermann
Message:

Add StudentOutstandingCoursesExporter.

File:
1 edited

Legend:

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

    r15664 r15873  
    2727    ICSVExporter, IExtFileStore, IFileStoreNameChooser)
    2828from waeup.kofa.students.catalog import StudentsQuery
     29from waeup.kofa.university.course import Course
     30from waeup.kofa.university.certificate import CertificateCourse
    2931from waeup.kofa.students.export import (
    3032    StudentExporter, StudentStudyCourseExporter, StudentStudyLevelExporter,
     
    3335    ComboCardDataExporter, DataForBursaryExporter,
    3436    StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter,
     37    StudentOutstandingCoursesExporter,
    3538    AccommodationPaymentsExporter, get_students,)
    3639from waeup.kofa.students.accommodation import BedTicket
     
    789792            '1,1,CRS1,,100,DEP1,FAC1,110,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    790793            'Anna M. Tester\r\n'
     794            )
     795        return
     796
     797class StudentOutstandingCoursesExporterTest(StudentImportExportSetup):
     798
     799    layer = FunctionalLayer
     800
     801    def setUp(self):
     802        super(StudentOutstandingCoursesExporterTest, self).setUp()
     803        self.setup_for_export()
     804        return
     805
     806    def test_ifaces(self):
     807        # make sure we fullfill interface contracts
     808        obj = StudentOutstandingCoursesExporter()
     809        verifyObject(ICSVStudentExporter, obj)
     810        verifyClass(ICSVStudentExporter, StudentOutstandingCoursesExporter)
     811        return
     812
     813    def test_get_as_utility(self):
     814        # we can get an student exporter as utility
     815        result = queryUtility(ICSVExporter, name="studentoutstandingcourses")
     816        self.assertTrue(result is not None)
     817        return
     818
     819    def test_export_all(self):
     820        course1 = Course(u'Cheese Basics', 'C1')
     821        course2 = Course(u'Advanced Cheese Making', 'C2')
     822        course3 = Course(u'Selling Cheese', 'C3')
     823        self.app['faculties']['fac1']['dep1'].courses.addCourse(course1)
     824        self.app['faculties']['fac1']['dep1'].courses.addCourse(course2)
     825        self.app['faculties']['fac1']['dep1'].courses.addCourse(course3)
     826        self.certificate.addCertCourse(course1, 100, True)
     827        self.certificate.addCertCourse(course2, 400, False)
     828        self.certificate.addCertCourse(course3, 100, False)
     829        self.setup_student(self.student)
     830        self.student['studycourse']['100']['C3'].score = 25
     831        exporter = StudentOutstandingCoursesExporter()
     832        exporter.export_all(self.app, self.outfile)
     833        result = open(self.outfile, 'rb').read()
     834        # The only student has registered C1, C3 and CRS1
     835        # She missed C2, has failed C3 and  did not
     836        # take C1 and CRS1
     837        self.assertEqual(
     838            result,
     839            'student_id,certcode,display_fullname,missed,failed,nottaken\r\n'
     840            'A111111,CERT1,Anna M. Tester,C2_400 ,C3 ,C1 CRS1 \r\n'
    791841            )
    792842        return
Note: See TracChangeset for help on using the changeset viewer.