Exemplo n.º 1
0
    def test_course_access_to_beta_users(self):
        """
        Test that beta testers can access `self_paced` course prior to start date.
        """
        now = datetime.datetime.now(pytz.UTC)
        one_month_from_now = now + datetime.timedelta(days=30)
        course_options = {
            'days_early_for_beta': 100,
            'self_paced': True,
            'start': one_month_from_now,
        }
        # Create a `self_paced` course and add a beta tester in it
        self_paced_course, self_paced_section = self.setup_course(
            **course_options)
        beta_tester = BetaTesterFactory(course_key=self_paced_course.id)

        # Verify course is `self_paced` and course has start date but not section.
        self.assertTrue(self_paced_course.self_paced)
        self.assertEqual(self_paced_course.start, one_month_from_now)
        self.assertIsNone(self_paced_section.start)

        # Verify that non-staff user do not have access to the course
        self.assertFalse(
            has_access(self.non_staff_user, 'load', self_paced_course))

        # Verify beta tester can access the course as well as the course sections
        self.assertTrue(has_access(beta_tester, 'load', self_paced_course))
        self.assertTrue(
            has_access(beta_tester, 'load', self_paced_section,
                       self_paced_course.id))
Exemplo n.º 2
0
def i_am_registered_for_the_course(coursenum, metadata, user='******'):
    # Create user
    if user == 'BetaTester':
        # Create the course
        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=5)
        metadata.update({'days_early_for_beta': 5, 'start': tomorrow})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location

        # create beta tester
        user = BetaTesterFactory(course=course_location)
        normal_student = UserFactory()
        instructor = InstructorFactory(course=course_location)

        assert not has_access(normal_student, course_descriptor, 'load')
        assert has_access(user, course_descriptor, 'load')
        assert has_access(instructor, course_descriptor, 'load')
    else:
        metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)})
        create_course_for_lti(coursenum, metadata)
        course_descriptor = world.scenario_dict['COURSE']
        course_location = world.scenario_dict['COURSE'].location
        user = InstructorFactory(course=course_location)

    # Enroll the user in the course and log them in
    if has_access(user, course_descriptor, 'load'):
        world.enroll_user(user, course_id(coursenum))

    world.log_in(username=user.username, password='******')
Exemplo n.º 3
0
 def setUp(self, **kwargs):
     super(StartDateTransformerTestCase, self).setUp(**kwargs)
     self.beta_user = BetaTesterFactory(course_key=self.course.id,
                                        username='******',
                                        password=self.password)
     course = self.get_block(0)
     course.days_early_for_beta = 33
     update_block(course)
Exemplo n.º 4
0
 def setUp(self):
     super(AccessTestCase, self).setUp()
     self.course = CourseFactory.create(org='edX', course='toy', run='test_run')
     self.anonymous_user = AnonymousUserFactory()
     self.beta_user = BetaTesterFactory(course_key=self.course.id)
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course.id)
     self.course_instructor = InstructorFactory(course_key=self.course.id)
     self.staff = GlobalStaffFactory()
Exemplo n.º 5
0
    def setUp(self):

        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=1)

        self.course = CourseFactory(days_early_for_beta=2, start=tomorrow)
        self.content = ItemFactory(parent=self.course)

        self.normal_student = UserFactory()
        self.beta_tester = BetaTesterFactory(course_key=self.course.id)
Exemplo n.º 6
0
 def setUp(self):
     super(AccessTestCase, self).setUp()
     course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
     self.course = course_key.make_usage_key('course', course_key.run)
     self.anonymous_user = AnonymousUserFactory()
     self.beta_user = BetaTesterFactory(course_key=self.course.course_key)
     self.student = UserFactory()
     self.global_staff = UserFactory(is_staff=True)
     self.course_staff = StaffFactory(course_key=self.course.course_key)
     self.course_instructor = InstructorFactory(
         course_key=self.course.course_key)
     self.staff = GlobalStaffFactory()