Пример #1
0
 def test_reciprocal_pairing(self):
     """ Two participants who request each other are reciprocally paired. """
     bonnie = ParticipantFactory.create()
     clyde = ParticipantFactory.create()
     LotteryInfoFactory.create(participant=bonnie, paired_with=clyde)
     LotteryInfoFactory.create(participant=clyde, paired_with=bonnie)
     self.expect_pairing({bonnie: True, clyde: True})
Пример #2
0
    def test_user_with_participant(self):
        """ When the user has created a participant, it's injected into the request."""
        self.request.user = self.user
        participant = ParticipantFactory.create(user_id=self.user.pk)

        self.pm(self.request)
        self.assertEqual(self.request.participant, participant)
Пример #3
0
    def test_nulls_do_not_mean_equal(self):
        """ Participants that want no pairing aren't accidentallly paired.

        This checks an implementation detail, ensuring that null==null doesn't
        amount to the SQL query mistakenly regarding participants as paired.
        """
        no_lotteryinfo_1 = ParticipantFactory.create(lotteryinfo=None)
        no_lotteryinfo_2 = ParticipantFactory.create(lotteryinfo=None)
        alone_1 = LotteryInfoFactory.create(paired_with=None)
        alone_2 = LotteryInfoFactory.create(paired_with=None)

        self.expect_pairing(
            {
                no_lotteryinfo_1: False,
                no_lotteryinfo_2: False,
                alone_1.participant: False,
                alone_2.participant: False,
            }
        )
Пример #4
0
    def test_deterministic_ranking(self):
        """ Ranking of a particular single trip is based on its pk. """
        trip = TripFactory.create(activity='hiking', pk=822)

        # TODO: This test relies pretty heavily on the database and is very slow
        participants = []
        for i in range(5):
            par = ParticipantFactory.create(name=f"Participant Num{i}")
            SignUpFactory.create(participant=par, trip=trip)
            participants.append(par)

        self.assertEqual(
            list(rank.SingleTripParticipantRanker(trip)),
            list(rank.SingleTripParticipantRanker(trip)),
        )
Пример #5
0
 def test_no_lotteryinfo(self):
     """ No lottery info still counts as not being paired. """
     no_lotteryinfo = ParticipantFactory.create(lotteryinfo=None)
     self.expect_pairing({no_lotteryinfo: False})
Пример #6
0
 def setUp(self):
     self.participant = ParticipantFactory.create()
     self.ranker = rank.WinterSchoolParticipantRanker()
Пример #7
0
 def setUp(self):
     self.participant = ParticipantFactory.create()
     self.ranker = rank.WinterSchoolParticipantRanker()
Пример #8
0
 def test_cannot_make_chair_for_open_activity(self):
     """ You can't make somebody the chair of an open activity. """
     valid_participant = ParticipantFactory.create()
     open_activity = models.BaseRating.OFFICIAL_EVENT
     with self.assertRaises(ValueError):
         perm_utils.make_chair(valid_participant.user, open_activity)
Пример #9
0
 def test_no_lotteryinfo(self):
     """No lottery info still counts as not being paired."""
     no_lotteryinfo = ParticipantFactory.create(lotteryinfo=None)
     self.expect_pairing({no_lotteryinfo: False})