def setUp(self): self.user = User.objects.create_user(username='******', password='******') UserProfileFactory(user=self.user) VotingFactory.create_batch(6) # creates 5 different users as well. for v in Voting.objects.all(): UserVoteFactory( document=v.document, voting_id=v.voting_id, user=self.user )
def test_openprofile_has_context(self): VotingFactory.create_batch(6) # creates 5 different users as well. for v in Voting.objects.all(): UserVoteFactory( document=v.document, voting_id=v.voting_id, user=self.user ) response = self.client.get('/anvandare/{}/'.format(self.user.username)) votes = UserVote.objects.filter(user__username=self.user.username)[:5] similarity = UserSimilarity.objects.filter(user__username=self.user.username)[:5] self.assertEqual(list(response.context['votes']), list(votes)) self.assertEqual(list(response.context['similarity']), list(similarity)) self.assertEqual(response.context['userprofile'].nr_votes, 6)