Changeset 6652 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 29 Aug 2011, 12:28:54 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6651 r6652 183 183 self.flash('Empty search string.') 184 184 return 185 #import pdb; pdb.set_trace()186 185 if not 'entries' in form: 187 186 self.hitlist = search(query=self.searchterm, … … 228 227 student = createObject(u'waeup.Student') 229 228 self.applyData(student, **data) 230 try: 231 self.context.addStudent(student) 232 except KeyError: 233 self.flash('The student id chosen already exists.') 234 return 229 self.context.addStudent(student) 235 230 self.flash('Student record created.') 236 231 self.redirect(self.url(self.context[student.student_id], 'index')) -
main/waeup.sirp/trunk/src/waeup/sirp/students/container.py
r6644 r6652 53 53 accommodation = StudentAccommodation() 54 54 self[student.student_id]['accommodation'] = accommodation 55 return 55 # Return student_id (only needed in tests) 56 return student.student_id 56 57 57 58 logger_name = 'waeup.sirp.${sitename}.students' -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r6651 r6652 19 19 import grok 20 20 from grok import index 21 from zope.component.interfaces import IFactory 21 from zope.component.interfaces import IFactory, ComponentLookupError 22 22 from zope.interface import implementedBy 23 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState … … 37 37 super(Student, self).__init__() 38 38 IWorkflowInfo(self).fireTransition('create') 39 self.student_id = generate_student_id('?') 39 # The catalog doesn't exist in unit tests 40 try: 41 self.student_id = generate_student_id('?') 42 except ComponentLookupError: 43 self.student_id = 'Z654321' 40 44 return 41 45 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6649 r6652 71 71 setSite(app) 72 72 73 74 73 # Add student with subobjects (done by addStudent) 75 74 student = Student() 76 75 student.name = u'Anna Tester' 77 student.student_id = u'Z654321' 78 self.app['students'].addStudent(student) 76 self.test_student_id = self.app['students'].addStudent(student) 79 77 80 78 self.container_path = 'http://localhost/app/students' 81 79 self.manage_container_path = self.container_path + '/@@manage' 82 80 self.add_student_path = self.container_path + '/addstudent' 83 self.student_path = self.container_path + '/ Z654321'81 self.student_path = self.container_path + '/' + self.test_student_id 84 82 self.manage_student_path = self.student_path + '/edit_base' 85 83 self.clearance_student_path = self.student_path + '/view_clearance' … … 146 144 self.assertEqual(self.browser.headers['Status'], '200 Ok') 147 145 self.assertEqual(self.browser.url, self.add_student_path) 148 self.browser.getControl(name="form.student_id").value = 'A123456'149 146 self.browser.getControl(name="form.name").value = 'Bob Tester' 150 147 self.browser.getControl("Create student record").click() 151 148 self.assertTrue('Student record created' in self.browser.contents) 152 self.browser.open(self.manage_container_path)153 self.browser.getLink("Add student").click()154 self.browser.getControl(name="form.student_id").value = 'A123456'155 self.browser.getControl(name="form.name").value = 'Bob Brother'156 self.browser.getControl("Create student record").click()157 self.assertTrue('The student id chosen already exists' in self.browser.contents)158 149 159 150 self.browser.open(self.container_path) … … 161 152 self.assertTrue('Empty search string' in self.browser.contents) 162 153 self.browser.getControl(name="searchtype").value = ['student_id'] 163 self.browser.getControl(name="searchterm").value = 'A123456' 164 self.browser.getControl("Search").click() 165 self.assertTrue('Bob Tester' in self.browser.contents) 166 # The old searchterm will be used again 167 self.browser.getControl("Search").click() 168 self.assertTrue('Bob Tester' in self.browser.contents) 154 self.browser.getControl(name="searchterm").value = self.test_student_id 155 self.browser.getControl("Search").click() 156 self.assertTrue('Anna Tester' in self.browser.contents) 169 157 170 158 self.browser.open(self.manage_container_path) … … 172 160 self.assertTrue('Empty search string' in self.browser.contents) 173 161 self.browser.getControl(name="searchtype").value = ['name'] 174 self.browser.getControl(name="searchterm").value = 'Bob Tester' 175 self.browser.getControl("Search").click() 176 self.assertTrue('A123456' in self.browser.contents) 162 self.browser.getControl(name="searchterm").value = 'Anna Tester' 163 self.browser.getControl("Search").click() 164 self.assertTrue('Anna Tester' in self.browser.contents) 165 # The old searchterm will be used again 166 self.browser.getControl("Search").click() 167 self.assertTrue('Anna Tester' in self.browser.contents) 168 177 169 ctrl = self.browser.getControl(name='entries') 178 ctrl.getControl(value= 'A123456').selected = True170 ctrl.getControl(value=self.test_student_id).selected = True 179 171 self.browser.getControl("Remove selected", index=0).click() 180 172 self.assertTrue('Successfully removed' in self.browser.contents) 181 173 self.browser.getControl(name="searchtype").value = ['student_id'] 182 self.browser.getControl(name="searchterm").value = 'A123456'174 self.browser.getControl(name="searchterm").value = self.test_student_id 183 175 self.browser.getControl("Search").click() 184 176 self.assertTrue('No student found' in self.browser.contents) … … 186 178 self.browser.open(self.container_path) 187 179 self.browser.getControl(name="searchtype").value = ['student_id'] 188 self.browser.getControl(name="searchterm").value = 'A123456'180 self.browser.getControl(name="searchterm").value = self.test_student_id 189 181 self.browser.getControl("Search").click() 190 182 self.assertTrue('No student found' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.