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 stock url to test disabled accounts' access to site self.some_url = '/'
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 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): # 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): # 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): self.output = StringIO.StringIO() self.gzipfile = StringIO.StringIO() self.course = CourseFactory.create( display_name=self.COURSE_NAME, ) self.course.raw_grader = [{ 'drop_count': 0, 'min_count': 1, 'short_label': 'Final', 'type': 'Final Exam', 'weight': 1.0 }] self.course.grade_cutoffs = {'Pass': 0.1} self.students = [ UserFactory.create(username='******'), UserFactory.create(username='******'), UserFactory.create(username='******'), UserFactory.create(username='******'), UserFactory.create(username='******'), StaffFactory.create(username='******', course_key=self.course.id), InstructorFactory.create(username='******', course_key=self.course.id), ] UserStandingFactory.create( user=self.students[4], account_status=UserStanding.ACCOUNT_DISABLED, changed_by=self.students[6] ) for user in self.students: CourseEnrollmentFactory.create(user=user, course_id=self.course.id) self.pgreport = ProgressReport(self.course.id) self.pgreport2 = ProgressReport(self.course.id, lambda state: state) self.chapter = ItemFactory.create( parent_location=self.course.location, category="chapter", display_name="Week 1" ) self.chapter.save() self.section = ItemFactory.create( parent_location=self.chapter.location, category="sequential", display_name="Lesson 1" ) self.section.save() self.vertical = ItemFactory.create( parent_location=self.section.location, category="vertical", display_name="Unit1" ) self.vertical.save() self.html = ItemFactory.create( parent_location=self.vertical.location, category="html", data={'data': "<html>foobar</html>"} ) self.html.save() """ course.children = [week1.location.url(), week2.location.url(), week3.location.url()] """ from capa.tests.response_xml_factory import OptionResponseXMLFactory self.problem_xml = OptionResponseXMLFactory().build_xml( question_text='The correct answer is Correct', num_inputs=2, weight=2, options=['Correct', 'Incorrect'], correct_option='Correct' ) self.problems = [] for num in xrange(1, 3): self.problems.append(ItemFactory.create( parent_location=self.vertical.location, category='problem', display_name='problem_' + str(num), metadata={'graded': True, 'format': 'Final Exam'}, data=self.problem_xml )) self.problems[num - 1].save() for problem in self.problems: problem.correct_map = { unicode(problem.location) + "_2_1": { "hint": "", "hintmode": "", "correctness": "correct", "npoints": "", "msg": "", "queuestate": "" }, unicode(problem.location) + "_2_2": { "hint": "", "hintmode": "", "correctness": "incorrect", "npoints": "", "msg": "", "queuestate": "" } } problem.student_answers = { unicode(problem.location) + "_2_1": "Correct", unicode(problem.location) + "_2_2": "Incorrect" } problem.input_state = { unicode(problem.location) + "_2_1": {}, unicode(problem.location) + "_2_2": {} } self.course.save() patcher = patch('pgreport.views.logging') self.log_mock = patcher.start() self.addCleanup(patcher.stop) """