Ignore:
Timestamp:
20 Mar 2012, 01:21:22 (13 years ago)
Author:
uli
Message:

Reflect changes in applicant exporter.

File:
1 edited

Legend:

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

    r7913 r7925  
    1212    ApplicantsContainerExporter, ApplicantsExporter)
    1313from waeup.kofa.applicants.interfaces import (
    14     IApplicantsContainerProvider, AppCatSource)
     14    IApplicantsContainerProvider, AppCatSource, ApplicationTypeSource)
    1515from waeup.kofa.applicants.tests.test_batching import (
    1616    ApplicantImportExportSetup)
    1717from waeup.kofa.interfaces import ICSVExporter
     18from waeup.kofa.schoolgrades import ResultEntry
    1819from waeup.kofa.testing import KofaUnitTestLayer, FunctionalLayer
     20from waeup.kofa.utils.utils import KofaUtils
    1921
    2022class ApplicantsContainersExporterTest(unittest.TestCase):
     
    4850        container.code = u'dp2012'
    4951        container.title = u'General Studies 2012/13'
    50         from waeup.kofa.applicants.interfaces import (
    51             ApplicationTypeSource, ApplicantContainerProviderSource,)
    5252        container.prefix = list(ApplicationTypeSource()(container))[0]
    5353        container.year = 2012
     
    106106        return
    107107
     108    def setup_applicant(self, applicant):
     109        # set predictable values for `applicant`
     110        applicant.reg_number = u'123456'
     111        applicant.applicant_id = u'dp2011_654321'
     112        applicant.firstname = u'Anna'
     113        applicant.lastname = u'Tester'
     114        applicant.middlename = u'M.'
     115        applicant.date_of_birth = datetime.date(1981, 2, 4)
     116        applicant.sex = 'f'
     117        applicant.email = 'anna@sample.com'
     118        applicant.phone = u'+234-123-12345'
     119        applicant.course1 = self.certificate
     120        applicant.course2 = self.certificate
     121        applicant.course_admitted = self.certificate
     122        applicant.notice = u'Some notice\nin lines.'
     123        applicant.screening_score = 98
     124        applicant.screening_venue = u'Exam Room'
     125        result_entry = ResultEntry(
     126            KofaUtils.EXAM_SUBJECTS_DICT.keys()[0],
     127            KofaUtils.EXAM_GRADES[0][0]
     128            )
     129        applicant.school_grades = [
     130            result_entry]
     131        return applicant
     132
    108133    def test_export(self):
    109134        # we can really export applicants
    110135        # set values we can expect in export file
    111         self.applicant.reg_number = u'123456'
    112         self.applicant.applicant_id = u'dp2011_654321'
    113         intid = self.intids.getId(self.applicant)
    114         # reindex modified applicant
    115         self.cat.index_doc(intid, self.applicant)
     136        applicant = self.setup_applicant(self.applicant)
    116137        exporter = ApplicantsExporter()
    117         exporter.export([self.applicant], self.outfile)
     138        exporter.export([applicant], self.outfile)
    118139        result = open(self.outfile, 'rb').read()
    119140        self.assertEqual(
    120141            result,
    121             'reg_number,school_grades,firstname,phone,middlename,lastname,'
    122             'lga,screening_score,notice,applicant_id,sex,course2,email,'
    123             'date_of_birth,screening_venue,course_admitted,course1\r\n'
     142            'applicant_id,course1,course2,course_admitted,date_of_birth,'
     143            'email,firstname,lastname,lga,middlename,notice,phone,'
     144            'reg_number,school_grades,screening_score,screening_venue,'
     145            'sex\r\n'
    124146
    125             '123456,[],Anna,,,Tester,foreigner,,,dp2011_654321,m,,,,,,\r\n'
     147            'dp2011_654321,CERT1,CERT1,CERT1,1981-02-04,anna@sample.com,'
     148            'Anna,Tester,foreigner,M.,"Some notice\nin lines.",'
     149            '+234-123-12345,123456,'
     150            '"[(\'computer_science\', \'A\')]",98,Exam Room,f\r\n'
    126151            )
    127152        return
Note: See TracChangeset for help on using the changeset viewer.