Changeset 16213 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 25 Aug 2020, 15:18:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r16194 r16213 28 28 import os 29 29 import grok 30 import logging 30 31 from zc.async.testing import wait_for_result 31 32 from zope.event import notify … … 452 453 # Tests for Student class views and pages 453 454 455 def setUp(self): 456 super(OfficerUITests, self).setUp() 457 self.setup_logging() 458 return 459 460 def tearDown(self): 461 super(OfficerUITests, self).tearDown() 462 self.teardown_logging() 463 return 464 465 def setup_logging(self): 466 # setup a log-handler that catches all fake mailer output 467 self.stream = StringIO() 468 handler = logging.StreamHandler(self.stream) 469 logger = logging.getLogger('test.smtp') 470 logger.addHandler(handler) 471 logger.setLevel(logging.INFO) 472 return 473 474 def get_fake_smtp_output(self): 475 # get output generated by fake mailer 476 self.stream.flush() 477 self.stream.seek(0) 478 return self.stream.read() 479 480 def teardown_logging(self): 481 # remove the log handler for fake mailer output 482 logger = logging.getLogger('test.smtp') 483 handlers = [x for x in logger.handlers] 484 for handler in handlers: 485 logger.removeHandler(handler) 486 return 487 454 488 def test_student_properties(self): 455 489 self.student['studycourse'].current_level = 100 … … 607 641 self.browser.getControl("Send message now").click() 608 642 self.assertTrue('Your message has been sent' in self.browser.contents) 643 self.assertMatches( 644 'Sending email from no-reply@waeup.org to xx@yy.zz:' 645 '\nMessage:' 646 '\nmsg: MIME-Version: 1.0' 647 '\nmsg: Content-Type: text/plain; charset="us-ascii"' 648 '\nmsg: Content-Transfer-Encoding: 7bit' 649 '\nmsg: From: Manager <no-reply@waeup.org>' 650 '\nmsg: To: Anna Tester <xx@yy.zz>' 651 '\nmsg: Reply-To: Manager <contact@waeup.org>' 652 '\nmsg: Subject: Important subject' 653 '\nmsg:' 654 '\nmsg: Hello!' 655 '\nmsg:' 656 '\nmsg: ---' 657 '\nmsg: Manager (id: zope.mgr)' 658 '\nmsg: Sample University' 659 '\nmsg:', 660 self.get_fake_smtp_output() 661 ) 609 662 return 610 663
Note: See TracChangeset for help on using the changeset viewer.