Ejemplo n.º 1
0
    def test_view_post_a_comment(self, fake_messages):
        """Post a comment on an automated poll."""
        poll_start = now() - timedelta(days=5)
        poll_user = UserFactory.create(groups=['Council'])
        poll_group = Group.objects.get(name='Council')
        bug = BugFactory.create()
        swag_poll = PollFactory.create(name='swag poll', start=poll_start,
                                       end=poll_start + timedelta(days=15),
                                       created_by=poll_user,
                                       valid_groups=poll_group,
                                       bug=bug,
                                       automated_poll=True,
                                       description='Swag poll description.',
                                       slug='swag-poll')
        vote_url = reverse('voting_view_voting',
                           kwargs={'slug': 'swag-poll'})
        factory = RequestFactory()
        request = factory.post(vote_url, {'comment': 'This is a comment'},
                               follow=True)
        request.user = poll_user

        view_voting(request, slug=swag_poll.slug)
        poll_comment = PollComment.objects.get(poll=swag_poll)
        eq_(poll_comment.user, poll_user)
        eq_(poll_comment.comment, 'This is a comment')
        fake_messages.success.assert_called_once_with(
            mock.ANY, 'Comment saved successfully.')
Ejemplo n.º 2
0
    def test_view_post_a_comment(self, fake_messages):
        """Post a comment on poll."""
        poll_start = datetime2pdt() - timedelta(days=5)
        poll_user = UserFactory.create(groups=['Council'])
        poll_group = Group.objects.get(name='Council')
        swag_poll = PollFactory.create(name='swag poll',
                                       start=poll_start,
                                       end=poll_start + timedelta(days=15),
                                       created_by=poll_user,
                                       valid_groups=poll_group,
                                       automated_poll=True,
                                       description='Swag poll description.',
                                       slug='swag-poll')
        vote_url = reverse('voting_view_voting', kwargs={'slug': 'swag-poll'})
        factory = RequestFactory()
        request = factory.post(vote_url, {'comment': 'This is a comment'},
                               follow=True)
        request.user = poll_user

        response = view_voting(request, slug=swag_poll.slug)
        self.assertTemplateUsed(response, 'list_votings.html')
        poll_comment = PollComment.objects.get(poll=swag_poll)
        eq_(poll_comment.user, poll_user)
        eq_(poll_comment.comment, 'This is a comment')
        fake_messages.success.assert_called_once_with(
            mock.ANY, 'Your vote has been successfully registered.')
Ejemplo n.º 3
0
    def test_view_post_a_comment(self, fake_messages):
        """Post a comment on poll."""
        poll_start = datetime2pdt() - timedelta(days=5)
        poll_user = UserFactory.create(groups=["Council"])
        poll_group = Group.objects.get(name="Council")
        swag_poll = PollFactory.create(
            name="swag poll",
            start=poll_start,
            end=poll_start + timedelta(days=15),
            created_by=poll_user,
            valid_groups=poll_group,
            automated_poll=True,
            description="Swag poll description.",
            slug="swag-poll",
        )
        vote_url = reverse("voting_view_voting", kwargs={"slug": "swag-poll"})
        factory = RequestFactory()
        request = factory.post(vote_url, {"comment": "This is a comment"}, follow=True)
        request.user = poll_user

        response = view_voting(request, slug=swag_poll.slug)
        self.assertTemplateUsed(response, "list_votings.html")
        poll_comment = PollComment.objects.get(poll=swag_poll)
        eq_(poll_comment.user, poll_user)
        eq_(poll_comment.comment, "This is a comment")
        fake_messages.success.assert_called_once_with(mock.ANY, "Your vote has been successfully registered.")