test_views.py 文件源码

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

项目:pyconjp-website 作者: pyconjp 项目源码 文件源码
def test_messaging_as_attendee(self):
        self.presentation.proposal.registrants.add(self.user)
        self.login()
        rsp = self.client.get(self.tutorial_url)
        self.assertIn('id="messages"', rsp.content)

       # We can display the page prompting for a message to send them
        url = reverse(
            'tutorial_message', kwargs={'pk': self.presentation.proposal.pk})
        rsp = self.client.get(url)
        self.assertEqual(200, rsp.status_code)

        # "Send" a message to those two applications
        test_message = 'One if by land and two if by sea'
        data = {'message': test_message, }
        rsp = self.client.post(url, data=data)
        self.assertEqual(302, rsp.status_code)
        msg = PyConTutorialMessage.objects.get(
            user=self.user,
            tutorial=self.presentation.proposal)
        self.assertEqual(test_message, msg.message)

        # For each message, it's visible, so it should have been emailed to
        # both the other attendees and speakers. Total: 1 message for this case
        self.assertEqual(1, len(mail.outbox))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号