Changeset 16231 for main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests
- Timestamp:
- 10 Sep 2020, 07:22:19 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r16215 r16231 37 37 from zope.security.interfaces import Unauthorized 38 38 from zope.testbrowser.testing import Browser 39 from zope.interface import implementedBy 40 from zope.schema.fieldproperty import FieldProperty 39 41 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 40 42 from waeup.kofa.browser.tests.test_pdf import samples_dir … … 583 585 layer = FunctionalLayer 584 586 587 def setUp(self): 588 super(ApplicantUITests, self).setUp() 589 self.setup_logging() 590 return 591 592 def tearDown(self): 593 super(ApplicantUITests, self).tearDown() 594 self.teardown_logging() 595 return 596 597 def setup_logging(self): 598 # setup a log-handler that catches all fake mailer output 599 self.stream = StringIO() 600 handler = logging.StreamHandler(self.stream) 601 logger = logging.getLogger('test.smtp') 602 logger.addHandler(handler) 603 logger.setLevel(logging.INFO) 604 return 605 606 def get_fake_smtp_output(self): 607 # get output generated by fake mailer 608 self.stream.flush() 609 self.stream.seek(0) 610 return self.stream.read() 611 612 def teardown_logging(self): 613 # remove the log handler for fake mailer output 614 logger = logging.getLogger('test.smtp') 615 handlers = [x for x in logger.handlers] 616 for handler in handlers: 617 logger.removeHandler(handler) 618 return 619 585 620 def test_manage_and_view_applicant(self): 586 621 # Managers can manage applicants … … 623 658 # If applicant is in correct state the pdf slip can be opened. 624 659 IWorkflowState(self.applicant).setState('submitted') 625 self.browser.open(self. manage_path)660 self.browser.open(self.view_path) 626 661 self.browser.getLink("Download application slip").click() 627 662 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 924 959 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 925 960 self.browser.getControl("Save").click() # submit form 926 self.browser.open(self. manage_path)961 self.browser.open(self.view_path) 927 962 self.browser.getLink("Download application slip").click() 928 963 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 1331 1366 return 1332 1367 1368 def test_manage_contact_applicant(self): 1369 # Managers can contact student 1370 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1371 # Remove required FieldProperty attribute first ... 1372 delattr(Applicant, 'email') 1373 # ... and replace by None 1374 self.applicant.email = None 1375 # Now we have to add the FieldProperty attribute again. Otherwise 1376 # many other tests below will fail. 1377 iface = list(implementedBy(Applicant))[0] 1378 field_property = FieldProperty(iface['email']) 1379 setattr(Applicant, 'email', field_property) 1380 self.browser.open(self.view_path) 1381 self.browser.getLink("Send email").click() 1382 self.browser.getControl( 1383 name="form.subject").value = 'Important subject' 1384 self.browser.getControl(name="form.body").value = 'Hello!' 1385 self.browser.getControl("Send message now").click() 1386 self.assertTrue( 1387 'An smtp server error occurred' in self.browser.contents) 1388 self.applicant.email = 'xx@yy.zz' 1389 self.browser.getControl("Send message now").click() 1390 self.assertTrue('Your message has been sent' in self.browser.contents) 1391 self.assertMatches( 1392 'Sending email from no-reply@waeup.org to xx@yy.zz:' 1393 '\nMessage:' 1394 '\nmsg: MIME-Version: 1.0' 1395 '\nmsg: Content-Type: text/plain; charset="us-ascii"' 1396 '\nmsg: Content-Transfer-Encoding: 7bit' 1397 '\nmsg: From: Manager <no-reply@waeup.org>' 1398 '\nmsg: To: Joan None <xx@yy.zz>' 1399 '\nmsg: Reply-To: Manager <contact@waeup.org>' 1400 '\nmsg: Subject: Important subject' 1401 '\nmsg:' 1402 '\nmsg: Hello!' 1403 '\nmsg:' 1404 '\nmsg: ---' 1405 '\nmsg: Manager (id: zope.mgr)' 1406 '\nmsg: Sample University' 1407 '\nmsg:', 1408 self.get_fake_smtp_output() 1409 ) 1410 return 1411 1333 1412 1334 1413 class ApplicantRegisterTests(ApplicantsFullSetup): … … 1956 2035 # Managers can remind referees 1957 2036 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1958 self.browser.open(self. manage_path)2037 self.browser.open(self.view_path) 1959 2038 self.browser.getLink("Remind referees").click() 1960 2039 self.assertTrue('2 referee(s) have been reminded by email.' … … 2035 2114 report.email = 'linda@forest.de' 2036 2115 self.applicant[report.r_id] = report 2037 self.browser.open(self. manage_path)2116 self.browser.open(self.view_path) 2038 2117 self.browser.getLink("Remind referees").click() 2039 2118 self.assertTrue('1 referee(s) have been reminded by email.'
Note: See TracChangeset for help on using the changeset viewer.