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
57f7271b
Commit
57f7271b
authored
May 24, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the Django TestClient for courseware unit tests, so that middleware is cleaned up properly
parent
437b249d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
lms/djangoapps/courseware/tests/test_access.py
+4
-13
lms/djangoapps/courseware/tests/test_views.py
+0
-0
lms/djangoapps/courseware/views/views.py
+9
-3
No files found.
lms/djangoapps/courseware/tests/test_access.py
View file @
57f7271b
...
...
@@ -30,7 +30,6 @@ from courseware.tests.factories import (
)
import
courseware.views.views
as
views
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
edxmako.tests
import
mako_middleware_process_request
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseCcxCoachRole
...
...
@@ -137,21 +136,13 @@ class CoachAccessTestCaseCCX(SharedModuleStoreTestCase, LoginEnrollmentTestCase)
CourseEnrollment
.
enroll
(
student
,
ccx_locator
)
# Test for access of a coach
request
=
self
.
request_factory
.
get
(
reverse
(
'about_course'
,
args
=
[
unicode
(
ccx_locator
)]))
request
.
user
=
self
.
coach
mako_middleware_process_request
(
request
)
resp
=
views
.
progress
(
request
,
course_id
=
unicode
(
ccx_locator
),
student_id
=
student
.
id
)
resp
=
self
.
client
.
get
(
reverse
(
'student_progress'
,
args
=
[
unicode
(
ccx_locator
),
student
.
id
]))
self
.
assertEqual
(
resp
.
status_code
,
200
)
# Assert access of a student
request
=
self
.
request_factory
.
get
(
reverse
(
'about_course'
,
args
=
[
unicode
(
ccx_locator
)]))
request
.
user
=
student
mako_middleware_process_request
(
request
)
with
self
.
assertRaises
(
Http404
)
as
context
:
views
.
progress
(
request
,
course_id
=
unicode
(
ccx_locator
),
student_id
=
self
.
coach
.
id
)
self
.
assertIsNotNone
(
context
.
exception
)
self
.
client
.
login
(
username
=
student
.
username
,
password
=
'test'
)
resp
=
self
.
client
.
get
(
reverse
(
'student_progress'
,
args
=
[
unicode
(
ccx_locator
),
self
.
coach
.
id
]))
self
.
assertEqual
(
resp
.
status_code
,
404
)
@attr
(
'shard_1'
)
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
57f7271b
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/views/views.py
View file @
57f7271b
...
...
@@ -658,7 +658,6 @@ def course_about(request, course_id):
@ensure_valid_course_key
def
progress
(
request
,
course_id
,
student_id
=
None
):
""" Display the progress page. """
course_key
=
CourseKey
.
from_string
(
course_id
)
with
modulestore
()
.
bulk_operations
(
course_key
):
...
...
@@ -673,6 +672,14 @@ def _progress(request, course_key, student_id):
Course staff are allowed to see the progress of students in their class.
"""
if
student_id
is
not
None
:
try
:
student_id
=
int
(
student_id
)
# Check for ValueError if 'student_id' cannot be converted to integer.
except
ValueError
:
raise
Http404
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
,
depth
=
None
,
check_if_enrolled
=
True
)
# check to see if there is a required survey that must be taken before
...
...
@@ -697,8 +704,7 @@ def _progress(request, course_key, student_id):
raise
Http404
try
:
student
=
User
.
objects
.
get
(
id
=
student_id
)
# Check for ValueError if 'student_id' cannot be converted to integer.
except
(
ValueError
,
User
.
DoesNotExist
):
except
User
.
DoesNotExist
:
raise
Http404
# NOTE: To make sure impersonation by instructor works, use
...
...
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