Example #1
0
    def test_just_3_votes_allowed(self):
        ideas = [Idea.Factory() for i in xrange(4)]
        votes = [Vote.Factory(user=self.user) for i in xrange(3)]

        data = {
            'user': {
                'id': self.user.id
            },
            'vote_type': 'idea',
            'type_id': '/api/v1/ideas/%s/' % self.idea.id
        }

        response = self.client.post('/api/v1/votes/',
                                    content_type='application/json',
                                    data=json.dumps(data),
                                    **self.auth_header)
        logging.info(response)
        print[v for v in Vote.objects.all()]
        self.assertEqual(response.status_code, 400)
        response.json = json.loads(response.content)
        self.assertEqual(response.json['votes']['count'],
                         "Oh boy, just 3 votes, don't be greedy ;)")