Beispiel #1
0
    def test_check_frequency_previous(self):
        self.previous_matches_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        mike = Profile.objects.get(first_name='michael')
        t_av = Availability.objects.get(profile=t,
                                        time_available_utc=self.future)
        a_av = Availability.objects.get(profile=a,
                                        time_available_utc=self.future)
        mike_av = Availability.objects.get(profile=mike,
                                           time_available_utc=self.future)

        self.assertEqual(Command.check_frequency(Command(), t_av, t), True)
        self.assertEqual(Command.check_frequency(Command(), a_av, a), True)

        # case where users just were matched
        mike_av.matched_name = 'andrew test'
        mike_av.matched_email = '*****@*****.**'
        mike_av.save()
        a_av.matched_name = 'mike test'
        a_av.matched_email = '*****@*****.**'
        a_av.save()

        self.assertEqual(Command.check_frequency(Command(), a_av, a), False)
        self.assertEqual(Command.check_frequency(Command(), mike_av, mike),
                         False)
        self.assertEqual(Command.check_frequency(Command(), t_av, t), True)
Beispiel #2
0
    def test_check_frequency_future(self):
        self.future_matches_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        pj = Profile.objects.get(first_name='philip')
        k = Profile.objects.get(first_name='karima')
        tim = Profile.objects.get(first_name='tim')
        mike = Profile.objects.get(first_name='michael')
        t_av = Availability.objects.get(profile=t,
                                        time_available_utc=self.future2)
        a_av = Availability.objects.get(profile=a,
                                        time_available_utc=self.future2)
        pj_av = Availability.objects.get(profile=pj,
                                         time_available_utc=self.future2)
        k_av = Availability.objects.get(profile=k,
                                        time_available_utc=self.future2)
        tim_av = Availability.objects.get(profile=tim,
                                          time_available_utc=self.future2)
        mike_av = Availability.objects.get(profile=mike,
                                           time_available_utc=self.future2)

        self.assertEqual(Command.check_frequency(Command(), t_av, t), True)
        self.assertEqual(Command.check_frequency(Command(), a_av, a), False)
        self.assertEqual(Command.check_frequency(Command(), pj_av, pj), False)
        self.assertEqual(Command.check_frequency(Command(), k_av, k), True)
        self.assertEqual(Command.check_frequency(Command(), tim_av, tim),
                         False)
        self.assertEqual(Command.check_frequency(Command(), mike_av, mike),
                         False)
    def test_frequencies(self):
        self.fresh_setup()
        none_p = Profile.objects.get(first_name='none')
        one_p = Profile.objects.get(first_name='one')
        two_p = Profile.objects.get(first_name='two')
        three_p = Profile.objects.get(first_name='three')
        four_p = Profile.objects.get(first_name='four')

        none_p_av = Availability.objects.get(profile=none_p,
                                             time_available_utc=self.week1)
        one_p_av_1 = Availability.objects.get(profile=one_p,
                                              time_available_utc=self.week1)
        two_p_av_1 = Availability.objects.get(profile=two_p,
                                              time_available_utc=self.week1)
        three_p_av_1 = Availability.objects.get(profile=three_p,
                                                time_available_utc=self.week1)
        four_p_av_1 = Availability.objects.get(profile=four_p,
                                               time_available_utc=self.week1)
        one_p_av_2 = Availability.objects.get(profile=one_p,
                                              time_available_utc=self.week2)
        two_p_av_2 = Availability.objects.get(profile=two_p,
                                              time_available_utc=self.week2)
        three_p_av_2 = Availability.objects.get(profile=three_p,
                                                time_available_utc=self.week2)
        four_p_av_2 = Availability.objects.get(profile=four_p,
                                               time_available_utc=self.week2)
        one_p_av_3 = Availability.objects.get(profile=one_p,
                                              time_available_utc=self.week3)
        two_p_av_3 = Availability.objects.get(profile=two_p,
                                              time_available_utc=self.week3)
        three_p_av_3 = Availability.objects.get(profile=three_p,
                                                time_available_utc=self.week3)
        four_p_av_3 = Availability.objects.get(profile=four_p,
                                               time_available_utc=self.week3)
        one_p_av_4 = Availability.objects.get(profile=one_p,
                                              time_available_utc=self.week4)
        two_p_av_4 = Availability.objects.get(profile=two_p,
                                              time_available_utc=self.week4)
        three_p_av_4 = Availability.objects.get(profile=three_p,
                                                time_available_utc=self.week4)
        four_p_av_4 = Availability.objects.get(profile=four_p,
                                               time_available_utc=self.week4)

        self.assertEqual(Command.check_frequency(Command(), none_p_av, none_p),
                         True)  # because we filter out this elsewhere
        self.assertEqual(Command.check_frequency(Command(), one_p_av_1, one_p),
                         True)

        # case where users just were matched
        one_p_av_1.matched_name = 'two test'
        one_p_av_1.matched_email = '*****@*****.**'
        one_p_av_1.save()
        two_p_av_1.matched_name = 'one test'
        two_p_av_1.matched_email = '*****@*****.**'
        two_p_av_1.save()
        three_p_av_1.matched_name = 'four test'
        three_p_av_1.matched_email = '*****@*****.**'
        three_p_av_1.save()
        four_p_av_1.matched_name = 'three test'
        four_p_av_1.matched_email = '*****@*****.**'
        four_p_av_1.save()

        self.assertEqual(Command.check_frequency(Command(), one_p_av_1, one_p),
                         False)
        self.assertEqual(Command.check_frequency(Command(), two_p_av_1, two_p),
                         False)
        self.assertEqual(
            Command.check_frequency(Command(), three_p_av_1, three_p), False)
        self.assertEqual(
            Command.check_frequency(Command(), four_p_av_1, four_p), False)

        self.assertEqual(Command.check_frequency(Command(), one_p_av_2, one_p),
                         False)
        self.assertEqual(Command.check_frequency(Command(), two_p_av_2, two_p),
                         False)
        self.assertEqual(
            Command.check_frequency(Command(), three_p_av_2, three_p), False)
        self.assertEqual(
            Command.check_frequency(Command(), four_p_av_2, four_p), True)

        self.assertEqual(Command.check_frequency(Command(), one_p_av_3, one_p),
                         False)
        self.assertEqual(Command.check_frequency(Command(), two_p_av_3, two_p),
                         False)
        self.assertEqual(
            Command.check_frequency(Command(), three_p_av_3, three_p), True)
        self.assertEqual(
            Command.check_frequency(Command(), four_p_av_3, four_p), True)

        self.assertEqual(Command.check_frequency(Command(), one_p_av_4, one_p),
                         False)
        self.assertEqual(Command.check_frequency(Command(), two_p_av_4, two_p),
                         True)
        self.assertEqual(
            Command.check_frequency(Command(), three_p_av_4, three_p), True)
        self.assertEqual(
            Command.check_frequency(Command(), four_p_av_4, four_p), True)
 def test_frequency(self):
     self.fresh_setup()
     t = Profile.objects.get(first_name='tiffany')
     t_av = GroupAvailability.objects.get(profile=t,
                                          time_available_utc=self.future)
     self.assertEqual(Command.check_frequency(Command(), t_av, t), True)