Exemplo n.º 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)
Exemplo n.º 2
0
    def test_check_departments(self):
        self.fresh_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        pj = Profile.objects.get(first_name='philip')

        self.assertEqual(Command.check_departments(Command(), t, a), True)
        self.assertEqual(Command.check_departments(Command(), t, pj), False)
Exemplo n.º 3
0
    def test_check_previous_matches(self):
        self.fresh_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        pj = Profile.objects.get(first_name='philip')

        self.assertEqual(Command.check_previous_matches(Command(), a, t), True)
        self.assertEqual(Command.check_previous_matches(Command(), a, pj),
                         True)
Exemplo n.º 4
0
    def test_check_google_hangout(self):
        self.fresh_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')

        self.assertEqual(Command.check_google_hangout(Command(), t, a), False)
        self.assertEqual(Command.check_google_hangout(Command(), t, pj), True)
        self.assertEqual(Command.check_google_hangout(Command(), pj, k), True)
Exemplo n.º 5
0
    def test_check_locations(self):
        self.fresh_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')

        self.assertEqual(Command.check_locations(Command(), t, a), True)
        self.assertEqual(Command.check_locations(Command(), k, pj), False)
        self.assertEqual(Command.check_locations(Command(), k, tim), False)
        self.assertEqual(Command.check_locations(Command(), tim, t), False)
 def test_match_and_run(self):
     self.fresh_setup()
     cherise = Profile.objects.get(first_name='Cherise')
     rishi = Profile.objects.get(first_name='Rishi')
     hannah = Profile.objects.get(first_name='Hannah')
     anya = Profile.objects.get(first_name='Anya')
     group = {self.jul26: [cherise, rishi, hannah, anya]}
     self.assertEqual(Command.run_group_matches(Command()), group)
 def test_match_and_run_fresh_first_day(self):
     self.fresh_setup()
     t = Profile.objects.get(first_name='tiffany')
     a = Profile.objects.get(first_name='andrew')
     pj = Profile.objects.get(first_name='philip')
     mike = Profile.objects.get(first_name='michael')
     group = {self.future: [t, a, pj, mike]}
     self.assertEqual(Command.run_group_matches(Command()), group)
    def test_run_matches(self):
        '''
        Christine & Hilary - T
        Jameson & Anthony - T
        James & Joey - M
        Shimin & Tiffany - T
        Brooke & Chi - T
        Maddie & Alex F - M
        Austin & Nicole - M
        Rajiv & Lopa - W
        '''
        self.fresh_setup()
        christine = Profile.objects.get(first_name='christine')
        hilary = Profile.objects.get(first_name='hilary')
        jameson = Profile.objects.get(first_name='jameson')
        anthony = Profile.objects.get(first_name='anthony')
        james = Profile.objects.get(first_name='james')
        joey = Profile.objects.get(first_name='joey')
        shimin = Profile.objects.get(first_name='shimin')
        tiffany = Profile.objects.get(first_name='tiffany')
        brooke = Profile.objects.get(first_name='brooke')
        chi = Profile.objects.get(first_name='chi')
        maddie = Profile.objects.get(first_name='maddie')
        alex = Profile.objects.get(first_name='alex')
        austin = Profile.objects.get(first_name='austin')
        nicole = Profile.objects.get(first_name='nicole')
        rajiv = Profile.objects.get(first_name='rajiv')
        lopa = Profile.objects.get(first_name='lopa')

        christine_tue = Availability.objects.get(profile=christine,
                                                 time_available_utc=self.tue)
        jameson_tue = Availability.objects.get(profile=jameson,
                                               time_available_utc=self.tue)
        james_mon = Availability.objects.get(profile=james,
                                             time_available_utc=self.mon)
        shimin_tue = Availability.objects.get(profile=shimin,
                                              time_available_utc=self.tue)
        brooke_tue = Availability.objects.get(profile=brooke,
                                              time_available_utc=self.tue)
        maddie_mon = Availability.objects.get(profile=maddie,
                                              time_available_utc=self.mon)
        austin_mon = Availability.objects.get(profile=austin,
                                              time_available_utc=self.mon)
        rajiv_wed = Availability.objects.get(profile=rajiv,
                                             time_available_utc=self.wed)

        matches = [
            [christine_tue, christine, hilary],
            [jameson_tue, jameson, anthony],
            [james_mon, james, joey],
            [shimin_tue, shimin, tiffany],
            [brooke_tue, brooke, chi],
            [maddie_mon, maddie, alex],
            [austin_mon, austin, nicole],
            [rajiv_wed, rajiv, lopa],
        ]

        self.assertEqual(Command.run_one_on_one_matches(Command()), matches)
Exemplo n.º 9
0
    def test_setup(self):
        self.fresh_setup()
        avs = Availability.objects.all()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        tim = Profile.objects.get(first_name='tim')
        t_av_past = Availability.objects.get(profile=t,
                                             time_available_utc=self.past)
        a_av_past = Availability.objects.get(profile=a,
                                             time_available_utc=self.past)
        tim_av_past = Availability.objects.get(profile=tim,
                                               time_available_utc=self.past)
        a_av_future = Availability.objects.get(profile=a,
                                               time_available_utc=self.future)
        tim_av_future = Availability.objects.get(
            profile=tim, time_available_utc=self.future)

        self.assertIn(a_av_past, Command.setup(Command(), avs)[1478347200.0])
        self.assertIn(t_av_past, Command.setup(Command(), avs)[1478347200.0])
        self.assertIn(tim_av_past, Command.setup(Command(), avs)[1478347200.0])
        self.assertIn(a_av_future, Command.setup(Command(), avs)[1509537600.0])
        self.assertIn(tim_av_future,
                      Command.setup(Command(), avs)[1509537600.0])
        self.assertNotIn(a_av_past,
                         Command.setup(Command(), avs)[1509537600.0])
        self.assertNotIn(a_av_future,
                         Command.setup(Command(), avs)[1478347200.0])
    def test_check_fuzzy_previous_matches(self):
        self.fresh_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')

        group = [t]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), tim, group), True)
        group = [a, pj]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), tim, group), True)

        group = [t, a, pj, k]
        Command.match_group(Command(), self.past, group)
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), tim, group), True)
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), t, group), False)
        group = [t, pj, k]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), a, group), False)
        group = [t]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), a, group), True)
Exemplo n.º 11
0
    def test_check_previous_matches_with_future_matches(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')

        self.assertEqual(Command.check_previous_matches(Command(), a, t),
                         False)
        self.assertEqual(Command.check_previous_matches(Command(), a, pj),
                         False)
        self.assertEqual(Command.check_previous_matches(Command(), a, mike),
                         False)
        self.assertEqual(Command.check_previous_matches(Command(), k, mike),
                         True)
        self.assertEqual(Command.check_previous_matches(Command(), k, tim),
                         False)
    def test_check_not_currently_matched(self):
        self.fresh_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        pj = Profile.objects.get(first_name='philip')
        t_av = GroupAvailability.objects.get(profile=t,
                                             time_available_utc=self.future)
        a_av = GroupAvailability.objects.get(profile=a,
                                             time_available_utc=self.future)
        pj_av = GroupAvailability.objects.get(profile=pj,
                                              time_available_utc=self.future)

        # case where users don't have any matches in the beginning
        self.assertEqual(Command.check_not_currently_matched(Command(), a_av),
                         True)
        self.assertEqual(Command.check_not_currently_matched(Command(), t_av),
                         True)
        self.assertEqual(Command.check_not_currently_matched(Command(), pj_av),
                         True)
Exemplo n.º 13
0
 def test_send_email(self):
     self.init_profiles()
     cherise = Profile.objects.get(first_name='Cherise')
     rishi = Profile.objects.get(first_name='Rishi')
     time = Availability.objects.get(time_available=self.now)
     profiles = [cherise, rishi]
     match_type = 'one-on-one'
     print(
         "Email test sent, check your email and calendar to see if it worked!"
     )
     Command.send_google_calendar_invite(Command(), time, profiles,
                                         match_type)
    def test_check_fuzzy_double_previous_matches(self):
        self.fresh_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')

        matches = [t, a, pj, k]
        emails = [prof.email for prof in matches]
        for prof in matches:
            av = GroupAvailability.objects.get(time_available_utc=self.past,
                                               profile=prof)
            av.matched_group_users = json.dumps(emails)
            av.save()

        new_matches = [tim, a, pj, mike]
        Command.match_group(Command(), self.future2, new_matches)
        group = [t]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), tim, group), True)
        group = [a, pj]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), tim, group), False)
        group = [a, t]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), mike, group), True)
        group = [a, t, k]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), mike, group), True)
        group = [mike, t, a]
        self.assertEqual(
            Command.check_fuzzy_previous_matches(Command(), k, group), False)
Exemplo n.º 15
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)
Exemplo n.º 16
0
    def test_check_not_currently_matched(self):
        self.fresh_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        pj = Profile.objects.get(first_name='philip')
        t_av = Availability.objects.get(profile=t,
                                        time_available_utc=self.future)
        a_av = Availability.objects.get(profile=a,
                                        time_available_utc=self.future)
        pj_av = Availability.objects.get(profile=pj,
                                         time_available_utc=self.future)

        # case where users don't have any matches in the beginning
        self.assertEqual(Command.check_not_currently_matched(Command(), a_av),
                         True)
        self.assertEqual(Command.check_not_currently_matched(Command(), t_av),
                         True)
        self.assertEqual(Command.check_not_currently_matched(Command(), pj_av),
                         True)

        # case where users just were matched
        t_av.matched_name = 'andrew test'
        t_av.matched_email = '*****@*****.**'
        a_av.matched_name = 'tiffany test'
        a_av.matched_email = '*****@*****.**'

        self.assertEqual(Command.check_not_currently_matched(Command(), a_av),
                         False)
        self.assertEqual(Command.check_not_currently_matched(Command(), t_av),
                         False)
        self.assertEqual(Command.check_not_currently_matched(Command(), pj_av),
                         True)
 def test_group_match(self):
     self.fresh_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')
     matches = [t, a, pj, k]
     emails = [t.email, a.email, pj.email, k.email]
     Command.match_group(Command(), self.past, matches)
     for prof in matches:
         av = GroupAvailability.objects.get(time_available_utc=self.past,
                                            profile=prof)
         self.assertEqual(av.matched_group_users, json.dumps(emails))
 def test_create_availabilities(self):
     self.setup_recurring()
     t = Profile.objects.get(first_name='tiffany')
     av1 = Availability.objects.create(
         profile=t,
         time_available=datetime.datetime(2017,
                                          8,
                                          7,
                                          13,
                                          0,
                                          tzinfo=pytz.UTC),
         time_available_utc=datetime.datetime(2017,
                                              8,
                                              7,
                                              20,
                                              0,
                                              tzinfo=pytz.UTC),
     )
     av2 = Availability.objects.create(
         profile=t,
         time_available=datetime.datetime(2017,
                                          8,
                                          9,
                                          12,
                                          0,
                                          tzinfo=pytz.UTC),
         time_available_utc=datetime.datetime(2017,
                                              8,
                                              9,
                                              19,
                                              0,
                                              tzinfo=pytz.UTC),
     )
     av3 = Availability.objects.create(
         profile=t,
         time_available=datetime.datetime(2017,
                                          8,
                                          11,
                                          10,
                                          0,
                                          tzinfo=pytz.UTC),
         time_available_utc=datetime.datetime(2017,
                                              8,
                                              11,
                                              17,
                                              0,
                                              tzinfo=pytz.UTC),
     )
     today = datetime.datetime(2017, 8, 1)
     self.assertEqual([av1, av2, av3],
                      Command.create_availabilities(Command(), today))
    def test_check_fuzzy_departments(self):
        self.fresh_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')

        group = []
        self.assertEqual(Command.check_fuzzy_departments(Command(), t, group),
                         True)
        group.append(t)
        self.assertEqual(Command.check_fuzzy_departments(Command(), a, group),
                         True)
        group.append(a)
        self.assertEqual(Command.check_fuzzy_departments(Command(), pj, group),
                         True)
        group.append(pj)
        self.assertEqual(Command.check_fuzzy_departments(Command(), k, group),
                         False)
        self.assertEqual(
            Command.check_fuzzy_departments(Command(), mike, group), True)
    def test_add_new(self):
        '''
        Zara & James - T
        '''
        self.add_new()
        zara = Profile.objects.get(first_name='zara')
        james = Profile.objects.get(first_name='james')

        zara_tue = Availability.objects.get(profile=zara,
                                            time_available_utc=self.tue)

        matches = [[zara_tue, zara, james]]

        self.assertEqual(Command.run_one_on_one_matches(Command()), matches)
    def test_new_multiple_availabilities(self):
        '''
        Christine & Shimin - M
        '''
        self.fresh_setup()
        christine = Profile.objects.get(first_name='christine')
        shimin = Profile.objects.get(first_name='shimin')

        christine_mon = Availability.objects.get(profile=christine,
                                                 time_available_utc=self.mon)

        matches = [[christine_mon, christine, shimin]]

        self.assertEqual(Command.run_one_on_one_matches(Command()), matches)
Exemplo n.º 22
0
    def test_match_and_run_fresh_first_day(self):
        self.fresh_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_past = Availability.objects.get(profile=t,
                                             time_available_utc=self.past)
        a_av_future = Availability.objects.get(profile=a,
                                               time_available_utc=self.future)
        t_av_future = Availability.objects.get(profile=t,
                                               time_available_utc=self.future)
        k_av_future = Availability.objects.get(profile=k,
                                               time_available_utc=self.future)
        matches = [[a_av_future, a, pj], [t_av_future, t, tim],
                   [k_av_future, k, mike]]

        self.assertEqual(t_av_past.matched_name, None)
        self.assertEqual(Command.run_one_on_one_matches(Command()), matches)
Exemplo n.º 23
0
    def test_match_and_run_future_first_day(self):
        self.previous_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_past = Availability.objects.get(profile=t,
                                             time_available_utc=self.past)
        a_av_past = Availability.objects.get(profile=a,
                                             time_available_utc=self.past)
        mike_av_past2 = Availability.objects.get(profile=mike,
                                                 time_available_utc=self.past2)
        t_av_future = Availability.objects.get(profile=t,
                                               time_available_utc=self.future)
        a_av_future = Availability.objects.get(profile=a,
                                               time_available_utc=self.future)
        pj_av_future = Availability.objects.get(profile=pj,
                                                time_available_utc=self.future)
        k_av_future = Availability.objects.get(profile=k,
                                               time_available_utc=self.future)
        tim_av_future = Availability.objects.get(
            profile=tim, time_available_utc=self.future)
        mike_av_future = Availability.objects.get(
            profile=mike, time_available_utc=self.future)

        self.assertEqual(t_av_past.matched_name, 'andrew huang')
        self.assertEqual(a_av_past.matched_name, 'tiffany qi')
        self.assertEqual(mike_av_past2.matched_name, None)

        future_availabilities = {
            1509537600.0: [
                a_av_future, t_av_future, k_av_future, mike_av_future,
                pj_av_future, tim_av_future
            ],
        }
        matches = [[1509537600.0, a, mike], [1509537600.0, pj, tim]]
        self.assertEqual(
            Command.runs_matches(Command(), future_availabilities), matches)
Exemplo n.º 24
0
    def test_match_and_run_future_first_day(self):
        self.previous_matches_setup()
        t = Profile.objects.get(first_name='tiffany')
        a = Profile.objects.get(first_name='andrew')
        tim = Profile.objects.get(first_name='tim')
        mike = Profile.objects.get(first_name='michael')
        t_av_past = Availability.objects.get(profile=t,
                                             time_available_utc=self.past)
        a_av_past = Availability.objects.get(profile=a,
                                             time_available_utc=self.past)
        a_av_future = Availability.objects.get(profile=a,
                                               time_available_utc=self.future)
        t_av_future = Availability.objects.get(profile=t,
                                               time_available_utc=self.future)
        mike_av_past2 = Availability.objects.get(profile=mike,
                                                 time_available_utc=self.past2)

        self.assertEqual(t_av_past.matched_name, 'andrew test')
        self.assertEqual(a_av_past.matched_name, 'tiffany test')
        self.assertEqual(mike_av_past2.matched_name, None)

        matches = [[a_av_future, a, mike], [t_av_future, t, tim]]
        self.assertEqual(Command.run_one_on_one_matches(Command()), matches)
    def test_check_group_match(self):
        self.fresh_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 = GroupAvailability.objects.get(profile=t,
                                             time_available_utc=self.future)
        a_av = GroupAvailability.objects.get(profile=a,
                                             time_available_utc=self.future)
        pj_av = GroupAvailability.objects.get(profile=pj,
                                              time_available_utc=self.future)
        k_av = GroupAvailability.objects.get(profile=k,
                                             time_available_utc=self.future)
        tim_av = GroupAvailability.objects.get(profile=tim,
                                               time_available_utc=self.future2)
        mike_av = GroupAvailability.objects.get(profile=mike,
                                                time_available_utc=self.future)

        group = []
        self.assertEqual(Command.check_fuzzy_match(Command(), t, t_av, group),
                         True)
        group.append(t)
        self.assertEqual(Command.check_fuzzy_match(Command(), a, a_av, group),
                         True)
        group.append(a)
        self.assertEqual(
            Command.check_fuzzy_match(Command(), pj, pj_av, group), True)
        group.append(pj)
        self.assertEqual(Command.check_fuzzy_match(Command(), k, k_av, group),
                         False)
        self.assertEqual(
            Command.check_fuzzy_match(Command(), tim, tim_av, group), True)
        group.append(tim)
        self.assertEqual(
            Command.check_fuzzy_match(Command(), mike, mike_av, group), True
        )  # actually true for the way we limit on run matches not check fuzzy match
 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)
Exemplo n.º 27
0
 def test_match_and_run_future_second_day(self):
     self.future_matches_setup()
     self.assertEqual(Command.run_one_on_one_matches(Command()), [])
Exemplo n.º 28
0
    def test_check_match_with_matches(self):
        self.previous_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.future)
        a_av = Availability.objects.get(profile=a,
                                        time_available_utc=self.future)
        pj_av = Availability.objects.get(profile=pj,
                                         time_available_utc=self.future)
        k_av = Availability.objects.get(profile=k,
                                        time_available_utc=self.future)
        tim_av = Availability.objects.get(profile=tim,
                                          time_available_utc=self.future)
        mike_av = Availability.objects.get(profile=mike,
                                           time_available_utc=self.future)

        self.assertEqual(Command.check_match(Command(), a_av, t_av, a, t),
                         False)
        self.assertEqual(Command.check_match(Command(), a_av, pj_av, a, pj),
                         False)
        self.assertEqual(Command.check_match(Command(), a_av, k_av, a, k),
                         False)
        self.assertEqual(Command.check_match(Command(), a_av, tim_av, a, tim),
                         False)
        self.assertEqual(
            Command.check_match(Command(), a_av, mike_av, a, mike), True)
        self.assertEqual(Command.check_match(Command(), t_av, pj_av, t, pj),
                         False)
        self.assertEqual(Command.check_match(Command(), t_av, a_av, t, a),
                         False)
        self.assertEqual(Command.check_match(Command(), t_av, k_av, t, k),
                         False)
        self.assertEqual(Command.check_match(Command(), t_av, tim_av, t, tim),
                         True)
        self.assertEqual(
            Command.check_match(Command(), t_av, mike_av, t, mike), True)
        self.assertEqual(Command.check_match(Command(), pj_av, t_av, pj, t),
                         False)
        self.assertEqual(Command.check_match(Command(), pj_av, a_av, pj, a),
                         False)
        self.assertEqual(Command.check_match(Command(), pj_av, k_av, pj, k),
                         False)
        self.assertEqual(
            Command.check_match(Command(), pj_av, tim_av, pj, tim), True)
        self.assertEqual(
            Command.check_match(Command(), pj_av, pj_av, pj, mike), False)
        self.assertEqual(Command.check_match(Command(), k_av, a_av, k, a),
                         False)
        self.assertEqual(Command.check_match(Command(), k_av, t_av, k, t),
                         False)
        self.assertEqual(Command.check_match(Command(), k_av, tim_av, k, tim),
                         False)
        self.assertEqual(Command.check_match(Command(), k_av, pj_av, k, pj),
                         False)
        self.assertEqual(
            Command.check_match(Command(), k_av, mike_av, k, mike), True)
        self.assertEqual(Command.check_match(Command(), tim_av, t_av, tim, t),
                         True)
        self.assertEqual(Command.check_match(Command(), tim_av, a_av, tim, a),
                         False)
        self.assertEqual(
            Command.check_match(Command(), tim_av, pj_av, tim, pj), True)
        self.assertEqual(Command.check_match(Command(), tim_av, k_av, tim, k),
                         False)
        self.assertEqual(
            Command.check_match(Command(), tim_av, mike_av, tim, mike), True)
        self.assertEqual(
            Command.check_match(Command(), mike_av, t_av, mike, t), True)
        self.assertEqual(
            Command.check_match(Command(), mike_av, a_av, mike, a), True)
        self.assertEqual(
            Command.check_match(Command(), mike_av, pj_av, mike, pj), False)
        self.assertEqual(
            Command.check_match(Command(), mike_av, k_av, mike, k), True)
        self.assertEqual(
            Command.check_match(Command(), mike_av, tim_av, mike, tim), True)
Exemplo n.º 29
0
    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)