def setUp(self): """ Fixtures. """ due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=utc) course = CourseFactory.create() week1 = ItemFactory.create(due=due, parent=course) week2 = ItemFactory.create(due=due, parent=course) week3 = ItemFactory.create(due=due, parent=course) homework = ItemFactory.create(parent=week1, due=due) user1 = UserFactory.create() StudentModule(state="{}", student_id=user1.id, course_id=course.id, module_state_key=week1.location).save() StudentModule(state="{}", student_id=user1.id, course_id=course.id, module_state_key=week2.location).save() StudentModule(state="{}", student_id=user1.id, course_id=course.id, module_state_key=week3.location).save() StudentModule(state="{}", student_id=user1.id, course_id=course.id, module_state_key=homework.location).save() user2 = UserFactory.create() StudentModule(state="{}", student_id=user2.id, course_id=course.id, module_state_key=week1.location).save() StudentModule(state="{}", student_id=user2.id, course_id=course.id, module_state_key=homework.location).save() user3 = UserFactory.create() StudentModule(state="{}", student_id=user3.id, course_id=course.id, module_state_key=week1.location).save() StudentModule(state="{}", student_id=user3.id, course_id=course.id, module_state_key=homework.location).save() self.course = course self.week1 = week1 self.homework = homework self.week2 = week2 self.user1 = user1 self.user2 = user2
def test_expiry_date_range(self): """ Test that the verifications are filtered on the given range. Email is not sent for any verification with expiry date out of range """ user = UserFactory.create() verification_in_range = self.create_and_submit(user) verification_in_range.status = 'approved' verification_in_range.expiry_date = now() - timedelta(days=1) verification_in_range.save() user = UserFactory.create() verification = self.create_and_submit(user) verification.status = 'approved' verification.expiry_date = now() - timedelta(days=5) verification.save() call_command('send_verification_expiry_email', '--days-range=2') # Check that only one email is sent self.assertEqual(len(mail.outbox), 1) # Verify that the email is not sent to the out of range verification expiry_email_date = SoftwareSecurePhotoVerification.objects.get(pk=verification.pk).expiry_email_date self.assertIsNone(expiry_email_date)
def setUp(self): self.course = CourseFactory.create() seed_permissions_roles(self.course.id) self.student = UserFactory.create() self.enrollment = CourseEnrollmentFactory(user=self.student, course_id=self.course.id) self.other_user = UserFactory.create(username="******") CourseEnrollmentFactory(user=self.other_user, course_id=self.course.id)
def test_user_details_force_sync_username_conflict(self): """ The user details were attempted to be synced but the incoming username already exists for another account. An email should still be sent in this case. """ # Create a user with an email that conflicts with the incoming value. UserFactory.create(username='******'.format(self.old_username)) # Begin the pipeline. pipeline.user_details_force_sync( auth_entry=pipeline.AUTH_ENTRY_LOGIN, strategy=self.strategy, details=self.details, user=self.user, ) # The username is not changed, but everything else is. user = User.objects.get(pk=self.user.pk) assert user.email == 'new+{}'.format(self.old_email) assert user.username == self.old_username assert user.profile.name == 'Grown Up {}'.format(self.old_fullname) assert user.profile.country == 'PK' # An email should still be sent because the email changed. assert len(mail.outbox) == 1
def test_transfer_students(self): student = UserFactory() student.set_password(self.PASSWORD) # pylint: disable=E1101 student.save() # pylint: disable=E1101 # Original Course original_course_location = locator.CourseLocator('Org0', 'Course0', 'Run0') course = self._create_course(original_course_location) # Enroll the student in 'verified' CourseEnrollment.enroll(student, course.id, mode="verified") # New Course 1 course_location_one = locator.CourseLocator('Org1', 'Course1', 'Run1') new_course_one = self._create_course(course_location_one) # New Course 2 course_location_two = locator.CourseLocator('Org2', 'Course2', 'Run2') new_course_two = self._create_course(course_location_two) original_key = unicode(course.id) new_key_one = unicode(new_course_one.id) new_key_two = unicode(new_course_two.id) # Run the actual management command transfer_students.Command().handle( source_course=original_key, dest_course_list=new_key_one + "," + new_key_two ) # Confirm the enrollment mode is verified on the new courses, and enrollment is enabled as appropriate. self.assertEquals(('verified', False), CourseEnrollment.enrollment_mode_for_user(student, course.id)) self.assertEquals(('verified', True), CourseEnrollment.enrollment_mode_for_user(student, new_course_one.id)) self.assertEquals(('verified', True), CourseEnrollment.enrollment_mode_for_user(student, new_course_two.id))
def setUp(self): super(CohortedContentTestCase, self).setUp() self.course = CourseFactory.create( discussion_topics={ "cohorted topic": {"id": "cohorted_topic"}, "non-cohorted topic": {"id": "non_cohorted_topic"}, }, cohort_config={ "cohorted": True, "cohorted_discussions": ["cohorted_topic"] } ) self.student_cohort = CourseUserGroup.objects.create( name="student_cohort", course_id=self.course.id, group_type=CourseUserGroup.COHORT ) self.moderator_cohort = CourseUserGroup.objects.create( name="moderator_cohort", course_id=self.course.id, group_type=CourseUserGroup.COHORT ) seed_permissions_roles(self.course.id) self.student = UserFactory.create() self.moderator = UserFactory.create() CourseEnrollmentFactory(user=self.student, course_id=self.course.id) CourseEnrollmentFactory(user=self.moderator, course_id=self.course.id) self.moderator.roles.add(Role.objects.get(name="Moderator", course_id=self.course.id)) self.student_cohort.users.add(self.student) self.moderator_cohort.users.add(self.moderator)
def test_enrolled_students_features_keys_cohorted(self): course = CourseFactory.create(org="test", course="course1", display_name="run1") course.cohort_config = {'cohorted': True, 'auto_cohort': True, 'auto_cohort_groups': ['cohort']} self.store.update_item(course, self.instructor.id) cohorted_students = [UserFactory.create() for _ in xrange(10)] cohort = CohortFactory.create(name='cohort', course_id=course.id, users=cohorted_students) cohorted_usernames = [student.username for student in cohorted_students] non_cohorted_student = UserFactory.create() for student in cohorted_students: cohort.users.add(student) CourseEnrollment.enroll(student, course.id) CourseEnrollment.enroll(non_cohorted_student, course.id) instructor = InstructorFactory(course_key=course.id) self.client.login(username=instructor.username, password='******') query_features = ('username', 'cohort') # There should be a constant of 2 SQL queries when calling # enrolled_students_features. The first query comes from the call to # User.objects.filter(...), and the second comes from # prefetch_related('course_groups'). with self.assertNumQueries(2): userreports = enrolled_students_features(course.id, query_features) self.assertEqual(len([r for r in userreports if r['username'] in cohorted_usernames]), len(cohorted_students)) self.assertEqual(len([r for r in userreports if r['username'] == non_cohorted_student.username]), 1) for report in userreports: self.assertEqual(set(report.keys()), set(query_features)) if report['username'] in cohorted_usernames: self.assertEqual(report['cohort'], cohort.name) else: self.assertEqual(report['cohort'], '[unassigned]')
def setUp(self): """Create a user with a team to test signals.""" super(TeamSignalsTest, self).setUp("teams.utils.tracker") self.user = UserFactory.create(username="******") self.moderator = UserFactory.create(username="******") self.team = CourseTeamFactory(discussion_topic_id=self.DISCUSSION_TOPIC_ID) self.team_membership = CourseTeamMembershipFactory(user=self.user, team=self.team)
def test_resolve_course_enrollments(self): """ Test that the CourseEnrollmentsScopeResolver actually returns all enrollments """ test_user_1 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id) test_user_2 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id) test_user_3 = UserFactory.create(password='******') enrollment = CourseEnrollmentFactory(user=test_user_3, course_id=self.course.id) # unenroll #3 enrollment.is_active = False enrollment.save() resolver = CourseEnrollmentsScopeResolver() user_ids = resolver.resolve('course_enrollments', {'course_id': self.course.id}, None) # should have first two, but the third should not be present self.assertTrue(test_user_1.id in user_ids) self.assertTrue(test_user_2.id in user_ids) self.assertFalse(test_user_3.id in user_ids)
def setUp(self): super(TestBlockListGetForm, self).setUp() self.student = UserFactory.create() self.student2 = UserFactory.create() self.staff = UserFactory.create(is_staff=True) CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) CourseEnrollmentFactory.create(user=self.student2, course_id=self.course.id) usage_key = self.course.location self.initial = {'requesting_user': self.student} self.form_data = QueryDict( urlencode({ 'username': self.student.username, 'usage_key': unicode(usage_key), }), mutable=True, ) self.cleaned_data = { 'all_blocks': None, 'block_counts': set(), 'depth': 0, 'nav_depth': None, 'return_type': 'dict', 'requested_fields': {'display_name', 'type'}, 'student_view_data': set(), 'usage_key': usage_key, 'username': self.student.username, 'user': self.student, }
def setup_students_and_grades(context): """ Create students and set their grades. :param context: class reference """ if context.course: context.student = student = UserFactory.create() CourseEnrollmentFactory.create(user=student, course_id=context.course.id) context.student2 = student2 = UserFactory.create() CourseEnrollmentFactory.create(user=student2, course_id=context.course.id) # create grades for self.student as if they'd submitted the ccx for chapter in context.course.get_children(): for i, section in enumerate(chapter.get_children()): for j, problem in enumerate(section.get_children()): # if not problem.visible_to_staff_only: StudentModuleFactory.create( grade=1 if i < j else 0, max_grade=1, student=context.student, course_id=context.course.id, module_state_key=problem.location ) StudentModuleFactory.create( grade=1 if i > j else 0, max_grade=1, student=context.student2, course_id=context.course.id, module_state_key=problem.location )
def setUp(self): super(UserStandingTest, self).setUp() # create users self.bad_user = UserFactory.create(username="******") self.good_user = UserFactory.create(username="******") self.non_staff = UserFactory.create(username="******") self.admin = UserFactory.create(username="******", is_staff=True) # create clients self.bad_user_client = Client() self.good_user_client = Client() self.non_staff_client = Client() self.admin_client = Client() for user, client in [ (self.bad_user, self.bad_user_client), (self.good_user, self.good_user_client), (self.non_staff, self.non_staff_client), (self.admin, self.admin_client), ]: client.login(username=user.username, password="******") UserStandingFactory.create( user=self.bad_user, account_status=UserStanding.ACCOUNT_DISABLED, changed_by=self.admin ) # set stock url to test disabled accounts' access to site self.some_url = "/"
def setUp(self): """ Create a course and user, then log in. """ super(EnrollmentTest, self).setUp() self.course = CourseFactory.create() self.user = UserFactory.create(username=self.USERNAME, email=self.EMAIL, password=self.PASSWORD) self.other_user = UserFactory.create() self.client.login(username=self.USERNAME, password=self.PASSWORD)
def test_enrollment_email_on(self): """ Do email on enroll test """ course = self.course #Create activated, but not enrolled, user UserFactory.create(username="******", email="*****@*****.**") url = reverse('instructor_dashboard', kwargs={'course_id': course.id}) response = self.client.post(url, {'action': 'Enroll multiple students', 'multiple_students': '[email protected], [email protected], [email protected]', 'auto_enroll': 'on', 'email_students': 'on'}) #Check the page output self.assertContains(response, '<td>[email protected]</td>') self.assertContains(response, '<td>[email protected]</td>') self.assertContains(response, '<td>[email protected]</td>') self.assertContains(response, '<td>added, email sent</td>') self.assertContains(response, '<td>user does not exist, enrollment allowed, pending with auto enrollment on, email sent</td>') #Check the outbox self.assertEqual(len(mail.outbox), 3) self.assertEqual(mail.outbox[0].subject, 'You have been enrolled in MITx/999/Robot_Super_Course') self.assertEqual(mail.outbox[1].subject, 'You have been invited to register for MITx/999/Robot_Super_Course') self.assertEqual(mail.outbox[1].body, "Dear student,\n\nYou have been invited to join MITx/999/Robot_Super_Course at edx.org by a member of the course staff.\n\n" + "To finish your registration, please visit https://edx.org/register and fill out the registration form.\n" + "Once you have registered and activated your account, you will see MITx/999/Robot_Super_Course listed on your dashboard.\n\n" + "----\nThis email was automatically sent from edx.org to [email protected]")
def test_duplicate_email(self): """ Assert the expected error message from the email validation method for an email address that is already in use by another account. """ UserFactory.create(email=self.new_email) self.assertEqual(self.do_email_validation(self.new_email), 'An account with this e-mail already exists.')
def setUp(self): super(ExternalAuthShibTest, self).setUp() self.course = CourseFactory.create( org='Stanford', number='456', display_name='NO SHIB', user_id=self.user.id, ) self.shib_course = CourseFactory.create( org='Stanford', number='123', display_name='Shib Only', enrollment_domain='shib:https://idp.stanford.edu/', user_id=self.user.id, ) self.user_w_map = UserFactory.create(email='*****@*****.**') self.extauth = ExternalAuthMap(external_id='*****@*****.**', external_email='*****@*****.**', external_domain='shib:https://idp.stanford.edu/', external_credentials="", user=self.user_w_map) self.user_w_map.save() self.extauth.save() self.user_wo_map = UserFactory.create(email='*****@*****.**') self.user_wo_map.save()
def setUp(self): super(RefundTests, self).setUp() self.course = CourseFactory.create( org='testorg', number='run1', display_name='refundable course' ) self.course_id = self.course.location.course_key self.client = Client() self.admin = UserFactory.create( username='******', email='*****@*****.**', password='******' ) SupportStaffRole().add_users(self.admin) self.client.login(username=self.admin.username, password='******') self.student = UserFactory.create( username='******', email='*****@*****.**' ) self.course_mode = CourseMode.objects.get_or_create( course_id=self.course_id, mode_slug='verified', min_price=1 )[0] self.order = None self.form_pars = {'course_id': str(self.course_id), 'user': self.student.email}
def setUp(self): """ Create users for use in the tests """ super(TpaAPITestCase, self).setUp() google = self.configure_google_provider(enabled=True) self.configure_facebook_provider(enabled=True) self.configure_linkedin_provider(enabled=False) self.enable_saml() testshib = self.configure_saml_provider(name='TestShib', enabled=True, idp_slug=IDP_SLUG_TESTSHIB) # Create several users and link each user to Google and TestShib for username in LINKED_USERS: make_superuser = (username == ADMIN_USERNAME) make_staff = (username == STAFF_USERNAME) or make_superuser user = UserFactory.create( username=username, password=PASSWORD, is_staff=make_staff, is_superuser=make_superuser ) UserSocialAuth.objects.create( user=user, provider=google.backend_name, uid='{}@gmail.com'.format(username), ) UserSocialAuth.objects.create( user=user, provider=testshib.backend_name, uid='{}:remote_{}'.format(testshib.idp_slug, username), ) # Create another user not linked to any providers: UserFactory.create(username=CARL_USERNAME, password=PASSWORD)
def test_site_config(self, this_org_list, other_org_list, expected_message_count, mock_ace): filtered_org = 'filtered_org' unfiltered_org = 'unfiltered_org' this_config = SiteConfigurationFactory.create(values={'course_org_filter': this_org_list}) other_config = SiteConfigurationFactory.create(values={'course_org_filter': other_org_list}) for config in (this_config, other_config): ScheduleConfigFactory.create(site=config.site) user1 = UserFactory.create(id=self.task.num_bins) user2 = UserFactory.create(id=self.task.num_bins * 2) current_day, offset, target_day, upgrade_deadline = self._get_dates() self._schedule_factory( enrollment__course__org=filtered_org, enrollment__user=user1, ) self._schedule_factory( enrollment__course__org=unfiltered_org, enrollment__user=user1, ) self._schedule_factory( enrollment__course__org=unfiltered_org, enrollment__user=user2, ) with patch.object(self.task, 'async_send_task') as mock_schedule_send: self.task().apply(kwargs=dict( site_id=this_config.site.id, target_day_str=serialize(target_day), day_offset=offset, bin_num=0 )) self.assertEqual(mock_schedule_send.apply_async.call_count, expected_message_count) self.assertFalse(mock_ace.send.called)
def setUp(self): super(TeamAPITestCase, self).setUp() self.topics_count = 4 self.users = { "student_unenrolled": UserFactory.create(password=self.test_password), "student_enrolled": UserFactory.create(password=self.test_password), "student_enrolled_not_on_team": UserFactory.create(password=self.test_password), # This student is enrolled in both test courses and is a member of a team in each course, but is not on the # same team as student_enrolled. "student_enrolled_both_courses_other_team": UserFactory.create(password=self.test_password), "staff": AdminFactory.create(password=self.test_password), "course_staff": StaffFactory.create(course_key=self.test_course_1.id, password=self.test_password), } # 'solar team' is intentionally lower case to test case insensitivity in name ordering self.test_team_1 = CourseTeamFactory.create( name=u"sólar team", course_id=self.test_course_1.id, topic_id="topic_0" ) self.test_team_2 = CourseTeamFactory.create(name="Wind Team", course_id=self.test_course_1.id) self.test_team_3 = CourseTeamFactory.create(name="Nuclear Team", course_id=self.test_course_1.id) self.test_team_4 = CourseTeamFactory.create(name="Coal Team", course_id=self.test_course_1.id, is_active=False) self.test_team_5 = CourseTeamFactory.create(name="Another Team", course_id=self.test_course_2.id) for user, course in [ ("student_enrolled", self.test_course_1), ("student_enrolled_not_on_team", self.test_course_1), ("student_enrolled_both_courses_other_team", self.test_course_1), ("student_enrolled_both_courses_other_team", self.test_course_2), ]: CourseEnrollment.enroll(self.users[user], course.id, check_access=True) self.test_team_1.add_user(self.users["student_enrolled"]) self.test_team_3.add_user(self.users["student_enrolled_both_courses_other_team"]) self.test_team_5.add_user(self.users["student_enrolled_both_courses_other_team"])
def setUp(self): super(DiscussionTabTestCase, self).setUp() self.course = CourseFactory.create() self.enrolled_user = UserFactory.create() self.staff_user = AdminFactory.create() CourseEnrollmentFactory.create(user=self.enrolled_user, course_id=self.course.id) self.unenrolled_user = UserFactory.create()
def setUp(self): """ Create a course and user, then log in. """ super(EnrollmentTest, self).setUp() self.rate_limit_config = RateLimitConfiguration.current() self.rate_limit_config.enabled = False self.rate_limit_config.save() throttle = EnrollmentUserThrottle() self.rate_limit, __ = throttle.parse_rate(throttle.rate) # Pass emit_signals when creating the course so it would be cached # as a CourseOverview. self.course = CourseFactory.create(emit_signals=True) self.user = UserFactory.create( username=self.USERNAME, email=self.EMAIL, password=self.PASSWORD, ) self.other_user = UserFactory.create( username=self.OTHER_USERNAME, email=self.OTHER_EMAIL, password=self.PASSWORD, ) self.client.login(username=self.USERNAME, password=self.PASSWORD)
def setUp(self): super(BookmarksTestsBase, self).setUp() self.admin = AdminFactory() self.user = UserFactory.create(password=self.TEST_PASSWORD) self.other_user = UserFactory.create(password=self.TEST_PASSWORD) self.setup_data(self.STORE_TYPE)
def create_mock_user(self, is_staff=True, is_enrolled=True): """ Creates a mock user with the specified properties. """ user = UserFactory(is_staff=is_staff) user.is_enrolled = is_enrolled return user
def setUp(self): super(CertificatesRestApiTest, self).setUp() self.student = UserFactory.create(password=USER_PASSWORD) self.student_no_cert = UserFactory.create(password=USER_PASSWORD) self.staff_user = UserFactory.create(password=USER_PASSWORD, is_staff=True) GeneratedCertificateFactory.create( user=self.student, course_id=self.course.id, status=CertificateStatuses.downloadable, mode='verified', download_url='www.google.com', grade="0.88" ) self.namespaced_url = 'certificates_api:v0:certificates:detail' # create a configuration for django-oauth-toolkit (DOT) dot_app_user = UserFactory.create(password=USER_PASSWORD) dot_app = dot_models.Application.objects.create( name='test app', user=dot_app_user, client_type='confidential', authorization_grant_type='authorization-code', redirect_uris='http://localhost:8079/complete/edxorg/' ) self.dot_access_token = dot_models.AccessToken.objects.create( user=self.student, application=dot_app, expires=datetime.utcnow() + timedelta(weeks=1), scope='read write', token='16MGyP3OaQYHmpT1lK7Q6MMNAZsjwF' )
def setUpTestData(cls): UserFactory.create( username='******', email='*****@*****.**', password='******', ) super(TestEnterpriseApi, cls).setUpTestData()
def test_course_bulk_notification_tests(self): # create new users and enroll them in the course. startup.startup_notification_subsystem() test_user_1 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id) test_user_2 = UserFactory.create(password='******') CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id) notification_type = get_notification_type(u'open-edx.studio.announcements.new-announcement') course = modulestore().get_course(self.course.id, depth=0) notification_msg = NotificationMessage( msg_type=notification_type, namespace=unicode(self.course.id), payload={ '_schema_version': '1', 'course_name': course.display_name, } ) # Send the notification_msg to the Celery task publish_course_notifications_task.delay(self.course.id, notification_msg) # now the enrolled users should get notification about the # course update where they are enrolled as student. self.assertTrue(get_notifications_count_for_user(test_user_1.id), 1) self.assertTrue(get_notifications_count_for_user(test_user_2.id), 1)
def setUp(self): # create users self.bad_user = UserFactory.create(username="******") self.good_user = UserFactory.create(username="******") self.non_staff = UserFactory.create(username="******") self.admin = UserFactory.create(username="******", is_staff=True) # create clients self.bad_user_client = Client() self.good_user_client = Client() self.non_staff_client = Client() self.admin_client = Client() for user, client in [ (self.bad_user, self.bad_user_client), (self.good_user, self.good_user_client), (self.non_staff, self.non_staff_client), (self.admin, self.admin_client), ]: client.login(username=user.username, password="******") UserStandingFactory.create( user=self.bad_user, account_status=UserStanding.ACCOUNT_DISABLED, changed_by=self.admin ) # set different stock urls for lms and cms # to test disabled accounts' access to site try: self.some_url = reverse("dashboard") except NoReverseMatch: self.some_url = "/course"
def setUp(self): """Set up data for the test case""" super(SubmitFeedbackTest, self).setUp() self._request_factory = RequestFactory() self._anon_user = AnonymousUser() self._auth_user = UserFactory.create( email="*****@*****.**", username="******", profile__name="Test User" ) self._anon_fields = { "email": "*****@*****.**", "name": "Test User", "subject": "a subject", "details": "some details", "issue_type": "test_issue" } # This does not contain issue_type nor course_id to ensure that they are optional self._auth_fields = {"subject": "a subject", "details": "some details"} # Create a service user, because the track selection page depends on it UserFactory.create( username='******', email="*****@*****.**", password="******", )
def setUp(self): """ Fixtures. """ super(TestDataDumps, self).setUp() due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) course = CourseFactory.create() week1 = ItemFactory.create(due=due, parent=course) week2 = ItemFactory.create(due=due, parent=course) homework = ItemFactory.create( parent=week1, due=due ) user1 = UserFactory.create() user2 = UserFactory.create() self.course = course self.week1 = week1 self.homework = homework self.week2 = week2 self.user1 = user1 self.user2 = user2 signals.extract_dates(None, course.id)
def setUp(self): self.user = UserFactory(username="******", email="*****@*****.**") self.user.profile.name = "Test Tester" self.anon_user = AnonymousUserFactory()
def test_allow_twice(self): user = UserFactory.create() update_forum_role(self.course.id, user, FORUM_ROLE_MODERATOR, 'allow') self.assertIn(user, self.mod_role.users.all()) update_forum_role(self.course.id, user, FORUM_ROLE_MODERATOR, 'allow') self.assertIn(user, self.mod_role.users.all())
def test_revoke_badrolename(self): user = UserFactory() revoke_access(self.course, user, 'robot-not-a-level')
def setUp(self): super(ComputeGradesForCourseTest, self).setUp() self.users = [UserFactory.create() for _ in xrange(12)] self.set_up_course() for user in self.users: CourseEnrollment.enroll(user, self.course.id)
def setUp(self): super(RecalculateSubsectionGradeTest, self).setUp() self.user = UserFactory() PersistentGradesEnabledFlag.objects.create( enabled_for_all_courses=True, enabled=True)
def setUpTestData(cls): """Set up and enroll our fake user in the course.""" cls.user = UserFactory(password=TEST_PASSWORD) CourseEnrollment.enroll(cls.user, cls.course.id)
def setUp(self): super(InstructorTaskTestCase, self).setUp() self.student = UserFactory.create(username="******", email="*****@*****.**") self.instructor = UserFactory.create(username="******", email="*****@*****.**") self.problem_url = InstructorTaskTestCase.problem_location("test_urlname")
def setUp(self): super(ClientCredentialsTest, self).setUp() self.user = UserFactory()
def setUp(self): self.user = UserFactory.create(username='******') self.assertEqual(self.user.id, 1) # check our assumption hard-coded in the key functions above. self.field_data_cache = FieldDataCache([mock_descriptor()], course_id, self.user) self.kvs = DjangoKeyValueStore(self.field_data_cache)
def setUp(self): super(TestApplicability, self).setUp() self.user = UserFactory.create() self.course = CourseFactory.create(run='test', display_name='test') CourseModeFactory.create(course_id=self.course.id, mode_slug='verified')
def setUpTestData(cls): """Set up and enroll our fake user in the course.""" super(CourseHomePageTestCase, cls).setUpTestData() cls.staff_user = StaffFactory(course_key=cls.course.id, password=TEST_PASSWORD) cls.user = UserFactory(password=TEST_PASSWORD) CourseEnrollment.enroll(cls.user, cls.course.id)
def setUp(self): self.user = UserFactory.create(username='******') self.field_data_cache = FieldDataCache([mock_descriptor([mock_field(Scope.user_state, 'a_field')])], course_id, self.user) self.kvs = DjangoKeyValueStore(self.field_data_cache)
def test_get_course_func_with_access(self, course_access_func_name, num_mongo_calls): course_access_func = self.COURSE_ACCESS_FUNCS[course_access_func_name] user = UserFactory.create() course = CourseFactory.create(emit_signals=True) with check_mongo_calls(num_mongo_calls): course_access_func(user, 'load', course.id)
def test_success_no_enrollment(self): """ Basic success path for users who have no enrollments, should simply not error """ user = UserFactory() _listen_for_lms_retire(sender=self.__class__, user=user)
def setUp(self): super(_BaseTestCase, self).setUp() self.override_waffle_switch(True) self.user = UserFactory.create()
def setUp(self): super(UserCartContextProcessorUnitTest, self).setUp() self.user = UserFactory.create() self.request = Mock()
def setUp(self): super(TestAccountAPITransactions, self).setUp() self.client = APIClient() self.user = UserFactory.create(password=TEST_PASSWORD) self.url = reverse("accounts_api", kwargs={'username': self.user.username})
def setUp(self): super(EnrollmentTrackTestCase, self).setUp() self.audit_user = UserFactory.create(username='******') self.verified_enrollment = CourseEnrollment.enroll(self.user, self.course_key, mode='verified') self.audit_enrollment = CourseEnrollment.enroll(self.audit_user, self.course_key, mode='audit')
def test_nonexistent_request(self): """Test that users who have not requested API access do not get it.""" other_user = UserFactory() self.assertFalse(ApiAccessRequest.has_api_access(other_user))
def setUp(self): super(UsernameReplacementViewTests, self).setUp() self.service_user = UserFactory(username=self.SERVICE_USERNAME) self.url = reverse("username_replacement")
def setUp(self): super(TestGetCourseRunDetails, self).setUp() self.catalog_integration = self.create_catalog_integration(cache_ttl=1) self.user = UserFactory(username=self.catalog_integration.service_username)
def setUp(self): super(ApiRequestViewTest, self).setUp() self.url = reverse('api-request') password = '******' self.user = UserFactory(password=password) self.client.login(username=self.user.username, password=password)
def setUp(self): super(CreateFakeCertTest, self).setUp() self.user = UserFactory.create(username=self.USERNAME)
def setUp(self): super(ApiAccessRequestTests, self).setUp() self.user = UserFactory() self.request = ApiAccessRequestFactory(user=self.user)
def test_retire_user_do_not_exist(self): user2 = UserFactory() retire_result = self.request.retire_user(user2) self.assertFalse(retire_result)
def setUp(self): self.course_overview = CourseOverviewFactory.create() self.user = UserFactory.create() super(TestCourseDurationLimitConfig, self).setUp()
def setUp(self): super(UserMixin, self).setUp() self.user = UserFactory()
def _create_user(self, username, user_email): user = UserFactory.build(username=username, email=user_email) user.set_password(self.password) user.save() return user
def setUp(self): super(ThreadViewSetListTest, self).setUp() self.author = UserFactory.create() self.url = reverse("thread-list")
def setUp(self): self.user = UserFactory.create()