コード例 #1
0
    def test_generate_interviews_for_students_without_interview_date(self):
        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(
            teacher=self.teacher_user1,
            date=str(tomorrow),
            start_time="15:00",
            end_time="16:00")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()
        client = Client()
        client.login(
            email=self.teacher_admin.email,
            password='******'
        )

        # There are only two slots, so only the first two students should have interview dates
        self.assertEqual(Student.objects.get(id=self.student1.id).has_interview_date, True)
        self.assertEqual(Student.objects.get(id=self.student2.id).has_interview_date, True)
        self.assertEqual(Student.objects.get(id=self.student3.id).has_interview_date, False)
コード例 #2
0
    def test_generate_interviews_for_students_with_interview_date(self):
        """
        If a student has interview slot, he should not receive another one
        He can change his slot only through the choose-interview url
        """
        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(teacher=self.teacher_user1,
                                           date=str(tomorrow),
                                           start_time="15:00",
                                           end_time="16:00")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        self.student1.has_interview_date = True
        self.student1.save()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()
        client = Client()
        client.login(email=self.teacher_admin.email, password='******')

        # With two slots available and student1 with interview date,
        # all three students should have interview dates
        self.assertEqual(
            Student.objects.get(id=self.student1.id).has_interview_date, True)
        self.assertEqual(
            Student.objects.get(id=self.student2.id).has_interview_date, True)
        self.assertEqual(
            Student.objects.get(id=self.student3.id).has_interview_date, True)
コード例 #3
0
    def test_generate_interviews_for_students_without_interview_date(self):
        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(teacher=self.teacher_user1,
                                           date=str(tomorrow),
                                           start_time="15:00",
                                           end_time="16:00")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()
        client = Client()
        client.login(email=self.teacher_admin.email, password='******')

        # There are only two slots, so only the first two students should have interview dates
        self.assertEqual(
            Student.objects.get(id=self.student1.id).has_interview_date, True)
        self.assertEqual(
            Student.objects.get(id=self.student2.id).has_interview_date, True)
        self.assertEqual(
            Student.objects.get(id=self.student3.id).has_interview_date, False)
コード例 #4
0
    def handle(self, **options):
        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()

        students_without_interviews = interview_generator.get_students_without_interviews()
        generated_interviews = interview_generator.get_generated_interviews_count()

        print(str(generated_interviews) + " interviews were generated")
        print(str(students_without_interviews) + " students do not have interview date")
コード例 #5
0
    def test_generate_interview_for_slot_date_that_is_today(self):
        """
        Interviews for slots with date equal to today should not be generated
        """
        # Create time slot for today
        today = date.today()
        InterviewerFreeTime.objects.create(
            teacher=self.teacher_user1,
            date=str(today),
            start_time="15:00",
            end_time="15:30")

        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(
            teacher=self.teacher_user1,
            date=str(tomorrow),
            start_time="15:00",
            end_time="15:30")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()

        today_slot = InterviewSlot.objects.all().filter(teacher_time_slot__date=today)
        today_slot = today_slot[0]

        tomorrow_slot = InterviewSlot.objects.all().filter(teacher_time_slot__date=tomorrow)
        tomorrow_slot = tomorrow_slot[0]

        self.assertEqual(today_slot.student, None)
        self.assertEqual(tomorrow_slot.student, self.student1)
コード例 #6
0
    def test_generate_interview_for_slot_date_that_is_today(self):
        """
        Interviews for slots with date equal to today should not be generated
        """
        # Create time slot for today
        today = date.today()
        InterviewerFreeTime.objects.create(teacher=self.teacher_user1,
                                           date=str(today),
                                           start_time="15:00",
                                           end_time="15:30")

        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(teacher=self.teacher_user1,
                                           date=str(tomorrow),
                                           start_time="15:00",
                                           end_time="15:30")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()

        today_slot = InterviewSlot.objects.all().filter(
            teacher_time_slot__date=today)
        today_slot = today_slot[0]

        tomorrow_slot = InterviewSlot.objects.all().filter(
            teacher_time_slot__date=tomorrow)
        tomorrow_slot = tomorrow_slot[0]

        self.assertEqual(today_slot.student, None)
        self.assertEqual(tomorrow_slot.student, self.student1)
コード例 #7
0
    def test_generate_interviews_for_students_with_interview_date(self):
        """
        If a student has interview slot, he should not receive another one
        He can change his slot only through the choose-interview url
        """
        # Create valid time slot
        tomorrow = date.today() + timedelta(days=1)
        InterviewerFreeTime.objects.create(
            teacher=self.teacher_user1,
            date=str(tomorrow),
            start_time="15:00",
            end_time="16:00")

        interview_length = 20
        break_between_interviews = 10

        interview_slots_generator = GenerateInterviewSlots(
            interview_length, break_between_interviews)
        interview_slots_generator.generate_interview_slots()

        self.student1.has_interview_date = True
        self.student1.save()

        interview_generator = GenerateInterviews()
        interview_generator.generate_interviews()
        client = Client()
        client.login(
            email=self.teacher_admin.email,
            password='******'
        )

        # With two slots available and student1 with interview date,
        # all three students should have interview dates
        self.assertEqual(Student.objects.get(id=self.student1.id).has_interview_date, True)
        self.assertEqual(Student.objects.get(id=self.student2.id).has_interview_date, True)
        self.assertEqual(Student.objects.get(id=self.student3.id).has_interview_date, True)