コード例 #1
0
ファイル: tests.py プロジェクト: 8planes/langolab
    def test_save_schedule_two_users(self):
        user_1_times = [[11, 17, 11, 20], [12, 17, 12, 20]]
        schedule_arg = _schedule_arg_for_times(user_1_times)
        request = RequestMockup(self.user_1)
        rpc.save_schedule(request, schedule_arg, 2011, 8, 11, TIME_RANGE)

        user_2_times = [[11, 19, 11, 20], [12, 13, 12, 19]]
        schedule_arg = _schedule_arg_for_times(user_2_times)
        request = RequestMockup(self.user_2)
        rpc.save_schedule(request, schedule_arg, 2011, 8, 11, TIME_RANGE)

        counts = rpc.fetch_schedule(
            request, ['en'], ['es', 'it'], 2011, 8, 11, TIME_RANGE)
        self.assertEqual(12, len(counts))
        # first check counts on 8/11
        cur_index = 0
        start_hour = scheduling.hour_for_date(datetime(2011, 8, 11, 17))
        for hour in range(17, 21):
            self.assertEqual(start_hour + cur_index, 
                             counts[cur_index]['hour'])
            self.assertEqual(1 if hour < 19 else 2,
                             counts[cur_index]['count'])
            cur_index += 1
        # now check counts on 8/12
        for hour in range(13, 21):
            self.assertEqual(scheduling.hour_for_date(
                    datetime(2011, 8, 12, hour)),
                             counts[cur_index]['hour'])
            self.assertEqual(2 if hour >= 17 and hour <= 19 else 1,
                             counts[cur_index]['count'])
            cur_index += 1
コード例 #2
0
ファイル: tests.py プロジェクト: 8planes/langolab
    def test_retrieve_schedule(self):
        schedule_arg = _schedule_arg_for_times([[11, 17, 11, 17]])
        request = RequestMockup(self.user_0)
        rpc.save_schedule(request, schedule_arg, 2011, 8, 11, TIME_RANGE)

        resulting_schedule = rpc.fetch_schedule(
            request, ['es'], ['en'], 2011, 8, 11, TIME_RANGE)
        self.assertEqual(1, len(resulting_schedule))
        self.assertEqual(
            scheduling.hour_for_date(datetime(2011, 8, 11, 17)),
            resulting_schedule[0]['hour'])
        self.assertEqual(
            1, resulting_schedule[0]['count'])