Ignore:
Timestamp:
10 Sep 2012, 11:05:07 (12 years ago)
Author:
uli
Message:

Merge changes from trunk, r8786-HEAD

Location:
main/waeup.kofa/branches/uli-async-update
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-async-update

  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r8667 r9169  
    2121import os
    2222import grok
     23from datetime import datetime
    2324from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2425from zope.event import notify
     
    2829from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
    2930from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
     31
     32session = datetime.now().year - 2
    3033
    3134class ApplicantCopierFunctionalTests(ApplicantsFullSetup):
     
    6770        self.browser.getControl(name="form.course_admitted").value = ['CERT1']
    6871        self.browser.getControl("Save").click()
     72        # Maybe the certificate has meanwhile been removed
     73        del self.app['faculties']['fac1']['dep1'].certificates['CERT1']
     74        (success, msg) = self.applicant.createStudent()
     75        self.assertFalse(success)
     76        self.assertTrue('ConstraintNotSatisfied: CERT1' in msg)
     77        # Ok, lets add the certificate and try again
     78        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     79            self.certificate)
    6980        (success, msg) = self.applicant.createStudent()
    7081        self.assertTrue('created' in msg)
     
    8293        self.assertEqual(student.firstname, 'John')
    8394        self.assertEqual(student.lastname, 'Tester')
     95        # student_id set in application record?
     96        self.assertEqual(self.applicant.student_id, student.student_id)
    8497        # Check if passport image has been copied
    8598        storage = getUtility(IExtFileStore)
     
    110123        # Has the student studycourse the correct attributes?
    111124        self.assertEqual(student['studycourse'].certificate.code, 'CERT1')
    112         self.assertEqual(student['studycourse'].entry_session, 2009)
     125        self.assertEqual(student['studycourse'].entry_session, session)
    113126        self.assertEqual(student['studycourse'].entry_mode, 'ug_ft')
    114         self.assertEqual(student['studycourse'].current_session, 2009)
     127        self.assertEqual(student['studycourse'].current_session, session)
    115128        self.assertEqual(student['studycourse'].current_level, 100)
    116129
  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_authentication.py

    r8351 r9169  
    6464    email = None
    6565    phone = None
     66    suspended = False
    6667
    6768
  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_browser.py

    r8778 r9169  
    2323import tempfile
    2424import grok
     25from datetime import datetime
    2526from StringIO import StringIO
    2627from datetime import datetime, date, timedelta
     
    4647PH_LEN = 2059  # Length of placeholder file
    4748
     49session_1 = datetime.now().year - 2
     50container_name_1 = u'app%s' % session_1
     51session_2 = datetime.now().year - 1
     52container_name_2 = u'app%s' % session_2
     53
    4854class ApplicantsFullSetup(FunctionalTestCase):
    4955    # A test case that only contains a setup and teardown
     
    8086        self.manage_root_path = self.root_path + '/@@manage'
    8187        self.add_container_path = self.root_path + '/@@add'
    82         self.container_path = 'http://localhost/app/applicants/app2009'
     88        self.container_path = 'http://localhost/app/applicants/%s' % container_name_1
    8389        self.manage_container_path = self.container_path + '/@@manage'
    8490
    8591        # Add an applicants container
    8692        applicantscontainer = ApplicantsContainer()
    87         applicantscontainer.code = u'app2009'
     93        applicantscontainer.code = container_name_1
    8894        applicantscontainer.prefix = 'app'
    89         applicantscontainer.year = 2009
    90         applicantscontainer.title = u'This is the app2009 container'
     95        applicantscontainer.year = session_1
     96        applicantscontainer.title = u'This is the %s container' % container_name_1
    9197        applicantscontainer.application_category = 'basic'
    9298        applicantscontainer.mode = 'create'
     
    95101        applicantscontainer.startdate = datetime.now(pytz.utc) - delta
    96102        applicantscontainer.enddate = datetime.now(pytz.utc) + delta
    97         self.app['applicants']['app2009'] = applicantscontainer
    98         self.applicantscontainer = self.app['applicants']['app2009']
     103        self.app['applicants'][container_name_1] = applicantscontainer
     104        self.applicantscontainer = self.app['applicants'][container_name_1]
    99105
    100106        # Populate university
     
    135141        self.applicant.reg_number = u'1234'
    136142        self.applicant.course1 = certificate
    137         app['applicants']['app2009'].addApplicant(self.applicant)
     143        app['applicants'][container_name_1].addApplicant(self.applicant)
    138144        IUserAccount(
    139             self.app['applicants']['app2009'][
     145            self.app['applicants'][container_name_1][
    140146            self.applicant.application_number]).setPassword('apwd')
    141147        self.manage_path = 'http://localhost/app/applicants/%s/%s/%s' % (
    142             'app2009', self.applicant.application_number, 'manage')
     148            container_name_1, self.applicant.application_number, 'manage')
    143149        self.edit_path = 'http://localhost/app/applicants/%s/%s/%s' % (
    144             'app2009', self.applicant.application_number, 'edit')
     150            container_name_1, self.applicant.application_number, 'edit')
    145151        self.view_path = 'http://localhost/app/applicants/%s/%s' % (
    146             'app2009', self.applicant.application_number)
     152            container_name_1, self.applicant.application_number)
    147153
    148154    def login(self):
     
    303309            'There were errors' in self.browser.contents)
    304310        self.browser.getControl(name="form.prefix").value = ['app']
    305         self.browser.getControl(name="form.year").value = ['2010']
     311        self.browser.getControl(name="form.year").value = [str(session_2)]
    306312        self.browser.getControl(name="form.mode").value = ['create']
    307313        self.browser.getControl(
     
    317323        self.browser.open(self.add_container_path)
    318324        self.browser.getControl(name="form.prefix").value = ['app']
    319         self.browser.getControl(name="form.year").value = ['2010']
     325        self.browser.getControl(name="form.year").value = [str(session_2)]
    320326        self.browser.getControl(name="form.mode").value = ['create']
    321327        self.browser.getControl(
     
    326332        self.browser.open(self.manage_root_path)
    327333        ctrl = self.browser.getControl(name='val_id')
    328         ctrl.getControl(value='app2010').selected = True
     334        ctrl.getControl(value=container_name_2).selected = True
    329335        self.browser.getControl("Remove selected", index=0).click()
    330336        self.assertTrue('Successfully removed:' in self.browser.contents)
    331337        self.browser.open(self.add_container_path)
    332338        self.browser.getControl(name="form.prefix").value = ['app']
    333         self.browser.getControl(name="form.year").value = ['2010']
     339        self.browser.getControl(name="form.year").value = [str(session_2)]
    334340        self.browser.getControl(name="form.mode").value = ['create']
    335341        #self.browser.getControl(name="form.ac_prefix").value = ['APP']
     
    337343            name="form.application_category").value = ['basic']
    338344        self.browser.getControl("Add applicants container").click()
    339         del self.app['applicants']['app2010']
     345        del self.app['applicants'][container_name_2]
    340346        ctrl = self.browser.getControl(name='val_id')
    341         ctrl.getControl(value='app2010').selected = True
     347        ctrl.getControl(value=container_name_2).selected = True
    342348        self.browser.getControl("Remove selected", index=0).click()
    343349        self.assertMatches('...Could not delete...', self.browser.contents)
     
    465471        self.browser.open(self.slip_path)
    466472        self.assertTrue(
    467             'Please pay before trying to download the application slip.'
     473            'Please pay and submit before trying to download the application slip.'
    468474            in self.browser.contents)
    469475        # If applicant is in correct state the pdf slip can be opened.
    470         IWorkflowState(self.applicant).setState('paid')
     476        IWorkflowState(self.applicant).setState('submitted')
    471477        self.browser.open(self.manage_path)
    472478        self.browser.getLink("Download application slip").click()
     
    493499            self.browser.headers['content-length'], str(PH_LEN))
    494500
     501    def test_applicant_login(self):
     502        self.applicant.suspended = True
     503        self.login()
     504        self.assertTrue(
     505            'You entered invalid credentials.' in self.browser.contents)
     506        self.applicant.suspended = False
     507        self.browser.getControl("Login").click()
     508        self.assertTrue(
     509            'You logged in.' in self.browser.contents)
     510
    495511    def test_applicant_access(self):
    496512        # Applicants can edit their record
    497513        self.browser.open(self.login_path)
    498514        self.login()
     515        self.assertTrue(
     516            'You logged in.' in self.browser.contents)
    499517        self.browser.open(self.edit_path)
    500518        self.assertTrue(self.browser.url != self.login_path)
     
    699717            in self.browser.contents)
    700718        configuration = SessionConfiguration()
    701         configuration.academic_session = 2009
     719        configuration.academic_session = session_1
    702720        configuration.application_fee = 200.0
    703721        self.app['configuration'].addSessionConfiguration(configuration)
     
    727745        payment_id = self.applicant.keys()[0]
    728746        payment = self.applicant[payment_id]
    729         self.assertEqual(payment.p_item,'This is the app2009 container')
    730         self.assertEqual(payment.p_session,2009)
     747        self.assertEqual(payment.p_item,'This is the %s container' % container_name_1)
     748        self.assertEqual(payment.p_session, session_1)
    731749        self.assertEqual(payment.p_category,'application')
    732750        self.assertEqual(payment.amount_auth,200.0)
     
    821839        self.browser.getControl("Final Submit").click()
    822840        self.assertTrue(
    823             '... submitted ...' in self.browser.contents)
     841            'Application submitted' in self.browser.contents)
    824842        # ... or allow submission after deadline.
    825843        IWorkflowState(self.applicant).setState('paid')
     
    830848        self.browser.getControl("Final Submit").click()
    831849        self.assertTrue(
    832             '... submitted ...' in self.browser.contents)
     850            'Application submitted' in self.browser.contents)
    833851        self.browser.goBack(count=1)
    834852        self.browser.getControl("Save").click()
     
    977995            in self.browser.contents)
    978996        #IUserAccount(
    979         #    self.app['applicants']['app2009'][
     997        #    self.app['applicants'][container_name_1][
    980998        #    self.applicant.application_number]).context.password = None
    981999        # Even without unsetting the password we can re-register if state
  • main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_export.py

    r8724 r9169  
    120120        applicant.course_admitted = self.certificate
    121121        applicant.notice = u'Some notice\nin lines.'
    122         applicant.screening_score = 98
    123         applicant.screening_venue = u'Exam Room'
    124122        applicant.password = 'any password'
    125123        result_entry = ResultEntry(
     
    144142            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    145143            'history,lastname,locked,middlename,notice,password,phone,'
    146             'reg_number,screening_score,screening_venue,sex,state,'
    147             'student_id,container_code\r\n'
     144            'reg_number,sex,state,'
     145            'student_id,suspended,container_code\r\n'
    148146            'dp2011_654321,,654321,,,,,Anna Tester,,Anna,'
    149147            in result)
    150148        self.assertTrue(
    151149            'Application initialized by system\'],Tester,'
    152             '0,,,,,,,,,initialized,,dp2011\r\n'
     150            '0,,,,,,,initialized,,0,dp2011\r\n'
    153151            in result)
    154152        return
     
    168166            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    169167            'history,lastname,locked,middlename,notice,password,phone,'
    170             'reg_number,screening_score,screening_venue,sex,state,'
    171             'student_id,container_code\r\n'
     168            'reg_number,sex,state,'
     169            'student_id,suspended,container_code\r\n'
    172170            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
    173171            'Anna M. Tester,anna@sample.com,Anna,'
     
    176174            'Application initialized by system\'],'
    177175            'Tester,0,M.,"Some notice\nin lines.",any password,'
    178             '+234-123-12345,123456,98,Exam Room,f,initialized,,dp2011\r\n'
     176            '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
    179177            in result)
    180178
     
    192190            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    193191            'history,lastname,locked,middlename,notice,password,phone,'
    194             'reg_number,screening_score,screening_venue,sex,state,'
    195             'student_id,container_code\r\n'
     192            'reg_number,sex,state,'
     193            'student_id,suspended,container_code\r\n'
    196194            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
    197195            'Anna M. Tester,anna@sample.com,Anna,'
     
    200198            'Application initialized by system\'],'
    201199            'Tester,0,M.,"Some notice\nin lines.",any password,'
    202             '+234-123-12345,123456,98,Exam Room,f,initialized,,dp2011\r\n'
    203             in result)
    204         return
     200            '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
     201            in result)
     202        return
Note: See TracChangeset for help on using the changeset viewer.