def test_class_answer(self):

        email_answer = EmailAnswer()
        self.assertTrue(hasattr(email_answer, 'subject'))
        self.assertTrue(hasattr(email_answer, '_content_text'))
        self.assertTrue(hasattr(email_answer, 'content_html'))
        self.assertTrue(hasattr(email_answer, 'outbound_message_identifier'))
        self.assertTrue(hasattr(email_answer, 'email_from'))
        self.assertTrue(hasattr(email_answer, 'email_to'))
        self.assertTrue(hasattr(email_answer, 'when'))
        self.assertTrue(hasattr(email_answer, 'message_id'))
        email_answer.subject = 'prueba4'
        email_answer.content_text = 'prueba4lafieritaespeluda'
        email_answer.content_html = '<p>prueba4lafieritaespeluda</p>'
        email_answer.outbound_message_identifier = '8974aabsdsfierapulgosa'
        email_answer.email_from = '*****@*****.**'
        email_answer.email_to = 'Felipe <*****@*****.**>'
        email_answer.when = 'Wed Jun 26 21:05:33 2013'
        email_answer.message_id = '<CAA5PczfGfdhf29wgK=8t6j7hm8HYsBy8Qg87iTU2pF42Ez3VcQ@mail.gmail.com>'

        self.assertTrue(email_answer)
        self.assertEquals(email_answer.subject, 'prueba4')
        self.assertEquals(email_answer.content_text, 'prueba4lafieritaespeluda')
        self.assertEquals(email_answer.outbound_message_identifier, '8974aabsdsfierapulgosa')
        self.assertEquals(email_answer.email_from, '*****@*****.**')
        self.assertEquals(email_answer.email_to, 'Felipe <*****@*****.**>')
        self.assertEquals(email_answer.when, 'Wed Jun 26 21:05:33 2013')
        self.assertEquals(email_answer.message_id, '<CAA5PczfGfdhf29wgK=8t6j7hm8HYsBy8Qg87iTU2pF42Ez3VcQ@mail.gmail.com>')
        self.assertEquals(email_answer.content_html, '<p>prueba4lafieritaespeluda</p>')
        self.assertFalse(email_answer.is_bounced)
Example #2
0
 def test_send_back_also_returns_an_answer(self):
     '''the method EmailAnswer.send_back returns an answer'''
     email_answer = EmailAnswer()
     email_answer.subject = 'prueba4'
     email_answer.content_text = 'prueba4lafieritaespeluda'
     email_answer.outbound_message_identifier = '8974aabsdsfierapulgosa'
     email_answer.email_from = '*****@*****.**'
     email_answer.when = 'Wed Jun 26 21:05:33 2013'
     # so when I execute email_answer.save, it will return
     # the first answer that we have in our fixtures
     # it doesn't really matter as long as it returns an answer
     answer = Answer.objects.first()
     with patch('requests.Session.post') as post:
         post.return_value = PostMock()
         with patch('mailit.bin.handleemail.EmailAnswer.save') as save_answer:
             save_answer.return_value = answer
             result = email_answer.send_back()
             self.assertEquals(result, answer)
Example #3
0
    def test_logs_the_result_of_send_back(self):
        email_answer = EmailAnswer()
        email_answer.subject = 'prueba4'
        email_answer.content_text = 'prueba4lafieritaespeluda'
        email_answer.outbound_message_identifier = '8974aabsdsfierapulgosa'
        email_answer.email_from = '*****@*****.**'
        email_answer.when = 'Wed Jun 26 21:05:33 2013'
        with patch('logging.info') as info:
            info.return_value = None
            with patch('requests.Session.post') as post:
                post.return_value = PostMock()

                with patch('logging.info') as info:
                    expected_log = "When sent to %(location)s the status code was 201" % {
                        'location': self.where_to_post_creation_of_the_answer
                        }
                    email_answer.send_back()
                    info.assert_called_with(expected_log)
Example #4
0
    def test_logs_the_result_of_send_back(self):
        email_answer = EmailAnswer()
        email_answer.subject = 'prueba4'
        email_answer.content_text = 'prueba4lafieritaespeluda'
        email_answer.outbound_message_identifier = '8974aabsdsfierapulgosa'
        email_answer.email_from = '*****@*****.**'
        email_answer.when = 'Wed Jun 26 21:05:33 2013'
        with patch('logging.info') as info:
            info.return_value = None
            with patch('requests.Session.post') as post:
                post.return_value = PostMock()

                with patch('logging.info') as info:
                    expected_log = "When sent to %(location)s the status code was 201" % {
                        'location': self.where_to_post_creation_of_the_answer
                    }
                    email_answer.send_back()
                    info.assert_called_with(expected_log)
Example #5
0
 def test_send_back_also_returns_an_answer(self):
     '''the method EmailAnswer.send_back returns an answer'''
     email_answer = EmailAnswer()
     email_answer.subject = 'prueba4'
     email_answer.content_text = 'prueba4lafieritaespeluda'
     email_answer.outbound_message_identifier = '8974aabsdsfierapulgosa'
     email_answer.email_from = '*****@*****.**'
     email_answer.when = 'Wed Jun 26 21:05:33 2013'
     # so when I execute email_answer.save, it will return
     # the first answer that we have in our fixtures
     # it doesn't really matter as long as it returns an answer
     answer = Answer.objects.first()
     with patch('requests.Session.post') as post:
         post.return_value = PostMock()
         with patch(
                 'mailit.bin.handleemail.EmailAnswer.save') as save_answer:
             save_answer.return_value = answer
             result = email_answer.send_back()
             self.assertEquals(result, answer)