Changeset 14014 for main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests
- Timestamp:
- 4 Jul 2016, 09:02:52 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13992 r14014 24 24 import tempfile 25 25 import grok 26 import logging 26 27 from datetime import datetime 27 28 from StringIO import StringIO … … 41 42 from waeup.kofa.payments.interfaces import IPayer 42 43 from waeup.kofa.configuration import SessionConfiguration 44 from waeup.kofa.refereeentries import RefereeEntry 43 45 from waeup.kofa.applicants.container import ApplicantsContainer 44 46 from waeup.kofa.applicants.applicant import Applicant … … 1526 1528 layer = FunctionalLayer 1527 1529 1530 def setUp(self): 1531 super(ApplicantRefereeReportTests, self).setUp() 1532 self.setup_logging() 1533 return 1534 1535 def tearDown(self): 1536 super(ApplicantRefereeReportTests, self).tearDown() 1537 self.teardown_logging() 1538 return 1539 1540 def setup_logging(self): 1541 # setup a log-handler that catches all fake mailer output 1542 self.stream = StringIO() 1543 handler = logging.StreamHandler(self.stream) 1544 logger = logging.getLogger('test.smtp') 1545 logger.addHandler(handler) 1546 logger.setLevel(logging.INFO) 1547 return 1548 1549 def get_fake_smtp_output(self): 1550 # get output generated by fake mailer 1551 self.stream.flush() 1552 self.stream.seek(0) 1553 return self.stream.read() 1554 1555 def teardown_logging(self): 1556 # remove the log handler for fake mailer output 1557 logger = logging.getLogger('test.smtp') 1558 handlers = [x for x in logger.handlers] 1559 for handler in handlers: 1560 logger.removeHandler(handler) 1561 return 1562 1528 1563 def test_refereereport_mandate(self): 1529 1564 mandate = RefereeReportMandate() … … 1604 1639 # Mandate is deleted 1605 1640 self.assertEqual(len(self.app['mandates'].keys()), 0) 1641 1642 def test_final_submit_with_referees(self): 1643 # Add two referees 1644 referee1 = RefereeEntry() 1645 referee2 = RefereeEntry() 1646 referee1.name = u'Linda Tree' 1647 referee1.email = 'linda@forest.de' 1648 referee2.name = u'Otis Stone' 1649 referee2.email = 'otis@stones.de' 1650 self.applicant.referees = [referee1, referee2] 1651 self.assertFalse(referee1.email_sent) 1652 self.assertFalse(referee2.email_sent) 1653 self.login() 1654 IWorkflowInfo(self.applicant).fireTransition('pay') 1655 self.browser.open(self.edit_path) 1656 self.fill_correct_values() # fill other fields with correct values 1657 image = open(SAMPLE_IMAGE, 'rb') 1658 ctrl = self.browser.getControl(name='form.passport') 1659 file_ctrl = ctrl.mech_control 1660 file_ctrl.add_file(image, filename='myphoto.jpg') 1661 self.browser.getControl("Save").click() 1662 self.browser.getControl(name="confirm_passport").value = True 1663 self.browser.getControl("Finally Submit").click() 1664 self.assertEqual( 1665 [u'Sending email from no-reply@waeup.org to linda@forest.de:', 1666 u'Message:', 1667 u'msg: MIME-Version: 1.0', 1668 u'msg: Content-Type: text/plain; charset="us-ascii"', 1669 u'msg: Content-Transfer-Encoding: 7bit', 1670 u'msg: From: Administrator <no-reply@waeup.org>', 1671 u'msg: To: Linda Tree <linda@forest.de>', 1672 u'msg: Reply-To: Administrator <contact@waeup.org>', 1673 u'msg: Subject: Request for referee report from Sample University', 1674 u'msg: ', 1675 ], self.get_fake_smtp_output().split('\n')[:10] 1676 ) 1677 self.assertTrue( 1678 'Application submitted' in self.browser.contents) 1679 logfile = os.path.join( 1680 self.app['datacenter'].storage, 'logs', 'applicants.log') 1681 logcontent = open(logfile).read() 1682 self.assertTrue( 1683 '%s - applicants.browser.ApplicantEditFormPage - %s - ' 1684 'email sent: otis@stones.de' % 1685 (self.applicant.applicant_id, self.applicant.applicant_id) 1686 in logcontent) 1687 self.assertTrue(referee1.email_sent) 1688 self.assertTrue(referee2.email_sent) 1689 return
Note: See TracChangeset for help on using the changeset viewer.