예제 #1
0
    def test_questionAnswered_incorrect_data(self):
        question = self._createQuestion()

        event = ObjectModifiedEvent(question)
        reported_errors = questionAnswered(question, event)

        self.assertTrue(len(reported_errors) > 0, 'No errors were reported.')
        expected_errors = \
            ['The owner () has no email address!', 'Add a portal email address.']
        for error in expected_errors:
            self.assertTrue(error in reported_errors,
                            'The error %s was not reported.' % error)
예제 #2
0
    def test_questionAnswered_incorrect_data(self):
        question = self._createQuestion()

        event = ObjectModifiedEvent(question)
        reported_errors = questionAnswered(question, event)

        self.assertTrue(len(reported_errors) > 0, 'No errors were reported.')
        expected_errors = \
            ['The owner () has no email address!', 'Add a portal email address.']
        for error in expected_errors:
            self.assertTrue(
                error in reported_errors,
                'The error %s was not reported.' %error
        )
예제 #3
0
    def test_questionAnswered(self):
        question = self._createQuestion()
        pmt = self.portal.portal_membership
        pmt.getMemberById('test_user_1_').setMemberProperties(
            {'email': '*****@*****.**'})
        self.portal.email_from_address = '*****@*****.**'
        self.portal.REQUEST['ACTUAL_URL'] = 'example.com'
        event = ObjectModifiedEvent(question)
        errors = questionAnswered(question, event)

        mailhost = self.portal.MailHost
        self.assertTrue(errors is None, 'Errors were reported.')
        self.assertTrue(mailhost.messages, 'No message in mailhost.')

        file = open(os.path.join(dirname, 'data', 'message.txt'), 'r')
        reference_message = file.read()
        file.close()
        returned_message = mailhost.messages[0]
        self.assertEqual(
            returned_message, reference_message,
            'Returned message and reference message '
            'are not identical: \n\n%s' %
            self.diff(returned_message, reference_message))
예제 #4
0
    def test_questionAnswered(self):
        question = self._createQuestion()
        pmt = self.portal.portal_membership
        pmt.getMemberById('test_user_1_').setMemberProperties(
            {'email': '*****@*****.**'})
        self.portal.email_from_address = '*****@*****.**'
        self.portal.REQUEST['ACTUAL_URL'] = 'example.com'
        event = ObjectModifiedEvent(question)
        errors = questionAnswered(question, event)
        
        mailhost = self.portal.MailHost
        self.assertTrue(errors is None, 'Errors were reported.')
        self.assertTrue(mailhost.messages, 'No message in mailhost.')

        file = open(os.path.join(
            dirname, 'data', 'message.txt'), 'r')
        reference_message = file.read()
        file.close()
        returned_message = mailhost.messages[0]
        self.assertEqual(returned_message, reference_message,
            'Returned message and reference message '
            'are not identical: \n\n%s' % self.diff(
                returned_message, reference_message))