Changeset 7203 for main/waeup.sirp/trunk
- Timestamp:
- 25 Nov 2011, 20:54:14 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py
r7191 r7203 39 39 matric_number = index.Field(attribute='matric_number') 40 40 state = index.Field(attribute='state') 41 certificate = index.Field(attribute='certificate') 41 certcode = index.Field(attribute='certcode') 42 depcode = index.Field(attribute='depcode') 43 faccode = index.Field(attribute='faccode') 42 44 current_session = index.Field(attribute='current_session') 43 45 -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r7191 r7203 123 123 state = Attribute('Returns the registration state of a student') 124 124 password = Attribute('Encrypted password of a student') 125 certificate = Attribute('The certificate of any chosen study course') 125 certcode = Attribute('The certificate code of any chosen study course') 126 depcode = Attribute('The department code of any chosen study course') 127 faccode = Attribute('The faculty code of any chosen study course') 126 128 current_session = Attribute('The current session of the student') 127 129 -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r7191 r7203 76 76 77 77 @property 78 def cert ificate(self):78 def certcode(self): 79 79 cert = getattr(self.get('studycourse', None), 'certificate', None) 80 return cert 80 if cert is not None: 81 return cert.code 82 return 83 84 @property 85 def faccode(self): 86 cert = getattr(self.get('studycourse', None), 'certificate', None) 87 if cert is not None: 88 return cert.__parent__.__parent__.__parent__.code 89 return 90 91 @property 92 def depcode(self): 93 cert = getattr(self.get('studycourse', None), 'certificate', None) 94 if cert is not None: 95 return cert.__parent__.__parent__.code 96 return 81 97 82 98 @property -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7201 r7203 257 257 self.browser.contents) 258 258 259 # We can find a student with a certain student_id 259 260 self.browser.open(self.container_path) 260 261 self.browser.getControl("Search").click() … … 265 266 self.assertTrue('Anna Tester' in self.browser.contents) 266 267 268 # We can find a student with a certain fullname 267 269 self.browser.open(self.manage_container_path) 268 270 self.browser.getControl("Search").click() -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_catalog.py
r7193 r7203 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 import grok 18 19 import shutil 19 20 import tempfile 21 from zope.event import notify 20 22 from zope.catalog.interfaces import ICatalog 21 from zope.component import queryUtility 23 from zope.component import queryUtility, createObject 22 24 from zope.component.hooks import setSite 23 25 from waeup.sirp.app import University 24 26 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 25 27 from waeup.sirp.students.student import Student 28 from waeup.sirp.university.faculty import Faculty 29 from waeup.sirp.university.department import Department 26 30 27 31 class CatalogTestSetup(FunctionalTestCase): … … 43 47 self.app = self.getRootFolder()['app'] 44 48 setSite(self.app) 49 self.certificate = createObject('waeup.Certificate') 50 self.certificate.code = u'CERT1' 51 self.app['faculties']['fac1'] = Faculty(code=u'fac1') 52 self.app['faculties']['fac1']['dep1'] = Department(code=u'dep1') 53 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 54 self.certificate) 45 55 46 # Create student s56 # Create student with studycourse subobject 47 57 student = Student() 48 58 student.fullname = u'Bob Tester' 49 student.student_id = u'A123456' 50 self.app['students'][student.student_id] = student 59 self.app['students'].addStudent(student) 60 self.student_id = student.student_id 61 self.student = self.app['students'][self.student_id] 62 self.student['studycourse'].certificate = self.certificate 63 # Update the catalog 64 notify(grok.ObjectModifiedEvent(self.student)) 51 65 return 52 66 … … 68 82 # We can find a certain student id 69 83 cat = queryUtility(ICatalog, name='students_catalog') 70 results = cat.searchResults(student_id=( 'A123456', 'A123456'))84 results = cat.searchResults(student_id=(self.student_id, self.student_id)) 71 85 results = [x for x in results] # Turn results generator into list 72 86 assert len(results) == 1 73 assert results[0] is self.app['students'][ 'A123456']87 assert results[0] is self.app['students'][self.student_id] 74 88 75 89 def test_search_by_name(self): … … 79 93 results = [x for x in results] # Turn results generator into list 80 94 assert len(results) == 1 81 assert results[0] is self.app['students']['A123456'] 95 assert results[0] is self.app['students'][self.student_id] 96 97 def test_search_by_department(self): 98 # We can find a student studying in a certain department 99 cat = queryUtility(ICatalog, name='students_catalog') 100 results = cat.searchResults(depcode=('dep1','dep1')) 101 results = [x for x in results] # Turn results generator into list 102 assert len(results) == 1 103 assert results[0] is self.app['students'][self.student_id] 104 105 def test_search_by_faculty(self): 106 # We can find a student studying in a certain faculty 107 cat = queryUtility(ICatalog, name='students_catalog') 108 results = cat.searchResults(faccode=('fac1','fac1')) 109 results = [x for x in results] # Turn results generator into list 110 assert len(results) == 1 111 assert results[0] is self.app['students'][self.student_id]
Note: See TracChangeset for help on using the changeset viewer.