Exemple #1
0
 def test_year_only(self):
     # Coefficient = 3: year = 3, successful semesters = 0, mo = 0
     self.test_user.graduation -= 2
     self.test_user.save()
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 3)
Exemple #2
0
 def test_count_not_going_participant(self):
     # Coefficient = 2: year = 1, successful semesters = 1, mo = 0
     EventParticipant.objects.create(event=self.camps[4],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=False)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 2)
Exemple #3
0
 def test_ignore_not_going_reserve(self):
     # Coefficient = 1: year = 1, successful semesters = 0, mo = 0
     EventParticipant.objects.create(event=self.camps[4],
                                     user=self.test_user,
                                     type=EventParticipant.RESERVE,
                                     going=False)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 1)
Exemple #4
0
 def test_ignore_mo_in_same_semester(self):
     # Coefficient = 3: year = 1, successful semesters = 0, mo = 2
     for mo_finals in self.mo_finals:
         EventParticipant.objects.create(event=mo_finals,
                                         user=self.test_user,
                                         type=EventParticipant.PARTICIPANT,
                                         going=True)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 3)
Exemple #5
0
 def test_many_camps(self):
     # Coefficient = 5: year = 1, successful semesters = 5, mo = 0
     for i in range(5):
         EventParticipant.objects.create(event=self.camps[i],
                                         user=self.test_user,
                                         type=EventParticipant.PARTICIPANT,
                                         going=True)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 5)
Exemple #6
0
 def test_camps_only(self):
     # Coefficient = 3: year = 1, successful semesters = 2, mo = 0
     EventParticipant.objects.create(event=self.camps[5],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     EventParticipant.objects.create(event=self.camps[4],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 3)
Exemple #7
0
 def test_invited_to_both_camps(self):
     # Coefficient = 2: year = 1, successful semesters = 1, mo = 0
     beta_camp = Event.objects.create(name='KMS camp beta',
                                      type=self.type_camp,
                                      semester=self.semesters[4],
                                      place=self.place,
                                      start_time=self.time,
                                      end_time=self.time)
     EventParticipant.objects.create(event=self.camps[4],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=False)
     EventParticipant.objects.create(event=beta_camp,
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 2)
Exemple #8
0
 def test_camps_mo(self):
     # Coefficient = 7: year = 4, successful semesters = 1, mo = 2
     self.test_user.graduation -= 3
     self.test_user.save()
     EventParticipant.objects.create(event=self.camps[5],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     EventParticipant.objects.create(event=self.mo_finals[1],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     EventParticipant.objects.create(event=self.mo_finals[0],
                                     user=self.test_user,
                                     type=EventParticipant.PARTICIPANT,
                                     going=True)
     generator = KMSResultsGenerator(self.tag)
     self.assertEqual(
         generator.get_user_coefficient(self.test_user, self.round), 7)
Exemple #9
0
 def test_create_user_with_coefficient(self):
     for i in range(-4, 12):
         user = self._create_user_with_coefficient(i, "testuser%d" % i)
         generator = KMSResultsGenerator(KMSRules.RESULTS_TAGS[KMS_BETA])
         self.assertEqual(generator.get_user_coefficient(user, self.round),
                          i)