Example #1
0
class ApplicationInfoFactory(factory.DjangoModelFactory):
    start_date = factory.LazyAttribute(lambda _: timezone.now().date() +
                                       timezone.timedelta(days=faker.pyint()))
    end_date = factory.LazyAttribute(lambda _: timezone.now().date() + timezone
                                     .timedelta(days=faker.pyint()))
    course = factory.SubFactory(CourseFactory)
    start_interview_date = factory.LazyAttribute(lambda _: timezone.now().date(
    ) + timezone.timedelta(days=faker.pyint()))
    end_interview_date = factory.LazyAttribute(lambda _: timezone.now().date(
    ) + timezone.timedelta(days=faker.pyint()))
    description = factory.LazyAttribute(lambda _: faker.text())

    class Meta:
        model = ApplicationInfo
Example #2
0
 def test_create_course_populates_teachers_with_superusers(self):
     start_date = faker.date_object()
     course = Course.objects.create(name=faker.word(),
                                    start_date=start_date,
                                    end_date=start_date +
                                    timezone.timedelta(days=faker.pyint()),
                                    slug_url=faker.slug())
     self.assertEqual(5, course.teachers.count())
Example #3
0
class InterviewerFreeTimeFactory(factory.DjangoModelFactory):
    interviewer = factory.SubFactory(InterviewerFactory)
    date = factory.LazyAttribute(lambda _: timezone.now().date() + timezone.
                                 timedelta(days=faker.pyint()))
    start_time = factory.LazyAttribute(lambda _: timezone.now().time())
    end_time = factory.LazyAttribute(
        lambda _: (timezone.now() + timezone.timedelta(minutes=20)).time())

    class Meta:
        model = InterviewerFreeTime
Example #4
0
class WeekFactory(factory.DjangoModelFactory):
    number = factory.LazyAttribute(lambda _: faker.pyint())

    start_date = factory.LazyAttribute(lambda _: faker.date_object())
    end_date = factory.LazyAttribute(lambda _: faker.date_object())

    course = factory.SubFactory(CourseFactory)

    class Meta:
        model = Week
Example #5
0
class SolutionFactory(factory.DjangoModelFactory):
    task = factory.SubFactory(IncludedTaskFactory)
    user = factory.SubFactory(BaseUserFactory)
    url = factory.LazyAttribute(lambda _: faker.url())
    code = factory.LazyAttribute(lambda _: faker.text())
    build_id = factory.LazyAttribute(lambda _: faker.pyint())
    test_output = factory.LazyAttribute(lambda _: faker.text())

    class Meta:
        model = Solution
Example #6
0
 def test_create_application_info_raises_validation_error_when_course_has_started(
         self):
     self.course.start_date = timezone.now().date() - timezone.timedelta(
         days=faker.pyint())
     with self.assertRaises(ValidationError):
         create_application_info(
             start_date=self.start_date,
             end_date=self.end_date,
             course=self.course,
             start_interview_date=self.start_interview_date,
             end_interview_date=self.end_interview_date)
Example #7
0
    def test_get_ordered_closed_application_infos_returns_sorted_closed_applications(
            self):
        # Randomize end dates
        for app_info in self.closed_applications:
            app_info.end_date -= timezone.timedelta(days=faker.pyint())
            app_info.save()

        self.closed_applications = sorted(self.closed_applications,
                                          key=lambda x: x.end_date,
                                          reverse=True)
        applications = ApplicationInfo.objects.get_ordered_closed_application_infos(
        )
        self.assertEqual(applications, self.closed_applications)
Example #8
0
 def test_course_is_created_successfully_with_valid_data(self):
     start_date = parser.parse(faker.date())
     count = Course.objects.count()
     data = {
         'name': faker.word(),
         'start_date': start_date,
         'end_date': start_date + timedelta(days=faker.pyint()),
         'repository': faker.url(),
         'video_channel': faker.url(),
         'facebook_group': faker.url(),
         'slug_url': faker.slug(),
     }
     create_course(**data)
     self.assertEqual(count + 1, Course.objects.count())
Example #9
0
 def test_create_course_creates_weeks_for_course_successfully(self):
     start_date = parser.parse(faker.date())
     count = Course.objects.count()
     data = {
         'name': faker.word(),
         'start_date': start_date,
         'end_date': start_date + timedelta(days=faker.pyint()),
         'repository': faker.url(),
         'video_channel': faker.url(),
         'facebook_group': faker.url(),
         'slug_url': faker.slug(),
     }
     course = create_course(**data)
     weeks = course.duration_in_weeks
     self.assertEqual(count + 1, Course.objects.count())
     self.assertEqual(weeks, Week.objects.count())
Example #10
0
 def test_create_course_raises_error_on_duplicate_name(self):
     start_date = parser.parse(faker.date())
     course = CourseFactory()
     count = Course.objects.count()
     data = {
         'name': course.name,
         'start_date': start_date,
         'end_date': start_date + timedelta(days=faker.pyint()),
         'repository': faker.url(),
         'video_channel': faker.url(),
         'facebook_group': faker.url(),
         'slug_url': faker.slug(),
     }
     with self.assertRaises(ValidationError):
         create_course(**data)
     self.assertEqual(count, Course.objects.count())
Example #11
0
 def test_create_course_starts_week_from_monday(self):
     start_date = parser.parse(faker.date())
     data = {
         'name': faker.word(),
         'start_date': start_date,
         'end_date': start_date + timedelta(days=faker.pyint()),
         'repository': faker.url(),
         'video_channel': faker.url(),
         'facebook_group': faker.url(),
         'slug_url': faker.slug(),
     }
     course = create_course(**data)
     weeks = course.duration_in_weeks
     self.assertEqual(1, Course.objects.count())
     self.assertEqual(weeks, Week.objects.count())
     week_one = Week.objects.first()
     self.assertEqual(0, week_one.start_date.weekday())
Example #12
0
 def test_service_raises_validation_error_when_date_is_invalid(self):
     invalid_date = self.course.end_date + timezone.timedelta(
         days=faker.pyint())
     with self.assertRaises(ValidationError):
         create_lecture(date=invalid_date, course=self.course)
Example #13
0
 def setUp(self):
     start_date = timezone.now().date() + timezone.timedelta(
         days=faker.pyint())
     self.course = CourseFactory(start_date=start_date,
                                 end_date=start_date +
                                 timezone.timedelta(days=faker.pyint()))