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')
评论列表
文章目录