test_tasks.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:teamreporter 作者: agilentia 项目源码 文件源码
def test_issue_survey(self):
        """
        Test survey issuing
        TODO: test multiple users

        Returns the number of users a survey was sent to.  TODO: issue_survey can probably return something with more info in the future
        """

        with mock.patch.object(Report, 'can_issue_daily', return_value=True):
            result = issue_surveys.apply().get()
        self.assertEqual(result, 1, 'task should generate at least one survey')
        self.assertEquals(len(mail.outbox), 1, 'there should be nice email sent to user')

        message = mail.outbox[0]
        html_body = message.alternatives[0][0]
        self.assertIn('Boomerang call from team', message.subject, 'title contains positive message')
        self.assertIn(str(Survey.objects.get().pk), message.body, 'body  contains link with survey pk')
        self.assertIn(str(Survey.objects.get().pk), html_body, 'also html body')

        for question in self.report.question_set.active().values_list('text', flat=True):
            self.assertIn(question, html_body, 'survey contains questions')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号