Commit f3e7a7f2 by bmedx

Remove unnecessary patches to User::is_authenticated

parent 9f921bf6
......@@ -98,7 +98,6 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
client = AjaxEnabledTestClient()
if authenticate:
client.login(username=nonstaff.username, password=password)
nonstaff.is_authenticated = lambda: authenticate
return client, nonstaff
def reload_course(self):
......
......@@ -57,13 +57,12 @@ class TabTestCase(SharedModuleStoreTestCase):
super(TabTestCase, self).setUp()
self.reverse = lambda name, args: "name/{0}/args/{1}".format(name, ",".join(str(a) for a in args))
def create_mock_user(self, is_authenticated=True, is_staff=True, is_enrolled=True):
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
user.is_authenticated = lambda: is_authenticated
return user
def is_tab_enabled(self, tab, course, user):
......@@ -155,16 +154,16 @@ class TabTestCase(SharedModuleStoreTestCase):
):
"""Checks can display results for various users"""
if for_staff_only:
user = self.create_mock_user(is_authenticated=True, is_staff=True, is_enrolled=True)
user = self.create_mock_user(is_staff=True, is_enrolled=True)
self.assertEquals(expected_value, self.is_tab_enabled(tab, self.course, user))
if for_authenticated_users_only:
user = self.create_mock_user(is_authenticated=True, is_staff=False, is_enrolled=False)
user = self.create_mock_user(is_staff=False, is_enrolled=False)
self.assertEquals(expected_value, self.is_tab_enabled(tab, self.course, user))
if not for_staff_only and not for_authenticated_users_only and not for_enrolled_users_only:
user = self.create_mock_user(is_authenticated=False, is_staff=False, is_enrolled=False)
user = self.create_mock_user(is_staff=False, is_enrolled=False)
self.assertEquals(expected_value, self.is_tab_enabled(tab, self.course, user))
if for_enrolled_users_only:
user = self.create_mock_user(is_authenticated=True, is_staff=False, is_enrolled=True)
user = self.create_mock_user(is_staff=False, is_enrolled=True)
self.assertEquals(expected_value, self.is_tab_enabled(tab, self.course, user))
def check_get_and_set_methods(self, tab):
......@@ -214,7 +213,7 @@ class TextbooksTestCase(TabTestCase):
type_to_reverse_name = {'textbook': 'book', 'pdftextbook': 'pdf_book', 'htmltextbook': 'html_book'}
num_textbooks_found = 0
user = self.create_mock_user(is_authenticated=True, is_staff=False, is_enrolled=True)
user = self.create_mock_user(is_staff=False, is_enrolled=True)
for tab in xmodule_tabs.CourseTabList.iterate_displayable(self.course, user=user):
# verify all textbook type tabs
if tab.type == 'single_textbook':
......@@ -704,7 +703,7 @@ class CourseTabListTestCase(TabListTestCase):
course_staff_only=True))
self.course.save()
user = self.create_mock_user(is_authenticated=True, is_staff=False, is_enrolled=True)
user = self.create_mock_user(is_staff=False, is_enrolled=True)
request = get_mock_request(user)
course_tab_list = get_course_tab_list(request, self.course)
name_list = [x.name for x in course_tab_list]
......@@ -837,7 +836,7 @@ class DiscussionLinkTestCase(TabTestCase):
self.course.tabs = tab_list
self.course.discussion_link = discussion_link_in_course
discussion_tab = xmodule_tabs.CourseTabList.get_discussion(self.course)
user = self.create_mock_user(is_authenticated=True, is_staff=is_staff, is_enrolled=is_enrolled)
user = self.create_mock_user(is_staff=is_staff, is_enrolled=is_enrolled)
with patch('student.models.CourseEnrollment.is_enrolled') as check_is_enrolled:
check_is_enrolled.return_value = is_enrolled
self.assertEquals(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment