Example #1
0
    def test_raffle_secret_friend_with_pair_participants(self):
        mixer.cycle(50).blend('core.Participant')
        participants = Participant.objects.all()

        for _ in range(participants.count()):
            participant = Participant.objects.filter(raffled=False).first()
            raffle_secret_friend(participant)

        all_chosen = all(participants.values_list('chosen', flat=True))
        all_raffled = all(participants.values_list('raffled', flat=True))
        self.assertTrue(all_chosen)
        self.assertTrue(all_raffled)
Example #2
0
    def post(self, request, *args, **kwargs):
        raffle_form = RaffleForm(request.POST)
        friend = None
        participant = None
        if raffle_form.is_valid():
            participant = raffle_form.cleaned_data.get('name')
            friend = raffle_secret_friend(participant)

        self.context['form'] = raffle_form
        self.context['friend'] = friend
        self.context['participant'] = participant
        return render(request, self.template_name, self.context)
Example #3
0
    def test_raffle_secret_friend_different_secret_friends_with_unpair_participants(
            self):
        mixer.cycle(51).blend('core.Participant')
        participants = Participant.objects.all()

        secret_friends = []
        for _ in range(participants.count()):
            participant = Participant.objects.filter(raffled=False).first()
            secret_friend = raffle_secret_friend(participant)
            secret_friends.append(secret_friend.pk)

        for participant in participants:
            self.assertEqual(secret_friends.count(participant.pk), 1)