Ignore:
Timestamp:
10 May 2012, 16:38:15 (13 years ago)
Author:
uli
Message:

Dirty fix for problem with export of student subobjects.

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_batching.py

    r8354 r8411  
    3434    StudentStudyLevelProcessor, CourseTicketProcessor,
    3535    StudentOnlinePaymentProcessor, StudentVerdictProcessor)
     36from waeup.kofa.students.payments import StudentOnlinePayment
    3637from waeup.kofa.students.student import Student
    3738from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket
     
    208209        ticket.semester = 2
    209210        study_level.addCourseTicket(ticket)
    210 
     211        self.add_payment(student)
    211212        return student
     213
     214    def add_payment(self, student):
     215        # get a payment with all fields set
     216        payment = StudentOnlinePayment()
     217        payment.creation_date = datetime.datetime(2012, 4, 1, 13, 12, 1)
     218        payment.p_id = 'my-id'
     219        payment.ac = u'666'
     220        payment.p_item = u'p-item'
     221        payment.p_level = 100
     222        payment.p_session = 2012
     223        payment.payment_date = datetime.datetime(2012, 4, 1, 14, 12, 1)
     224        payment.r_amount_approved = 12.12
     225        payment.r_code = u'r-code'
     226        # XXX: there is no addPayment method to give predictable names
     227        student['payments']['my-payment'] = payment
     228        return payment
     229
    212230
    213231
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r8402 r8411  
    7272        return
    7373
     74    def test_export_student(self):
     75        # we can export a single student
     76        self.setup_student(self.student)
     77        exporter = StudentsExporter()
     78        exporter.export_student(self.student, self.outfile)
     79        result = open(self.outfile, 'rb').read()
     80        self.assertEqual(
     81            result,
     82            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
     83            'firstname,lastname,matric_number,middlename,nationality,'
     84            'perm_address,phone,reg_number,sex,student_id\r\n'
     85
     86            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,Anna,'
     87            'Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
     88            '+234-123-12345,123456,f,A111111\r\n'
     89            )
     90        return
     91
     92
    7493class StudentStudyCourseExporterTest(StudentImportExportSetup):
    7594
     
    142161        return
    143162
     163    def test_export_student(self):
     164        # we can export studycourse of a certain student
     165        self.setup_student(self.student)
     166        exporter = StudentStudyCourseExporter()
     167        exporter.export_student(self.student, self.outfile)
     168        result = open(self.outfile, 'rb').read()
     169        self.assertEqual(
     170            result,
     171            'certificate,current_level,current_session,current_verdict,'
     172            'entry_mode,entry_session,previous_verdict\r\n'
     173
     174            'CERT1,200,2012,0,ug_ft,2010,0\r\n'
     175            )
     176        return
     177
    144178class StudentStudyLevelExporterTest(StudentImportExportSetup):
    145179
     
    207241        return
    208242
     243    def test_export_student(self):
     244        # we can really export study levels of a certain student
     245        self.setup_student(self.student)
     246        exporter = StudentStudyLevelExporter()
     247        exporter.export_student(self.student, self.outfile)
     248        result = open(self.outfile, 'rb').read()
     249        self.assertEqual(
     250            result,
     251            'level,level_session,level_verdict,matric_number,reg_number\r\n'
     252            '100,2012,A,M123456,123456\r\n'
     253            )
     254        return
     255
    209256class CourseTicketExporterTest(StudentImportExportSetup):
    210257
     
    276323        return
    277324
     325    def test_export_student(self):
     326        # we can really export all course tickets of a certain student
     327        self.setup_student(self.student)
     328        exporter = CourseTicketExporter()
     329        exporter.export_student(self.student, self.outfile)
     330        result = open(self.outfile, 'rb').read()
     331        self.assertEqual(
     332            result,
     333            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
     334            'matric_number,passmark,reg_number,score,semester,title\r\n'
     335            '1,1,CRS1,100,DEP1,FAC1,100,0,M123456,100,123456,0,2,Course 1\r\n'
     336            )
     337        return
     338
    278339class PaymentsExporterTest(StudentImportExportSetup):
    279340
     
    284345        self.setup_for_export()
    285346        return
    286 
    287     def get_payment(self):
    288         # get a payment with all fields set
    289         payment = StudentOnlinePayment()
    290         payment.creation_date = datetime.datetime(2012, 4, 1, 13, 12, 1)
    291         payment.p_id = 'my-id'
    292         payment.ac = u'666'
    293         payment.p_item = u'p-item'
    294         payment.p_level = 100
    295         payment.p_session = 2012
    296         payment.payment_date = datetime.datetime(2012, 4, 1, 14, 12, 1)
    297         payment.r_amount_approved = 12.12
    298         payment.r_code = u'r-code'
    299         # XXX: there is no addPayment method to give predictable names
    300         self.student['payments']['my-payment'] = payment
    301         return payment
    302347
    303348    def test_ifaces(self):
     
    335380        # set values we can expect in export file
    336381        self.setup_student(self.student)
    337         payment = self.get_payment()
     382        payment = self.student['payments']['my-payment']
    338383        exporter = PaymentsExporter()
    339384        exporter.export([payment], self.outfile)
     
    355400        # set values we can expect in export file
    356401        self.setup_student(self.student)
    357         self.get_payment() # adds new payment to student
    358402        exporter = PaymentsExporter()
    359403        exporter.export_all(self.app, self.outfile)
     
    370414            )
    371415        return
     416
     417    def test_export_student(self):
     418        # we can really export all payments of a certain student
     419        # set values we can expect in export file
     420        self.setup_student(self.student)
     421        exporter = PaymentsExporter()
     422        exporter.export_student(self.student, self.outfile)
     423        result = open(self.outfile, 'rb').read()
     424        self.assertEqual(
     425            result,
     426            'ac,amount_auth,creation_date,matric_number,p_category,p_id,'
     427            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
     428            'r_code,reg_number\r\n'
     429
     430            '666,0.0,2012-04-01 13:12:01,M123456,schoolfee,my-id,'
     431            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
     432            'r-code,123456\r\n'
     433            )
     434        return
Note: See TracChangeset for help on using the changeset viewer.