Ignore:
Timestamp:
26 Sep 2013, 06:27:53 (11 years ago)
Author:
Henrik Bettermann
Message:

We need to export applicants of single containers. First step is to implement export_filtered.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py

    r9117 r10653  
    115115            applicant_id=(None, None))
    116116        return self.export(applicants, filepath)
     117
     118    def export_filtered(self, site, filepath=None, **kw):
     119        """Export applicants in container.
     120
     121        If `filepath` is ``None``, a raw string with CSV data should
     122        be returned.
     123        """
     124        return self.export(kw['container'].values(), filepath=filepath)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py

    r10098 r10653  
    201201            in result)
    202202        return
     203
     204    def test_export_filtered(self):
     205        self.applicant = self.setup_applicant(self.applicant)
     206        exporter = ApplicantsExporter()
     207        exporter.export_filtered(self.app, self.outfile, container=self.container)
     208        result = open(self.outfile, 'rb').read()
     209        self.assertTrue(
     210            'applicant_id,application_date,application_number,course1,course2,'
     211            'course_admitted,date_of_birth,display_fullname,email,firstname,'
     212            'history,lastname,locked,middlename,notice,password,phone,'
     213            'reg_number,sex,state,'
     214            'student_id,suspended,container_code\r\n'
     215            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
     216            'Anna M. Tester,anna@sample.com,Anna,'
     217            in result)
     218        self.assertTrue(
     219            'Application initialized by system\'],'
     220            'Tester,0,M.,"Some notice\nin lines.",any password,'
     221            '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
     222            in result)
     223        # In empty container no applicants are exported
     224        container = ApplicantsContainer()
     225        exporter.export_filtered(self.app, self.outfile, container=container)
     226        result = open(self.outfile, 'rb').read()
     227        self.assertTrue(
     228            'applicant_id,application_date,application_number,course1,'
     229            'course2,course_admitted,date_of_birth,display_fullname,email,'
     230            'firstname,history,lastname,locked,middlename,notice,password,'
     231            'phone,reg_number,sex,state,student_id,suspended,container_code\r\n'
     232            in result)
     233        return
Note: See TracChangeset for help on using the changeset viewer.