Changeset 8055


Ignore:
Timestamp:
6 Apr 2012, 20:42:44 (12 years ago)
Author:
Henrik Bettermann
Message:

Use names of customized interfaces (UG, PG and Base) for export.

Location:
main/waeup.custom/trunk/src/waeup/custom/applicants
Files:
1 added
1 edited

Legend:

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

    r8054 r8055  
    1919import shutil
    2020import tempfile
     21import datetime
     22from zope.intid.interfaces import IIntIds
    2123from zope.interface.verify import verifyClass, verifyObject
    2224from zope.component.hooks import setSite, clearSite
    23 from zope.component import createObject
     25from zope.component import createObject, getUtility
     26from zope.catalog.interfaces import ICatalog
    2427from zope.testbrowser.testing import Browser
    2528from waeup.kofa.app import University
     
    2831from waeup.kofa.testing import FunctionalTestCase
    2932from waeup.kofa.applicants.container import ApplicantsContainer
     33from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup
     34from waeup.kofa.interfaces import IBatchProcessor
    3035from waeup.custom.testing import FunctionalLayer
    31 from waeup.kofa.interfaces import IBatchProcessor
     36from waeup.custom.applicants.export import ApplicantsExporter
     37
    3238
    3339class ApplicantUITest(FunctionalTestCase):
     
    145151        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    146152        return
     153
     154class ApplicantsExporterTest(ApplicantImportExportSetup):
     155
     156    layer = FunctionalLayer
     157
     158    def setUp(self):
     159        super(ApplicantsExporterTest, self).setUp()
     160        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
     161        self.cat = getUtility(ICatalog, name='applicants_catalog')
     162        self.intids = getUtility(IIntIds)
     163        return
     164
     165    def setup_applicant(self, applicant):
     166        # set predictable values for `applicant`
     167        applicant.reg_number = u'123456'
     168        applicant.applicant_id = u'dp2011_654321'
     169        applicant.firstname = u'Anna'
     170        applicant.lastname = u'Tester'
     171        applicant.middlename = u'M.'
     172        applicant.date_of_birth = datetime.date(1981, 2, 4)
     173        applicant.sex = 'f'
     174        applicant.email = 'anna@sample.com'
     175        applicant.phone = u'+234-123-12345'
     176        applicant.course1 = self.certificate
     177        applicant.course2 = self.certificate
     178        applicant.course_admitted = self.certificate
     179        applicant.notice = u'Some notice\nin lines.'
     180        applicant.screening_score = 98
     181        applicant.screening_venue = u'Exam Room'
     182        applicant.password = 'any password'
     183        return applicant
     184
     185    def test_export_all(self):
     186        # we can export all applicants in a portal
     187        # set values we can expect in export file
     188        self.applicant = self.setup_applicant(self.applicant)
     189        exporter = ApplicantsExporter()
     190        exporter.export_all(self.app, self.outfile)
     191        result = open(self.outfile, 'rb').read()
     192        # The exported records do contain a real date in their
     193        # history dict. We skip the date and split the comparison
     194        # into two parts.
     195        self.assertTrue(
     196            'applicant_id,application_date,application_number,course1,course2,'
     197            'course_admitted,date_of_birth,display_fullname,email,employer,'
     198            'firstname,history,lastname,lga,locked,middlename,notice,password,'
     199            'phone,reg_number,screening_score,screening_venue,sex,state,'
     200            'student_id'
     201            in result)
     202        self.assertTrue(
     203            'Application initialized by system\'],Tester,foreigner,0,M.,'
     204            '"Some notice\nin lines.",any password,+234-123-12345,123456,98,'
     205            'Exam Room,f,initialized,' in result)
     206        return
Note: See TracChangeset for help on using the changeset viewer.