Exemplo n.º 1
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())
Exemplo n.º 2
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())
Exemplo n.º 3
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())
Exemplo n.º 4
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())
Exemplo n.º 5
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())