예제 #1
0
    def test_fetching_answer_users(self, *args, **kwargs):

        group = GroupFactory.create(remote_id=GROUP_ID)
        post = PostFactory.create(remote_id=POST_ID, wall_owner=group)
        poll = PollFactory.create(remote_id=POLL_ID, owner=group, post=post)
        answer = AnswerFactory.create(pk=266067661, poll=poll)

        answer.fetch_voters()

        self.assertEqual(answer.voters.count(), answer.votes_count)
        self.assertTrue(answer.voters.count() > 110)
        self.assertTrue(answer.rate > 0)
예제 #2
0
    def test_fetching_answer_users(self, *args, **kwargs):

        group = GroupFactory.create(remote_id=GROUP_ID)
        post = PostFactory.create(remote_id=POST_ID, wall_owner=group)
        poll = PollFactory.create(remote_id=POLL_ID, owner=group, post=post)
        answer = AnswerFactory.create(pk=266067661, poll=poll)

        answer.fetch_voters()

        self.assertEqual(answer.voters.count(), answer.votes_count)
        self.assertTrue(answer.voters.count() > 110)
        self.assertTrue(answer.rate > 0)
예제 #3
0
    def test_fetching_answer_users_by_api(self, *args, **kwargs):
        def calc_percentage(poll, answer_votes):
            pp = Poll.remote.fetch(poll.pk, poll.post)
            if pp and pp.votes_count:
                return answer_votes * 100. / pp.votes_count
            return 0

        group = GroupFactory.create(remote_id=GROUP_ID)
        post = PostFactory.create(remote_id=POST_ID, wall_owner=group)
        poll = PollFactory.create(remote_id=POLL_ID, owner=group, post=post)
        answer = AnswerFactory.create(pk=266067661, poll=poll)

        answer.fetch_voters_by_api()

        self.assertEqual(answer.voters.count(), answer.votes_count)
        self.assertTrue(answer.voters.count() > 110)
        self.assertTrue(answer.rate > 0)
        percentage = calc_percentage(poll, answer.votes_count)
        self.assertEqual(answer.rate, percentage)