class TestAssignAcceptedUsersToCourses(TestCase): def setUp(self): start_date = timezone.now().date() - timezone.timedelta(days=3) end_date = timezone.now().date() + timezone.timedelta(days=5) start_interview_date = timezone.now().date() - timezone.timedelta(days=2) end_interview_date = timezone.now().date() + timezone.timedelta(days=4) self.application_info = ApplicationInfoFactory( start_date=start_date, end_date=end_date, start_interview_date=start_interview_date, end_interview_date=end_interview_date ) self.application = ApplicationFactory(application_info=self.application_info) def test_task_assigns_users_with_accepted_applications_to_courses(self): self.application.is_accepted = True self.application.save() course_student_count = self.application_info.course.students.count() assign_accepted_users_to_courses() self.application_info.course.refresh_from_db() self.assertEqual(course_student_count + 1, self.application_info.course.students.count()) def test_task_does_not_assign_user_with_not_accepted_application(self): self.application.is_accepted = False self.application.save() course_student_count = self.application_info.course.students.count() assign_accepted_users_to_courses() self.application_info.course.refresh_from_db() self.assertEqual(course_student_count, self.application_info.course.students.count())
class TestDeleteInterviewDataInApplication(TestCase): def setUp(self): self.application = ApplicationFactory() self.interview = InterviewFactory(application=self.application) def test_signal_sets_has_interview_date_to_false_when_interview_is_deleted( self): Interview.objects.all().delete() self.application.refresh_from_db() self.assertFalse(self.application.has_interview_date)
def setUp(self): start_date = timezone.now().date() - timezone.timedelta(days=3) end_date = timezone.now().date() + timezone.timedelta(days=5) start_interview_date = timezone.now().date() - timezone.timedelta(days=2) end_interview_date = timezone.now().date() + timezone.timedelta(days=4) self.application_info = ApplicationInfoFactory( start_date=start_date, end_date=end_date, start_interview_date=start_interview_date, end_interview_date=end_interview_date ) self.application = ApplicationFactory(application_info=self.application_info)
def test_create_application_raises_validation_error_when_user_has_already_applied( self): ApplicationFactory(application_info=self.app_info, user=self.user) with self.assertRaises(ValidationError): create_application(application_info=self.app_info, user=self.user, skype=faker.word(), full_name=faker.name())
def test_interviews_are_generated_if_enough_free_slots(self): interview_count = Interview.objects.count() ApplicationFactory(application_info=self.application_info) InterviewerFreeTimeFactory(interviewer=self.interviewer) self.interviewer.profile.skype = faker.word() self.interviewer.profile.save() context = generate_interview_slots() self.assertIn(f"Generated interviews: {Interview.objects.count()}", context['log']) self.assertEqual(interview_count + 1, Interview.objects.count())
def test_no_interviews_are_generated_if_not_enough_free_slots(self): interview_count = Interview.objects.count() ApplicationFactory(application_info=self.application_info) self.interviewer.profile.skype = faker.word() self.interviewer.profile.save() context = generate_interview_slots() application_count = Application.objects.count() self.assertIn(f"Not enough free slots - {application_count}", context['log']) self.assertEqual(interview_count, Interview.objects.count())
def setUp(self): self.application = ApplicationFactory() self.interview = InterviewFactory(application=self.application)
def setUp(self): self.user = BaseUserFactory() self.course = CourseFactory() self.application_info = ApplicationInfoFactory(course=self.course) self.application = ApplicationFactory( application_info=self.application_info, user=self.user)