Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f3e7a7f2
Commit
f3e7a7f2
authored
Dec 20, 2017
by
bmedx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary patches to User::is_authenticated
parent
9f921bf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
cms/djangoapps/contentstore/tests/utils.py
+0
-1
lms/djangoapps/courseware/tests/test_tabs.py
+8
-9
No files found.
cms/djangoapps/contentstore/tests/utils.py
View file @
f3e7a7f2
...
...
@@ -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
):
...
...
lms/djangoapps/courseware/tests/test_tabs.py
View file @
f3e7a7f2
...
...
@@ -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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment