'
'\nmsg: Subject: Your new Kofa student account'
'\nmsg:'
'\nmsg: Dear John Anthony Tester,'
'\nmsg:'
'\nmsg: Your student record of the Student Registration and Information Portal of'
'\nmsg: Sample University has been created for you.'
'\nmsg:'
'\nmsg: Your user name: K1000000'
'\nmsg: Your password: %s'
'\nmsg: Login: http://localhost/app/login?login=K1000000&password=%s'
'\nmsg:'
'\nmsg: Or request a new secure password here: http://localhost/app/changepw'
'\nmsg:'
'\nmsg: Regards'
'\nmsg:' % (self.applicant.application_number, self.applicant.application_number),
self.get_fake_smtp_output()
)
return
class ApplicantRegisterTests(ApplicantsFullSetup):
# Tests for applicant registration
layer = FunctionalLayer
def test_register_applicant_create(self):
config = grok.getSite()['configuration']
config.maintmode_enabled_by = u'any_user'
self.assertEqual(len(self.app['applicants'][container_name_1]), 1)
# An applicant can register himself.
self.browser.open(self.container_path)
self.browser.getLink("Register for application").click()
self.assertTrue(
'The portal is in maintenance mode' in self.browser.contents)
config.maintmode_enabled_by = None
self.browser.getLink("Register for application").click()
# The edit form now opens and can be filled with suitable values
self.browser.getControl(name="form.firstname").value = 'Anna'
self.browser.getControl(name="form.lastname").value = 'Kurios'
self.browser.getControl(name="form.email").value = 'xx@yy.zz'
self.browser.getControl(name="form.phone.country").value = ['+234']
self.browser.getControl(name="form.phone.area").value = '555'
self.browser.getControl(name="form.phone.ext").value = '6666666'
self.browser.getControl("Send login credentials").click()
self.assertEqual(self.browser.url,
self.container_path + '/registration_complete?email=xx%40yy.zz')
# A new applicant has been created
self.assertEqual(len(self.app['applicants'][container_name_1]), 2)
# The new applicant can be found in the catalog via the email address
cat = getUtility(ICatalog, name='applicants_catalog')
results = list(
cat.searchResults(email=('xx@yy.zz', 'xx@yy.zz')))
applicant = results[0]
self.assertEqual(applicant.lastname,'Kurios')
# The application_id has been copied to the reg_number
#self.assertEqual(applicant.applicant_id, applicant.reg_number)
# The applicant can be found in the catalog via the reg_number
#results = list(
# cat.searchResults(
# reg_number=(applicant.reg_number, applicant.reg_number)))
#self.assertEqual(applicant,results[0])
return
def test_register_applicant_take_unused_record(self):
# Create an unused record
uu_applicant = createObject('waeup.Applicant')
self.app['applicants'][container_name_1].addApplicant(uu_applicant)
self.assertEqual(uu_applicant.container_code, container_name_1 + '-')
self.assertEqual(len(self.app['applicants'][container_name_1]), 2)
self.browser.open(self.container_path)
self.browser.getLink("Register for application").click()
# Fill the edit form with suitable values
self.browser.getControl(name="form.firstname").value = 'Anna'
self.browser.getControl(name="form.lastname").value = 'Kurios'
self.browser.getControl(name="form.email").value = 'xx@yy.zz'
self.browser.getControl(name="form.phone.country").value = ['+234']
self.browser.getControl(name="form.phone.area").value = '555'
self.browser.getControl(name="form.phone.ext").value = '6666666'
self.browser.getControl("Send login credentials").click()
# No applicant has been created ...
self.assertEqual(len(self.app['applicants'][container_name_1]), 2)
# ... and the existing, formerly unused record has been used instead
self.assertEqual(uu_applicant.lastname, 'Kurios')
self.assertEqual(uu_applicant.container_code, container_name_1 + '+')
return
def test_register_applicant_update(self):
# We change the application mode and check if applicants
# can find and update imported records instead of creating new records.
# First we check what happens if record does not exist.
self.applicantscontainer.mode = 'update'
self.browser.open(self.container_path + '/register')
self.browser.getControl(name="form.lastname").value = 'Better'
self.browser.getControl(name="form.reg_number").value = 'anynumber'
self.browser.getControl(name="form.email").value = 'xx@yy.zz'
self.browser.getControl("Send login credentials").click()
self.assertTrue('No application record found.'
in self.browser.contents)
# Even with the correct reg_number we can't register
# because lastname attribute is not set.
self.applicantscontainer.mode = 'update'
self.browser.open(self.container_path + '/register')
self.browser.getControl(name="form.lastname").value = 'Better'
self.browser.getControl(name="form.reg_number").value = '1234'
self.browser.getControl(name="form.email").value = 'xx@yy.zz'
self.browser.getControl("Send login credentials").click()
self.assertTrue('An error occurred.' in self.browser.contents)
# Let's set this attribute manually
# and try to register with a wrong name.
self.applicant.lastname = u'Better'
self.browser.open(self.container_path + '/register')
self.browser.getControl(name="form.lastname").value = 'Worse'
self.browser.getControl(name="form.reg_number").value = '1234'
self.browser.getControl(name="form.email").value = 'xx@yy.zz'
self.browser.getControl("Send login credentials").click()
# Anonymous is not informed that lastname verification failed.
# It seems that the record doesn't exist.
self.assertTrue('No application record found.'
in self.browser.contents)
# Even with the correct lastname we can't register if a
# password has been set and used.
IWorkflowState(self.applicant).setState('started')
self.browser.getControl(name="form.lastname").value = 'Better'
self.browser.getControl(name="form.reg_number").value = '1234'
self.browser.getControl("Send login credentials").click()
self.assertTrue('Your password has already been set and used.'
in self.browser.contents)
#IUserAccount(
# self.app['applicants'][container_name_1][
# self.applicant.application_number]).context.password = None
# Even without unsetting the password we can re-register if state
# is 'initialized'
IWorkflowState(self.applicant).setState('initialized')
self.browser.open(self.container_path + '/register')
# The lastname field, used for verification, is not case-sensitive.
self.browser.getControl(name="form.lastname").value = 'bEtter'
self.browser.getControl(name="form.reg_number").value = '1234'
self.browser.getControl(name="form.email").value = 'new@yy.zz'
self.browser.getControl("Send login credentials").click()
# Yeah, we succeded ...
self.assertTrue('Your registration was successful.'
in self.browser.contents)
# ... and applicant can be found in the catalog via the email address
cat = getUtility(ICatalog, name='applicants_catalog')
results = list(
cat.searchResults(
email=('new@yy.zz', 'new@yy.zz')))
self.assertEqual(self.applicant,results[0])
return
def test_change_password_request(self):
self.browser.open('http://localhost/app/changepw')
self.browser.getControl(name="form.identifier").value = '1234'
self.browser.getControl(name="form.email").value = 'aa@aa.ng'
self.browser.getControl("Send login credentials").click()
self.assertTrue('No record found' in self.browser.contents)
self.applicant.email = 'aa@aa.ng'
# Update the catalog
notify(grok.ObjectModifiedEvent(self.applicant))
self.browser.open('http://localhost/app/changepw')
self.browser.getControl(name="form.identifier").value = '1234'
self.browser.getControl(name="form.email").value = 'aa@aa.ng'
self.browser.getControl("Send login credentials").click()
self.assertTrue(
'An email with your user name and password has been sent'
in self.browser.contents)
def test_check_status(self):
self.applicant.lastname = u'Lion '
self.browser.open('http://localhost/app/applicants/checkstatus')
self.browser.getControl(name="unique_id").value = 'nonsense'
self.browser.getControl(name="lastname").value = 'Lion'
self.browser.getControl("Submit").click()
self.assertTrue('No application record found' in self.browser.contents)
self.browser.getControl(
name="unique_id").value = self.applicant.applicant_id
self.browser.getControl(name="lastname").value = 'nonsense'
self.browser.getControl("Submit").click()
self.assertTrue('No application record found' in self.browser.contents)
self.browser.getControl(
name="unique_id").value = self.applicant.applicant_id
self.browser.getControl(name="lastname").value = 'Lion'
self.browser.getControl("Submit").click()
self.assertTrue('Admission status of' in self.browser.contents)
self.assertTrue(
'You have not yet submitted your application' in self.browser.contents)
IWorkflowState(self.applicant).setState('admitted')
self.browser.open('http://localhost/app/applicants/checkstatus')
self.browser.getControl(
name="unique_id").value = self.applicant.applicant_id
# Whitespaces are ignored.
self.browser.getControl(name="lastname").value = 'Lion'
self.browser.getControl("Submit").click()
self.assertTrue('Congratulations!' in self.browser.contents)
self.assertFalse('Study Course' in self.browser.contents)
self.applicant.course_admitted = self.certificate
self.browser.open('http://localhost/app/applicants/checkstatus')
self.browser.getControl(
name="unique_id").value = self.applicant.applicant_id
self.browser.getControl(name="lastname").value = 'Lion'
self.browser.getControl("Submit").click()
self.assertTrue('Congratulations!' in self.browser.contents)
self.assertTrue('Unnamed Certificate (CERT1)' in self.browser.contents)
self.assertTrue(
'Department of Unnamed Department (dep1)' in self.browser.contents)
self.assertTrue(
'Faculty of Unnamed Faculty (NA)' in self.browser.contents)
# Also the reg_number can be used and page shows student id and password
# if applicant is in state created.
IWorkflowState(self.applicant).setState('created')
self.applicant.student_id = u'my id'
self.browser.open('http://localhost/app/applicants/checkstatus')
self.browser.getControl(
name="unique_id").value = self.applicant.reg_number
self.browser.getControl(name="lastname").value = 'Lion'
self.browser.getControl("Submit").click()
self.assertTrue('Congratulations!' in self.browser.contents)
self.assertTrue('Unnamed Certificate (CERT1)' in self.browser.contents)
self.assertTrue('Department of Unnamed Department (dep1)'
in self.browser.contents)
self.assertTrue(
'Faculty of Unnamed Faculty (NA)' in self.browser.contents)
self.assertTrue('user name (= student id) is: my id'
in self.browser.contents)
self.assertTrue(
'password is: %s' % self.applicant.application_number
in self.browser.contents)
def test_check_transcript_status(self):
self.applicant.email = 'aa@aa.aa'
self.browser.open('http://localhost/app/applicants/checktranscript')
self.browser.getControl(name="unique_id").value = 'nonsense'
self.browser.getControl(name="email").value = 'aa@aa.aa'
self.browser.getControl("Check status now").click()
self.assertTrue('No student record was found in Kofa'
in self.browser.contents)
class ApplicantsExportTests(ApplicantsFullSetup, FunctionalAsyncTestCase):
# Tests for StudentsContainer class views and pages
layer = FunctionalLayer
def wait_for_export_jobs_completed(self):
# helper function waiting until the current export job is completed
manager = getUtility(IJobManager)
job_ids = [i[0] for i in self.app['datacenter'].running_exports]
jobs = [manager.get(job_id) for job_id in job_ids]
for job in jobs:
wait_for_result(job)
return job_ids
def test_applicants_in_container_export(self):
self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
container_path = 'http://localhost/app/applicants/%s' % container_name_1
self.browser.open(container_path)
self.browser.getLink("Export application data").click()
self.browser.getControl("Start new exports").click()
job_ids = self.wait_for_export_jobs_completed()
# Three exports were created
self.assertEqual(len(self.app['datacenter'].running_exports), 3)
# When the jobs are finished and we reload the page...
self.browser.open(container_path + '/exports')
# ... the both csv files can be downloaded ...
self.browser.getLink("Download", index=0).click()
self.assertEqual(self.browser.headers['content-type'],
'text/csv; charset=UTF-8')
self.assertTrue(
'filename="WAeUP.Kofa_applicants_%s.csv' % job_ids[0] in
self.browser.headers['content-disposition'])
self.browser.open(container_path + '/exports')
self.browser.getLink("Download", index=1).click()
self.assertEqual(self.browser.headers['content-type'],
'text/csv; charset=UTF-8')
self.assertTrue(
'filename="WAeUP.Kofa_applicantpayments_%s.csv' % job_ids[1] in
self.browser.headers['content-disposition'])
self.browser.open(container_path + '/exports')
self.browser.getLink("Download", index=2).click()
self.assertEqual(self.browser.headers['content-type'],
'text/csv; charset=UTF-8')
self.assertTrue(
'filename="WAeUP.Kofa_applicantrefereereports_%s.csv' % job_ids[2] in
self.browser.headers['content-disposition'])
# ... and discarded
self.browser.open(container_path + '/exports')
self.browser.getControl("Discard", index=0).click()
self.assertEqual(len(self.app['datacenter'].running_exports), 2)
self.browser.getControl("Discard", index=0).click()
self.assertEqual(len(self.app['datacenter'].running_exports), 1)
self.browser.getControl("Discard").click()
self.assertEqual(len(self.app['datacenter'].running_exports), 0)
# Creation, downloading and discarding are logged
logfile = os.path.join(
self.app['datacenter'].storage, 'logs', 'datacenter.log')
logcontent = open(logfile).read()
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerJobStart - '
'exported: applicants (%s), job_id=%s'
% (container_name_1, job_ids[0]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerDownload '
'- downloaded: WAeUP.Kofa_applicants_%s.csv, job_id=%s'
% (job_ids[0], job_ids[0]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerOverview '
'- discarded: job_id=%s' % job_ids[0] in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerJobStart - '
'exported: applicantpayments (%s), job_id=%s'
% (container_name_1, job_ids[1]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerDownload '
'- downloaded: WAeUP.Kofa_applicantpayments_%s.csv, job_id=%s'
% (job_ids[1], job_ids[1]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerOverview '
'- discarded: job_id=%s' % job_ids[1] in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerJobStart - '
'exported: applicantrefereereports (%s), job_id=%s'
% (container_name_1, job_ids[2]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerDownload '
'- downloaded: WAeUP.Kofa_applicantrefereereports_%s.csv, job_id=%s'
% (job_ids[2], job_ids[2]) in logcontent
)
self.assertTrue(
'zope.mgr - applicants.browser.ExportJobContainerOverview '
'- discarded: job_id=%s' % job_ids[2] in logcontent
)
class ApplicantRefereeReportTests(ApplicantsFullSetup, FunctionalAsyncTestCase):
# Tests for ApplicantRefereeReport class views and pages
layer = FunctionalLayer
def setUp(self):
super(ApplicantRefereeReportTests, self).setUp()
self.setup_logging()
return
def tearDown(self):
super(ApplicantRefereeReportTests, self).tearDown()
self.teardown_logging()
return
def setup_logging(self):
# setup a log-handler that catches all fake mailer output
self.stream = StringIO()
handler = logging.StreamHandler(self.stream)
logger = logging.getLogger('test.smtp')
logger.addHandler(handler)
logger.setLevel(logging.INFO)
return
def get_fake_smtp_output(self):
# get output generated by fake mailer
self.stream.flush()
self.stream.seek(0)
return self.stream.read()
def teardown_logging(self):
# remove the log handler for fake mailer output
logger = logging.getLogger('test.smtp')
handlers = [x for x in logger.handlers]
for handler in handlers:
logger.removeHandler(handler)
return
def test_refereereport_mandate(self):
mandate = RefereeReportMandate()
mandate.params['name'] = u'John Referee'
mandate.params['email'] = 'aa@aa.aa'
mandate.params['applicant_id'] = self.applicant.applicant_id
mandate.params[
'redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
container_name_1, self.applicant.application_number)
self.app['mandates'].addMandate(mandate)
# Let's open the add form page via the mandate view
self.browser.open('http://localhost/app/mandate?mandate_id=%s'
% mandate.mandate_id)
# Form page opens and is prefilled
self.assertEqual(
self.browser.url,
'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s'
% (container_name_1, self.applicant.application_number,
mandate.mandate_id))
self.assertTrue('value="John Referee"' in self.browser.contents)
# Let's open the page directly with an invalid mandate
self.browser.open(
'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=wrongmadate'
% (container_name_1, self.applicant.application_number))
self.assertTrue('No mandate.
'
in self.browser.contents)
self.assertEqual(self.browser.url, 'http://localhost/app')
# Page is also blocked in maintenance mode
grok.getSite()['configuration'].maintmode_enabled_by = u'anybody'
self.browser.open(
'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s'
% (container_name_1, self.applicant.application_number,
mandate.mandate_id))
self.assertTrue('The portal is '
'in maintenance mode'
in self.browser.contents)
self.assertEqual(self.browser.url, 'http://localhost/app')
return
def test_add_and_view_manage_reports(self):
mandate = RefereeReportMandate()
mandate.params['name'] = u'John Referee'
mandate.params['email'] = 'aa@aa.aa'
mandate.params['applicant_id'] = self.applicant.applicant_id
mandate.params['redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
container_name_1, self.applicant.application_number)
mandate.params['redirect_path2'] = ''
self.app['mandates'].addMandate(mandate)
self.assertEqual(len(self.app['mandates'].keys()), 1)
# Let's open the add form page via the mandate view
self.browser.open('http://localhost/app/mandate?mandate_id=%s'
% mandate.mandate_id)
self.assertTrue('Joan None' in self.browser.contents)
self.assertTrue('John Referee' in self.browser.contents)
# Report can't be saved without required fields
self.browser.getControl(name="form.name").value = ''
self.browser.getControl("Submit").click()
self.assertTrue('Required input is missing' in self.browser.contents)
self.browser.getControl(name="form.name").value = 'Johnny Referee'
self.browser.getControl("Submit").click()
# Referee will be redirected to the frontpage
self.assertEqual(self.browser.url, 'http://localhost/app')
self.assertTrue('Your report has been successfully submitted. '
'Please use the report link in the email again '
'to download a pdf slip of your report.'
in self.browser.contents)
# If they use the mandate again, they will be redirected to a pdf file
self.browser.open('http://localhost/app/mandate?mandate_id=%s'
% mandate.mandate_id)
self.assertEqual(self.browser.headers['Status'], '200 Ok')
self.assertEqual(self.browser.headers['Content-Type'],
'application/pdf')
path = os.path.join(samples_dir(), 'referee_report.pdf')
open(path, 'wb').write(self.browser.contents)
print "Sample PDF referee_report.pdf written to %s" % path
# Report has been created
self.assertEqual(len(self.applicant.refereereports), 1)
report = self.applicant.refereereports[0]
# The email address has been stored
self.assertEqual(report.email, 'aa@aa.aa')
# Referee can use mandate again to download the pdf report
self.browser.open('http://localhost/app/mandate?mandate_id=%s'
% mandate.mandate_id)
self.assertEqual(self.browser.headers['Status'], '200 Ok')
self.assertEqual(self.browser.headers['Content-Type'],
'application/pdf')
# Referees can't use another mandate for adding a new report
mandate2 = RefereeReportMandate()
mandate2.params['name'] = u'John Referee'
mandate2.params['email'] = 'aa@aa.aa'
mandate2.params['applicant_id'] = self.applicant.applicant_id
mandate2.params['redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
container_name_1, self.applicant.application_number)
mandate2.params['redirect_path2'] = ''
self.app['mandates'].addMandate(mandate2)
self.browser.open('http://localhost/app/mandate?mandate_id=%s'
% mandate2.mandate_id)
self.assertTrue('You have already created a report with another mandate'
in self.browser.contents)
# Managers can view the report
self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
self.browser.open(self.manage_path)
self.browser.getLink("%s" % report.r_id).click()
self.assertEqual(
self.browser.url, self.view_path + '/%s' % report.r_id)
self.assertTrue('Johnny Referee' in self.browser.contents)
# Managers can download a pdf slip
self.browser.getLink("Download referee report").click()
self.assertEqual(self.browser.headers['Status'], '200 Ok')
self.assertEqual(self.browser.headers['Content-Type'],
'application/pdf')
# Mandate is not deleted ...
self.assertEqual(len(self.app['mandates'].keys()), 2)
# ... but redirect_path2 attribute has been set
redirect_path2 = '/applicants/%s/%s/%s/referee_report.pdf' % (
container_name_1,
self.applicant.application_number,
report.r_id)
self.assertEqual(
self.app['mandates'][mandate.mandate_id].params['redirect_path2'],
redirect_path2)
# Portal managers can edit referee reports (no button available!)
self.browser.open(self.view_path + '/%s/manage' % report.r_id)
self.browser.getControl(name="form.email_pref").value = 'bb@bb.de'
self.browser.getControl("Save").click()
self.assertEqual(report.email_pref, 'bb@bb.de')
# Managers can delete referee reports
self.browser.open(self.manage_path)
self.browser.getLink("%s" % report.r_id).click()
self.assertEqual(len(self.applicant.refereereports), 1)
self.browser.getLink("Delete").click()
self.assertEqual(len(self.applicant.refereereports), 0)
self.assertTrue('Referee report removed.' in self.browser.contents)
self.assertEqual(self.browser.url, self.view_path)
# Report creation, managing and deletion is logged
logfile = os.path.join(
self.app['datacenter'].storage, 'logs', 'applicants.log')
logcontent = open(logfile).read()
self.assertTrue(
'zope.anybody - applicants.browser.RefereeReportAddFormPage - '
'%s - added: %s\n' % (self.applicant.applicant_id, report.r_id)
in logcontent)
self.assertTrue(
'zope.mgr - applicants.browser.RefereeReportManageFormPage - '
'%s - %s - saved: email_pref\n' % (
self.applicant.applicant_id, report.r_id) in logcontent)
self.assertTrue(
'zope.mgr - applicants.browser.RemoveRefereeReportPage - '
'%s - removed: %s\n' % (self.applicant.applicant_id, report.r_id)
in logcontent)
return
def test_final_submit_with_referees(self):
# Add two referees
referee1 = RefereeEntry()
referee2 = RefereeEntry()
referee1.name = u'Linda Tree'
referee1.email = 'linda@forest.de'
referee2.name = u'Otis Stone'
referee2.email = 'otis@stones.de'
self.applicant.__parent__.send_email = True
self.applicant.referees = [referee1, referee2]
self.assertFalse(referee1.email_sent)
self.assertFalse(referee2.email_sent)
self.login()
IWorkflowInfo(self.applicant).fireTransition('pay')
self.browser.open(self.edit_path)
self.fill_correct_values() # fill other fields with correct values
image = open(SAMPLE_IMAGE, 'rb')
ctrl = self.browser.getControl(name='form.passport')
file_ctrl = ctrl.mech_control
file_ctrl.add_file(image, filename='myphoto.jpg')
self.browser.getControl("Save").click()
self.browser.getControl(name="confirm_passport").value = True
self.browser.getControl("Finally Submit").click()
if self.app['mandates'].values()[0].params['name'] == 'Linda Tree':
mandate_id_0 = self.app['mandates'].keys()[0]
mandate_id_1 = self.app['mandates'].keys()[1]
else:
mandate_id_0 = self.app['mandates'].keys()[1]
mandate_id_1 = self.app['mandates'].keys()[0]
self.assertMatches(
'Sending email from no-reply@waeup.org to linda@forest.de:'
'\nMessage:'
'\nmsg: MIME-Version: 1.0\nmsg: Content-Type: text/plain; charset="us-ascii"'
'\nmsg: Content-Transfer-Encoding: 7bit'
'\nmsg: From: Administrator '
'\nmsg: To: Linda Tree '
'\nmsg: Reply-To: Administrator '
'\nmsg: Subject: Request for referee report from Sample University'
'\nmsg: '
'\nmsg: Dear Linda Tree,'
'\nmsg: '
'\nmsg: The candidate with Id app%s_372052 and name John Anthony Tester applied to'
'\nmsg: the Sample University to study Unnamed Certificate for the %s/%s session.'
'\nmsg: The candidate has listed you as referee. You are, therefore, required to,'
'\nmsg: kindly, provide your referral remarks on or before .<6-DIGITS>+00:00. Please use the'
'\nmsg: following form:'
'\nmsg: '
'\nmsg: Report link: http://localhost/app/mandate?mandate_id=%s'
'\nmsg: '
'\nmsg: Thank You'
'\nmsg: '
'\nmsg: The Secretary'
'\nmsg: School of Postgraduate Studies'
'\nmsg: Sample University'
'\nmsg: '
'\nSending email from no-reply@waeup.org to otis@stones.de:'
'\nMessage:'
'\nmsg: MIME-Version: 1.0'
'\nmsg: Content-Type: text/plain; charset="us-ascii"'
'\nmsg: Content-Transfer-Encoding: 7bit'
'\nmsg: From: Administrator '
'\nmsg: To: Otis Stone '
'\nmsg: Reply-To: Administrator '
'\nmsg: Subject: Request for referee report from Sample University'
'\nmsg: '
'\nmsg: Dear Otis Stone,'
'\nmsg: '
'\nmsg: The candidate with Id app%s_<6-DIGITS> and name John Anthony Tester applied to'
'\nmsg: the Sample University to study Unnamed Certificate for the %s/%s session.'
'\nmsg: The candidate has listed you as referee. You are, therefore, required to,'
'\nmsg: kindly, provide your referral remarks on or before .<6-DIGITS>+00:00. Please use the'
'\nmsg: following form:'
'\nmsg: '
'\nmsg: Report link: http://localhost/app/mandate?mandate_id=%s'
'\nmsg: '
'\nmsg: Thank You'
'\nmsg: '
'\nmsg: The Secretary'
'\nmsg: School of Postgraduate Studies'
'\nmsg: Sample University'
'\nmsg: '
'\nSending email from no-reply@waeup.org to xx@yy.zz:'
'\nMessage:'
'\nmsg: MIME-Version: 1.0'
'\nmsg: Content-Type: text/plain; charset="us-ascii"'
'\nmsg: Content-Transfer-Encoding: 7bit'
'\nmsg: From: Administrator '
'\nmsg: To: John Anthony Tester '
'\nmsg: Reply-To: Administrator '
'\nmsg: Subject: Your application form was successfully submitted'
'\nmsg: '
'\nmsg: Dear John Anthony Tester,'
'\nmsg: '
'\nmsg: Your application app%s_<6-DIGITS> has been successfully submitted to Sample University.'
'\nmsg: '
'\nmsg: Regards'
'\nmsg: '
% (session_1, session_1, session_2, mandate_id_0,
session_1, session_1, session_2, mandate_id_1, session_1),
self.get_fake_smtp_output()
)
self.assertTrue(
'Application submitted' in self.browser.contents)
self.assertTrue(
'Form has been successfully submitted and 2 '
'invitation emails were sent.' in self.browser.contents)
logfile = os.path.join(
self.app['datacenter'].storage, 'logs', 'applicants.log')
logcontent = open(logfile).read()
self.assertTrue(
'%s - applicants.browser.ApplicantEditFormPage - %s - '
'email sent: otis@stones.de' %
(self.applicant.applicant_id, self.applicant.applicant_id)
in logcontent)
self.assertTrue(referee1.email_sent)
self.assertTrue(referee2.email_sent)
# If the form is being resubmitted, no more emails will be sent
IWorkflowState(self.applicant).setState('paid')
self.applicant.locked = False
self.browser.open(self.edit_path)
self.browser.getControl(name="confirm_passport").value = True
self.browser.getControl("Finally Submit").click()
self.assertTrue(
'Form has been successfully submitted and 0 '
'invitation emails were sent.' in self.browser.contents)
return
def test_remind_referees(self):
self.applicant.lastname = u'Mitchell'
IWorkflowState(self.applicant).setState('submitted')
# Add two referees
referee1 = RefereeEntry()
referee2 = RefereeEntry()
referee1.name = u'Linda Tree'
referee1.email = 'linda@forest.de'
referee2.name = u'Otis Stone'
referee2.email = 'otis@stones.de'
referee1.email_sent = True
referee2.email_sent = True
self.applicant.referees = [referee1, referee2]
# Managers can remind referees
self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
self.browser.open(self.view_path)
self.browser.getLink("Remind referees").click()
self.assertTrue('2 referee(s) have been reminded by email.'
in self.browser.contents)
logfile = os.path.join(
self.app['datacenter'].storage, 'logs', 'applicants.log')
logcontent = open(logfile).read()
self.assertTrue(
'zope.mgr - applicants.browser.RefereesRemindPage - %s - '
'email sent: otis@stones.de' % self.applicant.applicant_id
in logcontent)
if self.app['mandates'].values()[0].params['name'] == 'Linda Tree':
mandate_id_0 = self.app['mandates'].keys()[0]
mandate_id_1 = self.app['mandates'].keys()[1]
else:
mandate_id_0 = self.app['mandates'].keys()[1]
mandate_id_1 = self.app['mandates'].keys()[0]
self.assertMatches(
'Sending email from no-reply@waeup.org to linda@forest.de:'
'\nMessage:'
'\nmsg: MIME-Version: 1.0\nmsg: Content-Type: text/plain; charset="us-ascii"'
'\nmsg: Content-Transfer-Encoding: 7bit'
'\nmsg: From: Administrator '
'\nmsg: To: Linda Tree '
'\nmsg: Reply-To: Administrator '
'\nmsg: Subject: Request for referee report from Sample University'
'\nmsg: '
'\nmsg: Dear Linda Tree,'
'\nmsg: '
'\nmsg: The candidate with Id app%s_372052 and name Joan Mitchell applied to'
'\nmsg: the Sample University to study Unnamed Certificate for the %s/%s session.'
'\nmsg: The candidate has listed you as referee. You are, therefore, required to,'
'\nmsg: kindly, provide your referral remarks on or before .<6-DIGITS>+00:00. Please use the'
'\nmsg: following form:'
'\nmsg: '
'\nmsg: Report link: http://localhost/app/mandate?mandate_id=%s'
'\nmsg: '
'\nmsg: Thank You'
'\nmsg: '
'\nmsg: The Secretary'
'\nmsg: School of Postgraduate Studies'
'\nmsg: Sample University'
'\nmsg: '
'\nSending email from no-reply@waeup.org to otis@stones.de:'
'\nMessage:'
'\nmsg: MIME-Version: 1.0'
'\nmsg: Content-Type: text/plain; charset="us-ascii"'
'\nmsg: Content-Transfer-Encoding: 7bit'
'\nmsg: From: Administrator '
'\nmsg: To: Otis Stone '
'\nmsg: Reply-To: Administrator '
'\nmsg: Subject: Request for referee report from Sample University'
'\nmsg: '
'\nmsg: Dear Otis Stone,'
'\nmsg: '
'\nmsg: The candidate with Id app%s_<6-DIGITS> and name Joan Mitchell applied to'
'\nmsg: the Sample University to study Unnamed Certificate for the %s/%s session.'
'\nmsg: The candidate has listed you as referee. You are, therefore, required to,'
'\nmsg: kindly, provide your referral remarks on or before .<6-DIGITS>+00:00. Please use the'
'\nmsg: following form:'
'\nmsg: '
'\nmsg: Report link: http://localhost/app/mandate?mandate_id=%s'
'\nmsg: '
'\nmsg: Thank You'
'\nmsg: '
'\nmsg: The Secretary'
'\nmsg: School of Postgraduate Studies'
'\nmsg: Sample University'
'\nmsg: '
% (session_1, session_1, session_2, mandate_id_0,
session_1, session_1, session_2, mandate_id_1,),
self.get_fake_smtp_output()
)
# If a report exists, only one email is being sent to Otis Stone.
report = createObject(u'waeup.ApplicantRefereeReport')
report.r_id = 'any_id'
report.name = u'Liiiinda Tree'
report.email = 'linda@forest.de'
self.applicant[report.r_id] = report
self.browser.open(self.view_path)
self.browser.getLink("Remind referees").click()
self.assertTrue('1 referee(s) have been reminded by email.'
in self.browser.contents)
return