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
0646f9bf
Commit
0646f9bf
authored
Nov 06, 2015
by
christopher lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-1637 Discussion API now uses the view_auth_classes for permissions
Added missing unit tests.
parent
8e20faae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
19 deletions
+15
-19
lms/djangoapps/discussion_api/tests/test_views.py
+6
-2
lms/djangoapps/discussion_api/views.py
+9
-17
No files found.
lms/djangoapps/discussion_api/tests/test_views.py
View file @
0646f9bf
...
@@ -71,6 +71,10 @@ class DiscussionAPIViewTestMixin(CommentsServiceMockMixin, UrlResetMixin):
...
@@ -71,6 +71,10 @@ class DiscussionAPIViewTestMixin(CommentsServiceMockMixin, UrlResetMixin):
{
"developer_message"
:
"Authentication credentials were not provided."
}
{
"developer_message"
:
"Authentication credentials were not provided."
}
)
)
def
test_inactive
(
self
):
self
.
user
.
is_active
=
False
self
.
test_basic
()
@mock.patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@mock.patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
class
CourseViewTest
(
DiscussionAPIViewTestMixin
,
ModuleStoreTestCase
):
class
CourseViewTest
(
DiscussionAPIViewTestMixin
,
ModuleStoreTestCase
):
...
@@ -89,7 +93,7 @@ class CourseViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
...
@@ -89,7 +93,7 @@ class CourseViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
{
"developer_message"
:
"Course not found."
}
{
"developer_message"
:
"Course not found."
}
)
)
def
test_
get_success
(
self
):
def
test_
basic
(
self
):
response
=
self
.
client
.
get
(
self
.
url
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assert_response_correct
(
self
.
assert_response_correct
(
response
,
response
,
...
@@ -150,7 +154,7 @@ class CourseTopicsViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
...
@@ -150,7 +154,7 @@ class CourseTopicsViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
{
"developer_message"
:
"Course not found."
}
{
"developer_message"
:
"Course not found."
}
)
)
def
test_
get_success
(
self
):
def
test_
basic
(
self
):
response
=
self
.
client
.
get
(
self
.
url
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assert_response_correct
(
self
.
assert_response_correct
(
response
,
response
,
...
...
lms/djangoapps/discussion_api/views.py
View file @
0646f9bf
...
@@ -3,9 +3,6 @@ Discussion API views
...
@@ -3,9 +3,6 @@ Discussion API views
"""
"""
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
rest_framework.authentication
import
SessionAuthentication
from
rest_framework_oauth.authentication
import
OAuth2Authentication
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework.viewsets
import
ViewSet
from
rest_framework.viewsets
import
ViewSet
...
@@ -28,19 +25,11 @@ from discussion_api.api import (
...
@@ -28,19 +25,11 @@ from discussion_api.api import (
update_thread
,
update_thread
,
)
)
from
discussion_api.forms
import
CommentListGetForm
,
ThreadListGetForm
,
_PaginationForm
from
discussion_api.forms
import
CommentListGetForm
,
ThreadListGetForm
,
_PaginationForm
from
openedx.core.lib.api.view_utils
import
DeveloperErrorViewMixin
from
openedx.core.lib.api.view_utils
import
DeveloperErrorViewMixin
,
view_auth_classes
class
_ViewMixin
(
object
):
@view_auth_classes
()
"""
class
CourseView
(
DeveloperErrorViewMixin
,
APIView
):
Mixin to provide common characteristics and utility functions for Discussion
API views
"""
authentication_classes
=
(
OAuth2Authentication
,
SessionAuthentication
)
permission_classes
=
(
IsAuthenticated
,)
class
CourseView
(
_ViewMixin
,
DeveloperErrorViewMixin
,
APIView
):
"""
"""
**Use Cases**
**Use Cases**
...
@@ -72,7 +61,8 @@ class CourseView(_ViewMixin, DeveloperErrorViewMixin, APIView):
...
@@ -72,7 +61,8 @@ class CourseView(_ViewMixin, DeveloperErrorViewMixin, APIView):
return
Response
(
get_course
(
request
,
course_key
))
return
Response
(
get_course
(
request
,
course_key
))
class
CourseTopicsView
(
_ViewMixin
,
DeveloperErrorViewMixin
,
APIView
):
@view_auth_classes
()
class
CourseTopicsView
(
DeveloperErrorViewMixin
,
APIView
):
"""
"""
**Use Cases**
**Use Cases**
...
@@ -106,7 +96,8 @@ class CourseTopicsView(_ViewMixin, DeveloperErrorViewMixin, APIView):
...
@@ -106,7 +96,8 @@ class CourseTopicsView(_ViewMixin, DeveloperErrorViewMixin, APIView):
return
Response
(
response
)
return
Response
(
response
)
class
ThreadViewSet
(
_ViewMixin
,
DeveloperErrorViewMixin
,
ViewSet
):
@view_auth_classes
()
class
ThreadViewSet
(
DeveloperErrorViewMixin
,
ViewSet
):
"""
"""
**Use Cases**
**Use Cases**
...
@@ -294,7 +285,8 @@ class ThreadViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
...
@@ -294,7 +285,8 @@ class ThreadViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
return
Response
(
status
=
204
)
return
Response
(
status
=
204
)
class
CommentViewSet
(
_ViewMixin
,
DeveloperErrorViewMixin
,
ViewSet
):
@view_auth_classes
()
class
CommentViewSet
(
DeveloperErrorViewMixin
,
ViewSet
):
"""
"""
**Use Cases**
**Use Cases**
...
...
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