Changeset 10216
- Timestamp:
- 24 May 2013, 05:17:21 (12 years ago)
- Location:
- main/waeup.futminna/trunk/src/waeup/futminna/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.futminna/trunk/src/waeup/futminna/applicants/tests/test_browser.py
r10203 r10216 21 21 22 22 import os 23 import grok 24 from zope.event import notify 23 25 from StringIO import StringIO 24 26 from zope.component import createObject, getUtility … … 248 250 249 251 def test_certificate_source(self): 252 # We add a second 'alternative' certificate 253 certificate = createObject('waeup.Certificate') 254 certificate.code = 'CERT2' 255 certificate.title = 'New Certificate' 256 certificate.application_category = 'basic' 257 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 258 certificate) 250 259 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 251 self.browser.open(self.manage_path) 252 self.assertTrue('value="CERT1">CERT1 - Unnamed Certificate</option>' 253 in self.browser.contents) 260 self.browser.open(self.edit_path) 261 self.assertFalse('course2' in self.browser.contents) 254 262 self.certificate.custom_textline_1 = u'Maths, Physics' 255 263 self.certificate.custom_float_1 = 50.0 256 self.browser.open(self.manage_path) 257 self.assertTrue( 258 'value="CERT1">CERT1 - Unnamed Certificate [Maths, Physics, 50]</option>' 259 in self.browser.contents) 264 certificate.custom_textline_1 = u'German, Physics' 265 certificate.custom_float_1 = 30.0 266 notify(grok.ObjectModifiedEvent(certificate)) 267 self.browser.open(self.edit_path) 268 # Score must be set and below the limit 269 # of course1 to see course2 field 270 self.applicant.jamb_score = 20 271 self.browser.open(self.edit_path) 272 self.assertTrue('course2' in self.browser.contents) 273 # But 20 is not enough to select the alternative CERT2 274 self.assertFalse( 275 'value="CERT2">CERT2 - New Certificate' 276 in self.browser.contents) 277 self.applicant.jamb_score = 30 278 self.browser.open(self.edit_path) 279 # 30 is enough 280 self.assertTrue('course2' in self.browser.contents) 281 self.assertTrue( 282 'value="CERT2">CERT2 - New Certificate [German, Physics, 30]</option>' 283 in self.browser.contents) 284 285 def test_low_jamb_score(self): 286 self.login() 287 self.assertFalse('<select id="form.course2" name="form.course2" size="1" >' 288 in self.browser.contents) 289 self.certificate.custom_textline_1 = u'Maths, Physics' 290 self.certificate.custom_float_1 = 50.0 291 self.applicant.jamb_score = 40 292 self.browser.open(self.edit_path) 293 self.assertTrue('<select id="form.course2" name="form.course2" size="1" >' 294 in self.browser.contents) -
main/waeup.futminna/trunk/src/waeup/futminna/applicants/utils.py
r10203 r10216 37 37 """Filter and sort certificates in AppCatCertificateSource. 38 38 """ 39 return sorted(resultset, key=lambda value: value.code) 39 certs = sorted(resultset, key=lambda value: value.code) 40 resultlist = [cert for cert in certs 41 if not None in (context.jamb_score, cert.custom_float_1) 42 and context.jamb_score >= cert.custom_float_1] 43 curr_course = context.course1 44 if curr_course is not None and curr_course not in resultlist: 45 # display also current course even if certificate has been removed 46 # or does not meet requirement 47 resultlist = [curr_course,] + resultlist 48 return resultlist 40 49 41 50 def getCertTitle(self, context, value):
Note: See TracChangeset for help on using the changeset viewer.