Changeset 13163 for main/kofacustom.nigeria/trunk/src
- Timestamp:
- 12 Jul 2015, 17:17:48 (9 years ago)
- Location:
- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/interfaces.py
r13161 r13163 68 68 ) 69 69 70 # Define a validation method for jamb subjects 71 class NotExactNumberOfItems(schema.ValidationError): 72 __doc__ = u"Not exactly 4 items selected." 73 74 def four_items(value): 75 if len(value) != 4: 76 raise NotExactNumberOfItems(value) 77 return True 78 70 79 class JAMBSubjectSource(SubjectSource): 71 80 """A source for school subjects used in exam documentation. … … 233 242 jamb_subjects_list = schema.List( 234 243 title = _(u'JAMB Subjects'), 235 default = ['english_language',],236 required = False,244 required = False, 245 default = [], 237 246 value_type = schema.Choice( 238 247 vocabulary = jambsubjects … … 578 587 title = _(u'JAMB Subjects'), 579 588 description = _(u'Select four subjects.'), 580 default = ['english_language',],581 required = True,589 required = True, 590 constraint = four_items, 582 591 value_type = schema.Choice( 583 592 vocabulary = jambsubjects -
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/tests/test_browser.py
r13160 r13163 38 38 from waeup.kofa.applicants.container import ApplicantsContainer 39 39 from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup 40 from waeup.kofa.interfaces import IBatchProcessor 40 from waeup.kofa.interfaces import IBatchProcessor, IUserAccount 41 41 from kofacustom.nigeria.testing import FunctionalLayer 42 42 from kofacustom.nigeria.applicants.export import NigeriaApplicantExporter … … 46 46 app_container_name = u'app%s' % session_1 47 47 pgft_container_name = u'pgft%s' % session_1 48 cbt_container_name = u'cbt%s' % session_1 48 49 49 50 class ApplicantUITest(FunctionalTestCase): … … 69 70 setSite(app) 70 71 71 # Add an twodifferent applicants containers72 # Add three different applicants containers 72 73 self.pgcontainer = ApplicantsContainer() 73 74 self.pgcontainer.code = pgft_container_name … … 78 79 self.pgcontainer.title = u'This is the %s container' % pgft_container_name 79 80 self.app['applicants'][pgft_container_name] = self.pgcontainer 81 80 82 self.ugcontainer = ApplicantsContainer() 81 83 self.ugcontainer.code = app_container_name … … 86 88 self.ugcontainer.title = u'This is the %s container' % app_container_name 87 89 self.app['applicants'][app_container_name] = self.ugcontainer 88 89 90 self.ugcontainer.mode = 'update' 90 91 delta = datetime.timedelta(days=10) 91 92 self.ugcontainer.startdate = datetime.datetime.now(pytz.utc) - delta 92 93 self.ugcontainer.enddate = datetime.datetime.now(pytz.utc) + delta 94 95 self.cbtcontainer = ApplicantsContainer() 96 self.cbtcontainer.code = cbt_container_name 97 self.cbtcontainer.prefix = u'cbt' 98 self.cbtcontainer.application_category = u'basic' 99 self.cbtcontainer.year = session_1 100 self.cbtcontainer.application_fee = 300.0 101 self.cbtcontainer.title = u'This is the %s container' % cbt_container_name 102 self.app['applicants'][cbt_container_name] = self.cbtcontainer 103 self.cbtcontainer.mode = 'update' 104 delta = datetime.timedelta(days=10) 105 self.cbtcontainer.startdate = datetime.datetime.now(pytz.utc) - delta 106 self.cbtcontainer.enddate = datetime.datetime.now(pytz.utc) + delta 93 107 94 108 # Populate university … … 128 142 self.ugapplicant = self.app['applicants'][app_container_name][ 129 143 self.ugapplication_number] 144 145 cbtapplicant = createObject(u'waeup.Applicant') 146 cbtapplicant.firstname = u'Anna' 147 cbtapplicant.lastname = u'Cbt' 148 self.app['applicants'][cbt_container_name].addApplicant(cbtapplicant) 149 self.cbtapplication_number = cbtapplicant.application_number 150 self.cbtapplicant = self.app['applicants'][cbt_container_name][ 151 self.cbtapplication_number] 152 IUserAccount(self.cbtapplicant).setPassword('apwd') 153 154 self.login_path = 'http://localhost/app/login' 155 self.logout_path = 'http://localhost/app/logout' 130 156 self.pgapplicant_path = ('http://localhost/app/applicants/%s/%s' 131 157 % (pgft_container_name, self.pgapplication_number)) 132 158 self.ugapplicant_path = ('http://localhost/app/applicants/%s/%s' 133 159 % (app_container_name, self.ugapplication_number)) 160 self.cbtapplicant_path = ('http://localhost/app/applicants/%s/%s' 161 % (cbt_container_name, self.cbtapplication_number)) 134 162 135 163 self.browser = Browser() … … 319 347 self.assertEqual(student.nationality, 'NG') 320 348 return 349 350 def test_applicant_access(self): 351 # Applicants can edit their record 352 self.browser.open(self.login_path) 353 self.browser.getControl( 354 name="form.login").value = self.cbtapplicant.applicant_id 355 self.browser.getControl(name="form.password").value = 'apwd' 356 self.browser.getControl("Login").click() 357 self.assertTrue( 358 'You logged in.' in self.browser.contents) 359 self.browser.getLink("Edit application record").click() 360 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 361 self.browser.getControl(name="form.lga").value = ['foreigner'] 362 self.browser.getControl(name="form.nationality").value = ['NG'] 363 self.browser.getControl(name="form.sex").value = ['m'] 364 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 365 self.browser.getControl(name="form.course1").value = ['CERT1'] 366 self.browser.getControl("Save").click() 367 self.assertMatches('...Not exactly 4 items selected...', self.browser.contents) 368 # Since the testbrowser does not support Javascrip we can't test the 369 # save action which clears jamb_subjects_list on the edit form page 370 # An error would be raised. 371 372 # If we login as manager, we can use the manage form page. 373 self.browser.open(self.logout_path) 374 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 375 self.cbtapplicant.jamb_subjects_list = [ 376 'english_language', 'fine_art', 'mathematics', 'physics'] 377 self.browser.open(self.cbtapplicant_path + '/manage') 378 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 379 self.browser.getControl(name="form.lga").value = ['foreigner'] 380 self.browser.getControl(name="form.nationality").value = ['NG'] 381 self.browser.getControl(name="form.sex").value = ['m'] 382 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 383 self.browser.getControl(name="form.course1").value = ['CERT1'] 384 self.browser.getControl(name="form.reg_number").value = '1234' 385 self.browser.getControl("Save").click() 386 self.assertMatches('...Form has been saved...', self.browser.contents) 387 # The save action on this form pages, if called with the testbrowser, 388 # replaces jamb_subjects_list by an empty list (and not by None). 389 self.assertEqual(self.cbtapplicant.jamb_subjects_list, []) 321 390 322 391 class ApplicantExporterTest(ApplicantImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.