Changeset 9169 for main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_browser.py
- Timestamp:
- 10 Sep 2012, 11:05:07 (12 years ago)
- Location:
- main/waeup.kofa/branches/uli-async-update
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-async-update
- Property svn:mergeinfo changed
-
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/applicants/tests/test_browser.py
r8778 r9169 23 23 import tempfile 24 24 import grok 25 from datetime import datetime 25 26 from StringIO import StringIO 26 27 from datetime import datetime, date, timedelta … … 46 47 PH_LEN = 2059 # Length of placeholder file 47 48 49 session_1 = datetime.now().year - 2 50 container_name_1 = u'app%s' % session_1 51 session_2 = datetime.now().year - 1 52 container_name_2 = u'app%s' % session_2 53 48 54 class ApplicantsFullSetup(FunctionalTestCase): 49 55 # A test case that only contains a setup and teardown … … 80 86 self.manage_root_path = self.root_path + '/@@manage' 81 87 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 83 89 self.manage_container_path = self.container_path + '/@@manage' 84 90 85 91 # Add an applicants container 86 92 applicantscontainer = ApplicantsContainer() 87 applicantscontainer.code = u'app2009'93 applicantscontainer.code = container_name_1 88 94 applicantscontainer.prefix = 'app' 89 applicantscontainer.year = 200990 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 91 97 applicantscontainer.application_category = 'basic' 92 98 applicantscontainer.mode = 'create' … … 95 101 applicantscontainer.startdate = datetime.now(pytz.utc) - delta 96 102 applicantscontainer.enddate = datetime.now(pytz.utc) + delta 97 self.app['applicants'][ 'app2009'] = applicantscontainer98 self.applicantscontainer = self.app['applicants'][ 'app2009']103 self.app['applicants'][container_name_1] = applicantscontainer 104 self.applicantscontainer = self.app['applicants'][container_name_1] 99 105 100 106 # Populate university … … 135 141 self.applicant.reg_number = u'1234' 136 142 self.applicant.course1 = certificate 137 app['applicants'][ 'app2009'].addApplicant(self.applicant)143 app['applicants'][container_name_1].addApplicant(self.applicant) 138 144 IUserAccount( 139 self.app['applicants'][ 'app2009'][145 self.app['applicants'][container_name_1][ 140 146 self.applicant.application_number]).setPassword('apwd') 141 147 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') 143 149 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') 145 151 self.view_path = 'http://localhost/app/applicants/%s/%s' % ( 146 'app2009', self.applicant.application_number)152 container_name_1, self.applicant.application_number) 147 153 148 154 def login(self): … … 303 309 'There were errors' in self.browser.contents) 304 310 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)] 306 312 self.browser.getControl(name="form.mode").value = ['create'] 307 313 self.browser.getControl( … … 317 323 self.browser.open(self.add_container_path) 318 324 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)] 320 326 self.browser.getControl(name="form.mode").value = ['create'] 321 327 self.browser.getControl( … … 326 332 self.browser.open(self.manage_root_path) 327 333 ctrl = self.browser.getControl(name='val_id') 328 ctrl.getControl(value= 'app2010').selected = True334 ctrl.getControl(value=container_name_2).selected = True 329 335 self.browser.getControl("Remove selected", index=0).click() 330 336 self.assertTrue('Successfully removed:' in self.browser.contents) 331 337 self.browser.open(self.add_container_path) 332 338 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)] 334 340 self.browser.getControl(name="form.mode").value = ['create'] 335 341 #self.browser.getControl(name="form.ac_prefix").value = ['APP'] … … 337 343 name="form.application_category").value = ['basic'] 338 344 self.browser.getControl("Add applicants container").click() 339 del self.app['applicants'][ 'app2010']345 del self.app['applicants'][container_name_2] 340 346 ctrl = self.browser.getControl(name='val_id') 341 ctrl.getControl(value= 'app2010').selected = True347 ctrl.getControl(value=container_name_2).selected = True 342 348 self.browser.getControl("Remove selected", index=0).click() 343 349 self.assertMatches('...Could not delete...', self.browser.contents) … … 465 471 self.browser.open(self.slip_path) 466 472 self.assertTrue( 467 'Please pay before trying to download the application slip.'473 'Please pay and submit before trying to download the application slip.' 468 474 in self.browser.contents) 469 475 # If applicant is in correct state the pdf slip can be opened. 470 IWorkflowState(self.applicant).setState(' paid')476 IWorkflowState(self.applicant).setState('submitted') 471 477 self.browser.open(self.manage_path) 472 478 self.browser.getLink("Download application slip").click() … … 493 499 self.browser.headers['content-length'], str(PH_LEN)) 494 500 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 495 511 def test_applicant_access(self): 496 512 # Applicants can edit their record 497 513 self.browser.open(self.login_path) 498 514 self.login() 515 self.assertTrue( 516 'You logged in.' in self.browser.contents) 499 517 self.browser.open(self.edit_path) 500 518 self.assertTrue(self.browser.url != self.login_path) … … 699 717 in self.browser.contents) 700 718 configuration = SessionConfiguration() 701 configuration.academic_session = 2009719 configuration.academic_session = session_1 702 720 configuration.application_fee = 200.0 703 721 self.app['configuration'].addSessionConfiguration(configuration) … … 727 745 payment_id = self.applicant.keys()[0] 728 746 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) 731 749 self.assertEqual(payment.p_category,'application') 732 750 self.assertEqual(payment.amount_auth,200.0) … … 821 839 self.browser.getControl("Final Submit").click() 822 840 self.assertTrue( 823 ' ... submitted ...' in self.browser.contents)841 'Application submitted' in self.browser.contents) 824 842 # ... or allow submission after deadline. 825 843 IWorkflowState(self.applicant).setState('paid') … … 830 848 self.browser.getControl("Final Submit").click() 831 849 self.assertTrue( 832 ' ... submitted ...' in self.browser.contents)850 'Application submitted' in self.browser.contents) 833 851 self.browser.goBack(count=1) 834 852 self.browser.getControl("Save").click() … … 977 995 in self.browser.contents) 978 996 #IUserAccount( 979 # self.app['applicants'][ 'app2009'][997 # self.app['applicants'][container_name_1][ 980 998 # self.applicant.application_number]).context.password = None 981 999 # Even without unsetting the password we can re-register if state
Note: See TracChangeset for help on using the changeset viewer.