Changeset 6585 for main/waeup.sirp/trunk
- Timestamp:
- 10 Aug 2011, 10:37:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
r6583 r6585 68 68 setSite(app) 69 69 70 self.root_path = 'http://localhost/app/applicants /'71 self.container_path = 'http://localhost/app/applicants/app2009 /'70 self.root_path = 'http://localhost/app/applicants' 71 self.container_path = 'http://localhost/app/applicants/app2009' 72 72 73 73 # Add an applicants container … … 108 108 self.applicant.access_code = self.pin_applicant 109 109 app['applicants']['app2009'][self.pin_applicant] = self.applicant 110 111 # Add an officer 112 myusers = self.app['users'] 113 myusers.addUser('bob', 'bobssecret') 110 114 return 111 115 … … 142 146 def test_manage_access(self): 143 147 # Managers can access the manage pages of applicants root and 144 # applicants containers 148 # applicants containers and can perform actions 145 149 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 146 150 self.browser.open(self.root_path) … … 155 159 self.assertEqual(self.browser.headers['Status'], '200 Ok') 156 160 self.assertEqual(self.browser.url, self.manage_container_path) 161 self.browser.getControl("Save").click() 162 self.assertTrue( 163 'Data saved' in self.browser.contents) 164 self.browser.getControl("Remove selected", index=0).click() 165 self.assertTrue( 166 'No applicant selected' in self.browser.contents) 167 self.browser.getControl("Cancel", index=0).click() 168 self.assertEqual(self.browser.url, self.container_path) 157 169 return 158 170 159 171 def test_add_delete_container(self): 160 172 # Managers can add and delete applicants containers 161 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 162 self.browser.open(self.root_path) 173 self.manage_root_path = self.root_path + '/@@manage' 163 174 self.add_container_path = self.root_path + '/@@add' 164 self.browser.open(self.add_container_path) 175 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 176 self.browser.open(self.manage_root_path) 177 self.browser.getControl("Cancel").click() 178 self.assertEqual(self.browser.url, self.root_path) 179 self.browser.open(self.manage_root_path) 180 self.browser.getControl("Add applicants container").click() 165 181 self.assertEqual(self.browser.headers['Status'], '200 Ok') 166 182 self.assertEqual(self.browser.url, self.add_container_path) … … 177 193 self.browser.getControl("Add applicants container").click() 178 194 self.assertTrue('Added:' in self.browser.contents) 195 self.browser.open(self.add_container_path) 196 self.browser.getControl(name="form.prefix").value = ['app'] 197 self.browser.getControl(name="form.year").value = ['2010'] 198 self.browser.getControl(name="form.provider").value = [ 199 'waeup.sirp.applicants.ApplicantsContainer'] 200 self.browser.getControl(name="form.ac_prefix").value = ['APP'] 201 self.browser.getControl(name="form.application_category").value = ['basic'] 202 self.browser.getControl("Add applicants container").click() 203 self.assertTrue('exists already in the database' in self.browser.contents) 204 self.browser.open(self.manage_root_path) 179 205 ctrl = self.browser.getControl(name='val_id') 180 206 ctrl.getControl(value='app2010').selected = True … … 203 229 return 204 230 205 def test_manage_a pplicant(self):231 def test_manage_and_view_applicant(self): 206 232 # Managers can manage applicants 207 233 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 210 236 self.applicant_manage_path = self.applicant_path + '/edit_full' 211 237 self.applicant_slip_path = self.applicant_path + '/application_slip.pdf' 212 self.browser.open(self.applicant_view_path)213 self.assertEqual(self.browser.headers['Status'], '200 Ok')214 self.browser.open(self.applicant_slip_path)215 self.assertEqual(self.browser.headers['Status'], '200 Ok')216 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')217 238 self.browser.open(self.applicant_manage_path) 218 239 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 226 247 self.browser.getControl("Save").click() 227 248 self.assertMatches('...Form has been saved...', self.browser.contents) 249 self.browser.open(self.applicant_view_path) 250 self.assertEqual(self.browser.headers['Status'], '200 Ok') 251 self.browser.open(self.applicant_slip_path) 252 self.assertEqual(self.browser.headers['Status'], '200 Ok') 253 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 228 254 return 229 255 … … 665 691 self.assertTrue(passport0 != passport1) 666 692 self.assertTrue(passport1 == passport2) 667 self.assertTrue(passport1 is not passport2) 668 return 693 self.assertTrue(passport1 is passport2) 694 return 695 696 def test_final_submit(self): 697 # Make sure that a correctly filled form with passport picture 698 # can be submitted 699 self.login() # Create applicant form 700 self.fill_correct_values() # fill other fields with correct values 701 # Create a pseudo image file and select it to be uploaded in form 702 pseudo_image = StringIO('I pretend to be a graphics file') 703 ctrl = self.browser.getControl(name='form.passport') 704 file_ctrl = ctrl.mech_control 705 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 706 self.browser.getControl("Final Submit").click() # (finally) submit form 707 self.assertEqual(self.browser.headers['Status'], '200 Ok') 708 self.assertTrue( 709 'Passport confirmation box not ticked' in self.browser.contents) 710 self.browser.getControl(name="confirm_passport").value = True 711 self.browser.getControl("Final Submit").click() # submit form again 712 self.assertTrue( 713 '... submitted ...' in self.browser.contents) 714 return 715 716 def test_locking(self): 717 # Make sure that locked forms can't be submitted 718 self.login() # Create applicant form 719 self.fill_correct_values() # fill other fields with correct values 720 # Create a pseudo image file and select it to be uploaded in form 721 pseudo_image = StringIO('I pretend to be a graphics file') 722 ctrl = self.browser.getControl(name='form.passport') 723 file_ctrl = ctrl.mech_control 724 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 725 self.browser.getControl("Save").click() 726 self.browser.getLink("Logout").click() 727 728 # Login as manager and lock the form 729 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 730 self.browser.open(self.edit_full_path) 731 self.browser.getControl(name="form.locked").value = True 732 self.browser.getControl("Save").click() 733 self.browser.getLink("Logout").click() 734 735 # Login as applicant again and try to open the edit form 736 self.login() 737 self.browser.open(self.edit_path) 738 self.assertEqual(self.browser.headers['Status'], '200 Ok') 739 #print self.browser.contents 740 self.assertTrue( 741 'The requested form is locked' in self.browser.contents) 742 return
Note: See TracChangeset for help on using the changeset viewer.