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
408bc223
Commit
408bc223
authored
Sep 20, 2016
by
Rene Sorel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
requested changes for quality and performance
parent
a91b5f38
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
13 deletions
+8
-13
lms/djangoapps/mobile_api/testutils.py
+4
-4
lms/djangoapps/mobile_api/users/tests.py
+3
-8
lms/djangoapps/mobile_api/users/views.py
+1
-1
No files found.
lms/djangoapps/mobile_api/testutils.py
View file @
408bc223
...
@@ -72,13 +72,13 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase):
...
@@ -72,13 +72,13 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase):
self
.
login
()
self
.
login
()
self
.
enroll
(
course_id
)
self
.
enroll
(
course_id
)
def
api_response
(
self
,
reverse_args
=
None
,
expected_response_code
=
200
,
qargs
=
{}
,
**
kwargs
):
def
api_response
(
self
,
reverse_args
=
None
,
expected_response_code
=
200
,
data
=
None
,
**
kwargs
):
"""
"""
Helper method for calling endpoint, verifying and returning response.
Helper method for calling endpoint, verifying and returning response.
If expected_response_code is None, doesn't verify the response' status_code.
If expected_response_code is None, doesn't verify the response' status_code.
"""
"""
url
=
self
.
reverse_url
(
reverse_args
,
**
kwargs
)
url
=
self
.
reverse_url
(
reverse_args
,
**
kwargs
)
response
=
self
.
url_method
(
url
,
qargs
=
qargs
,
**
kwargs
)
response
=
self
.
url_method
(
url
,
data
=
data
,
**
kwargs
)
if
expected_response_code
is
not
None
:
if
expected_response_code
is
not
None
:
self
.
assertEqual
(
response
.
status_code
,
expected_response_code
)
self
.
assertEqual
(
response
.
status_code
,
expected_response_code
)
return
response
return
response
...
@@ -92,9 +92,9 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase):
...
@@ -92,9 +92,9 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase):
reverse_args
.
update
({
'username'
:
kwargs
.
get
(
'username'
,
self
.
user
.
username
)})
reverse_args
.
update
({
'username'
:
kwargs
.
get
(
'username'
,
self
.
user
.
username
)})
return
reverse
(
self
.
REVERSE_INFO
[
'name'
],
kwargs
=
reverse_args
)
return
reverse
(
self
.
REVERSE_INFO
[
'name'
],
kwargs
=
reverse_args
)
def
url_method
(
self
,
url
,
qargs
=
{}
,
**
kwargs
):
# pylint: disable=unused-argument
def
url_method
(
self
,
url
,
data
=
None
,
**
kwargs
):
# pylint: disable=unused-argument
"""Base implementation that returns response from the GET method of the URL."""
"""Base implementation that returns response from the GET method of the URL."""
return
self
.
client
.
get
(
url
,
qargs
)
return
self
.
client
.
get
(
url
,
data
=
data
)
class
MobileAuthTestMixin
(
object
):
class
MobileAuthTestMixin
(
object
):
...
...
lms/djangoapps/mobile_api/users/tests.py
View file @
408bc223
...
@@ -292,16 +292,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
...
@@ -292,16 +292,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
for
course
in
courses
:
for
course
in
courses
:
self
.
enroll
(
course
.
id
)
self
.
enroll
(
course
.
id
)
response
=
self
.
api_response
(
qargs
=
{
'org'
:
'edX'
})
response
=
self
.
api_response
(
data
=
{
'org'
:
'edX'
})
# Verify only edX courses are returned
# Verify only edX courses are returned
self
.
assertEqual
(
len
(
response
.
data
),
3
)
for
entry
in
response
.
data
:
for
course_index
in
range
(
3
):
self
.
assertEqual
(
entry
[
'course'
][
'org'
],
'edX'
)
result
=
response
.
data
[
course_index
][
'course'
]
self
.
assertEqual
(
result
[
'org'
],
'edX'
)
# Verify most recently enrolled course is staff only but still returned
self
.
assertFalse
(
response
.
data
[
0
][
'course'
][
'courseware_access'
][
'has_access'
])
@attr
(
shard
=
2
)
@attr
(
shard
=
2
)
...
...
lms/djangoapps/mobile_api/users/views.py
View file @
408bc223
...
@@ -271,7 +271,7 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
...
@@ -271,7 +271,7 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
pagination_class
=
None
pagination_class
=
None
def
is_org
(
self
,
check_org
,
course_org
):
def
is_org
(
self
,
check_org
,
course_org
):
return
check_org
==
None
or
(
check_org
.
lower
()
==
course_org
.
lower
())
return
check_org
is
None
or
(
check_org
.
lower
()
==
course_org
.
lower
())
def
get_queryset
(
self
):
def
get_queryset
(
self
):
enrollments
=
self
.
queryset
.
filter
(
enrollments
=
self
.
queryset
.
filter
(
...
...
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