- Timestamp:
- 25 Nov 2011, 20:54:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.