Changeset 8671 for main/waeup.fceokene/trunk/src/waeup/fceokene/applicants
- Timestamp:
- 11 Jun 2012, 07:09:06 (13 years ago)
- Location:
- main/waeup.fceokene/trunk/src/waeup/fceokene/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/applicant.py
r8531 r8671 30 30 grok.provides(ICustomApplicant) 31 31 32 create_names = Applicant.create_names + [ 33 'lga', 'nationality', 'perm_address'] 34 32 35 # Set all attributes of Applicant required in IApplicant as field 33 36 # properties. Doing this, we do not have to set initial attributes -
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests.py
r8624 r8671 20 20 import tempfile 21 21 import datetime 22 import grok 23 import pytz 24 from zope.event import notify 22 25 from zope.intid.interfaces import IIntIds 23 26 from zope.interface.verify import verifyClass, verifyObject … … 26 29 from zope.catalog.interfaces import ICatalog 27 30 from zope.testbrowser.testing import Browser 31 from hurry.workflow.interfaces import IWorkflowState 28 32 from waeup.kofa.app import University 29 33 from waeup.kofa.university.faculty import Faculty … … 61 65 setSite(app) 62 66 63 # Add an two different applicants containers 64 self.pgcontainer = ApplicantsContainer() 65 self.pgcontainer.code = u'pgft2011' 66 self.pgcontainer.prefix = u'pgft' 67 self.pgcontainer.application_category = u'pg_ft' 68 self.pgcontainer.year = 2011 69 self.pgcontainer.application_fee = 300.0 70 self.pgcontainer.title = u'This is the pgft2011 container' 71 self.app['applicants']['pgft2011'] = self.pgcontainer 67 # Add an applicants containers 72 68 self.ugcontainer = ApplicantsContainer() 73 69 self.ugcontainer.code = u'putme2011' … … 79 75 self.app['applicants']['app2011'] = self.ugcontainer 80 76 77 self.ugcontainer.mode = 'update' 78 delta = datetime.timedelta(days=10) 79 self.ugcontainer.startdate = datetime.datetime.now(pytz.utc) - delta 80 self.ugcontainer.enddate = datetime.datetime.now(pytz.utc) + delta 81 81 82 # Populate university 82 83 self.certificate = createObject('waeup.Certificate') … … 85 86 self.certificate.start_level = 100 86 87 self.certificate.end_level = 500 88 self.certificate.study_mode = u'ug_ft' 87 89 self.app['faculties']['fac1'] = Faculty() 88 90 self.app['faculties']['fac1']['dep1'] = Department() 89 91 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 90 92 self.certificate) 91 self.certificate2 = createObject('waeup.Certificate') 92 self.certificate2.code = 'CERT2' 93 self.certificate2.application_category = 'pg_ft' 94 self.certificate2.start_level = 100 95 self.certificate2.end_level = 500 96 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 97 self.certificate2) 98 99 # Add (customized) applicants 100 pgapplicant = createObject(u'waeup.Applicant') 101 pgapplicant.firstname = u'Anna' 102 pgapplicant.lastname = u'Post' 103 self.app['applicants']['pgft2011'].addApplicant(pgapplicant) 104 self.pgapplication_number = pgapplicant.application_number 105 self.pgapplicant = self.app['applicants']['pgft2011'][ 106 self.pgapplication_number] 107 93 94 # Add (customized) applicant 108 95 ugapplicant = createObject(u'waeup.Applicant') 109 96 ugapplicant.firstname = u'Klaus' … … 113 100 self.ugapplicant = self.app['applicants']['app2011'][ 114 101 self.ugapplication_number] 115 self.pgapplicant_path = ('http://localhost/app/applicants/pgft2011/%s'116 % self.pgapplication_number)117 102 self.ugapplicant_path = ('http://localhost/app/applicants/app2011/%s' 118 103 % self.ugapplication_number) … … 133 118 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 134 119 self.browser.getControl(name="form.lga").value = ['foreigner'] 120 self.browser.getControl(name="form.nationality").value = ['NG'] 135 121 self.browser.getControl(name="form.sex").value = ['m'] 136 122 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 137 138 def test_manage_and_view_applicant(self):139 # Managers can manage pg applicants140 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')141 # The IPGApplicant interface is really used in all pages142 self.browser.open(self.pgapplicant_path)143 self.assertEqual(self.browser.headers['Status'], '200 Ok')144 self.assertTrue('Employer' in self.browser.contents)145 self.browser.open(self.pgapplicant_path + '/manage')146 self.assertEqual(self.browser.headers['Status'], '200 Ok')147 self.assertTrue('Employer' in self.browser.contents)148 self.browser.open(self.pgapplicant_path + '/edit')149 self.assertEqual(self.browser.headers['Status'], '200 Ok')150 self.assertTrue('Employer' in self.browser.contents)151 self.browser.open(self.pgapplicant_path + '/application_slip.pdf')152 self.assertEqual(self.browser.headers['Status'], '200 Ok')153 # If we view the applicant in the ug container,154 # the employer field doesn't appear155 self.browser.open(self.ugapplicant_path)156 self.assertEqual(self.browser.headers['Status'], '200 Ok')157 self.assertFalse('Employer' in self.browser.contents)158 self.browser.open(self.ugapplicant_path + '/manage')159 self.assertEqual(self.browser.headers['Status'], '200 Ok')160 # We can save the applicant161 self.fill_correct_values()162 self.browser.getControl(name="form.course1").value = ['CERT1']163 self.browser.getControl("Save").click()164 self.assertMatches('...Form has been saved...', self.browser.contents)165 self.assertFalse('Employer' in self.browser.contents)166 self.browser.open(self.ugapplicant_path + '/edit')167 self.assertEqual(self.browser.headers['Status'], '200 Ok')168 self.assertFalse('Employer' in self.browser.contents)169 self.browser.open(self.ugapplicant_path + '/application_slip.pdf')170 self.assertEqual(self.browser.headers['Status'], '200 Ok')171 return172 123 173 124 def test_application_payment(self): … … 195 146 self.assertEqual(payment.amount_auth, 200.0) 196 147 197 # PG applicants pay more 198 self.browser.open(self.pgapplicant_path) 199 self.browser.open(self.pgapplicant_path + '/manage') 200 self.assertEqual(self.browser.headers['Status'], '200 Ok') 148 return 149 150 def test_create_ugstudent(self): 151 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 152 manage_path = 'http://localhost/app/applicants/%s/%s/%s' % ( 153 'app2011', self.ugapplicant.application_number, 'manage') 154 self.browser.open(manage_path) 201 155 self.fill_correct_values() 202 self.browser.getControl( name="form.course1").value = ['CERT2']203 self.browser.getControl(name="form.reg_number").value = '2345'204 self.browser.getControl(name="form. firstname").value = 'Anna'205 self.browser.getControl( "Save").click()206 self. assertMatches('...Form has been saved...', self.browser.contents)207 self.browser.get Control("Add online payment ticket").click()208 s elf.assertMatches('...Payment ticket created...',209 self.browser.contents)210 self.assertMatches('...Amount Authorized...',211 self.browser.contents)212 payment_id = self.pgapplicant.keys()[0]213 payment = self.pgapplicant[payment_id]214 self.assertEqual( payment.p_item,'This is the pgft2011 container')215 self.assertEqual(payment.p_session,2011)216 self.assertEqual( payment.p_category,'application')217 self.assertEqual( payment.amount_auth, 300.0)156 self.browser.getControl("Save").click() 157 IWorkflowState(self.ugapplicant).setState('admitted') 158 self.browser.getControl(name="form.course1").value = ['CERT1'] 159 self.browser.getControl(name="form.course_admitted").value = ['CERT1'] 160 self.browser.getControl("Save").click() 161 self.browser.getLink("Create student").click() 162 student_id = self.app['students'].keys()[0] 163 self.assertTrue(('Student %s created' % student_id) 164 in self.browser.contents) 165 student = self.app['students'][student_id] 166 self.assertEqual(student.email, 'xx@yy.zz') 167 self.assertEqual(student.firstname, 'John') 168 self.assertEqual(student.lastname, 'Tester') 169 # Also additional attributes have been copied. 170 self.assertEqual(student.lga, 'foreigner') 171 self.assertEqual(student.nationality, 'NG') 218 172 return 219 173
Note: See TracChangeset for help on using the changeset viewer.