Changeset 7633 for main/waeup.sirp/trunk/src/waeup/sirp/students/tests
- Timestamp:
- 11 Feb 2012, 23:02:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_catalog.py
r7357 r7633 26 26 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 27 27 from waeup.sirp.students.student import Student 28 from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket 28 29 from waeup.sirp.university.faculty import Faculty 29 30 from waeup.sirp.university.department import Department 30 31 31 32 class CatalogTestSetup(FunctionalTestCase): 32 # A setup for testing studentscatalog related stuff.33 # A setup for testing catalog related stuff. 33 34 # 34 35 # sets up a site with some student already created. … … 54 55 self.certificate) 55 56 56 # Create student with s tudycourse subobject57 # Create student with subobjects 57 58 student = Student() 58 59 student.firstname = u'Bob' … … 62 63 self.student = self.app['students'][self.student_id] 63 64 self.student['studycourse'].certificate = self.certificate 64 # Update the catalog65 # Update the students_catalog 65 66 notify(grok.ObjectModifiedEvent(self.student)) 67 studylevel = StudentStudyLevel() 68 studylevel.level = 100 69 studylevel.level_session = 2010 70 self.student['studycourse']['100'] = studylevel 71 ticket = CourseTicket() 72 ticket.code = 'Course1' 73 self.student['studycourse']['100']['Course1'] = ticket 74 payment = createObject(u'waeup.StudentOnlinePayment') 75 payment.p_id = 'p1234567890' 76 payment.p_item = u'any item' 77 payment.p_session = 2010 78 payment.p_category = 'schoolfee' 79 payment.p_state = 'paid' 80 payment.r_pay_reference = u'GTB|WEB|FUT' 81 self.student['payments'][payment.p_id] = payment 66 82 return 67 83 … … 111 127 assert len(results) == 1 112 128 assert results[0] is self.app['students'][self.student_id] 129 130 class CourseTicketCatalogTests(CatalogTestSetup): 131 132 layer = FunctionalLayer 133 134 def test_get_catalog(self): 135 # We can get an students catalog if we wish 136 cat = queryUtility(ICatalog, name='coursetickets_catalog') 137 assert cat is not None 138 139 def test_search_by_code(self): 140 # We can find a certain course ticket by its code 141 cat = queryUtility(ICatalog, name='coursetickets_catalog') 142 results = cat.searchResults(code=('Course1', 'Course1')) 143 results = [x for x in results] # Turn results generator into list 144 assert len(results) == 1 145 assert results[0] is self.app['students'][self.student_id][ 146 'studycourse']['100']['Course1'] 147 148 def test_search_by_level(self): 149 # We can find a certain course ticket by the level 150 cat = queryUtility(ICatalog, name='coursetickets_catalog') 151 results = cat.searchResults(level=(100, 100)) 152 results = [x for x in results] # Turn results generator into list 153 assert len(results) == 1 154 assert results[0] is self.app['students'][self.student_id][ 155 'studycourse']['100']['Course1'] 156 157 def test_search_by_session(self): 158 # We can find a certain course ticket by the level session 159 cat = queryUtility(ICatalog, name='coursetickets_catalog') 160 results = cat.searchResults(session=(2010, 2010)) 161 results = [x for x in results] # Turn results generator into list 162 assert len(results) == 1 163 assert results[0] is self.app['students'][self.student_id][ 164 'studycourse']['100']['Course1'] 165 166 class PaymentCatalogTests(CatalogTestSetup): 167 168 layer = FunctionalLayer 169 170 def test_get_catalog(self): 171 # We can get an students catalog if we wish 172 cat = queryUtility(ICatalog, name='payments_catalog') 173 assert cat is not None 174 175 def test_search_by_session(self): 176 # We can find a payment ticket by the payment session 177 cat = queryUtility(ICatalog, name='payments_catalog') 178 results = cat.searchResults(p_session=(2010, 2010)) 179 results = [x for x in results] # Turn results generator into list 180 assert len(results) == 1 181 assert results[0] is self.app['students'][self.student_id][ 182 'payments']['p1234567890'] 183 184 def test_search_by_category(self): 185 # We can find a payment ticket by the payment category 186 cat = queryUtility(ICatalog, name='payments_catalog') 187 results = cat.searchResults(p_category=('schoolfee','schoolfee')) 188 results = [x for x in results] # Turn results generator into list 189 assert len(results) == 1 190 assert results[0] is self.app['students'][self.student_id][ 191 'payments']['p1234567890'] 192 193 def test_search_by_item(self): 194 # We can find a payment ticket by the payment item 195 cat = queryUtility(ICatalog, name='payments_catalog') 196 results = cat.searchResults(p_item=('any item','any item')) 197 results = [x for x in results] # Turn results generator into list 198 assert len(results) == 1 199 assert results[0] is self.app['students'][self.student_id][ 200 'payments']['p1234567890'] 201 202 def test_search_by_state(self): 203 # We can find a payment ticket by the payment state 204 cat = queryUtility(ICatalog, name='payments_catalog') 205 results = cat.searchResults(p_state=('paid','paid')) 206 results = [x for x in results] # Turn results generator into list 207 assert len(results) == 1 208 assert results[0] is self.app['students'][self.student_id][ 209 'payments']['p1234567890'] 210 211 def test_search_by_reference(self): 212 # We can find a payment ticket by parts of the response reference 213 cat = queryUtility(ICatalog, name='payments_catalog') 214 results = cat.searchResults(r_pay_reference='GTB') 215 results = [x for x in results] # Turn results generator into list 216 assert len(results) == 1 217 assert results[0] is self.app['students'][self.student_id][ 218 'payments']['p1234567890']
Note: See TracChangeset for help on using the changeset viewer.