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
f1f65c56
Commit
f1f65c56
authored
May 09, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix failing unit test in lms.envs.test env
parent
c7197cd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
lms/djangoapps/notes/api.py
+14
-2
lms/djangoapps/notes/tests.py
+5
-2
No files found.
lms/djangoapps/notes/api.py
View file @
f1f65c56
...
@@ -28,6 +28,13 @@ API_SETTINGS = {
...
@@ -28,6 +28,13 @@ API_SETTINGS = {
#----------------------------------------------------------------------#
#----------------------------------------------------------------------#
# API requests are routed through api_request() using the resource map.
# API requests are routed through api_request() using the resource map.
def
api_enabled
(
request
,
course_id
):
'''
Returns True if the api is enabled for the course, otherwise False.
'''
course
=
_get_course
(
request
,
course_id
)
return
notes_enabled_for_course
(
course
)
@login_required
@login_required
def
api_request
(
request
,
course_id
,
**
kwargs
):
def
api_request
(
request
,
course_id
,
**
kwargs
):
'''
'''
...
@@ -37,8 +44,7 @@ def api_request(request, course_id, **kwargs):
...
@@ -37,8 +44,7 @@ def api_request(request, course_id, **kwargs):
'''
'''
# Verify that notes are enabled for the course
# Verify that notes are enabled for the course
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
if
not
api_enabled
(
request
,
course_id
):
if
not
notes_enabled_for_course
(
course
):
log
.
debug
(
'Notes not enabled for course'
)
log
.
debug
(
'Notes not enabled for course'
)
raise
Http404
raise
Http404
...
@@ -91,6 +97,12 @@ def api_format(request, response, data):
...
@@ -91,6 +97,12 @@ def api_format(request, response, data):
content
=
json
.
dumps
(
data
)
content
=
json
.
dumps
(
data
)
return
[
content_type
,
content
]
return
[
content_type
,
content
]
def
_get_course
(
request
,
course_id
):
'''
Helper function to load and return a user's course.
'''
return
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
#----------------------------------------------------------------------#
#----------------------------------------------------------------------#
# API actions exposed via the resource map.
# API actions exposed via the resource map.
...
...
lms/djangoapps/notes/tests.py
View file @
f1f65c56
...
@@ -14,8 +14,6 @@ import logging
...
@@ -14,8 +14,6 @@ import logging
from
.
import
utils
,
api
,
models
from
.
import
utils
,
api
,
models
logging
.
disable
(
logging
.
CRITICAL
)
# remove debugging from the log output
class
UtilsTest
(
TestCase
):
class
UtilsTest
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
'''
'''
...
@@ -41,12 +39,17 @@ class UtilsTest(TestCase):
...
@@ -41,12 +39,17 @@ class UtilsTest(TestCase):
{
'type'
:
'foo'
},
{
'type'
:
'foo'
},
{
'name'
:
'My Notes'
,
'type'
:
'notes'
},
{
'name'
:
'My Notes'
,
'type'
:
'notes'
},
{
'type'
:
'bar'
}]
{
'type'
:
'bar'
}]
self
.
assertTrue
(
utils
.
notes_enabled_for_course
(
self
.
course
))
self
.
assertTrue
(
utils
.
notes_enabled_for_course
(
self
.
course
))
class
ApiTest
(
TestCase
):
class
ApiTest
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
client
=
Client
()
self
.
client
=
Client
()
# Mocks
api
.
api_enabled
=
(
lambda
request
,
course_id
:
True
)
# Create two accounts
# Create two accounts
self
.
password
=
'abc'
self
.
password
=
'abc'
self
.
student
=
User
.
objects
.
create_user
(
'student'
,
'student@test.com'
,
self
.
password
)
self
.
student
=
User
.
objects
.
create_user
(
'student'
,
'student@test.com'
,
self
.
password
)
...
...
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