Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
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-notes-api
Commits
782ed102
Commit
782ed102
authored
Nov 20, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests.
parent
0ef2b13c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
notesapi/v1/tests/test_views.py
+8
-8
notesapi/v1/views.py
+3
-3
No files found.
notesapi/v1/tests/test_views.py
View file @
782ed102
...
@@ -126,25 +126,25 @@ class AnnotationViewTests(APITestCase):
...
@@ -126,25 +126,25 @@ class AnnotationViewTests(APITestCase):
self
.
assertEqual
(
annotation_1
[
'name'
],
'foo'
)
self
.
assertEqual
(
annotation_1
[
'name'
],
'foo'
)
self
.
assertEqual
(
annotation_2
[
'name'
],
'bar'
)
self
.
assertEqual
(
annotation_2
[
'name'
],
'bar'
)
@unittest.skip
(
"TODO"
)
@patch
(
'notesapi.v1.views.Annotation'
,
autospec
=
Annotation
)
@patch
(
'notesapi.v1.views.Annotation'
)
def
test_create_refresh
(
self
,
mocked_annotation
):
def
test_create_refresh
(
self
,
ann_mock
):
"""
"""
Ensure save was with refresh.
Ensure save was with refresh.
"""
"""
mocked_annotation
.
return_value
.
__getitem__
=
lambda
x
,
y
:
'test_id'
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=true'
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=true'
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
ann_mock
.
return_value
.
save
.
assert_called_once_with
(
refresh
=
True
)
mocked_annotation
.
return_value
.
save
.
assert_called_once_with
(
refresh
=
True
)
@unittest.skip
(
"TODO"
)
@patch
(
'notesapi.v1.views.Annotation'
,
autospec
=
Annotation
)
@patch
(
'annotator.store.Annotation'
)
def
test_create_disable_refresh
(
self
,
mocked_annotation
):
def
test_create_disable_refresh
(
self
,
ann_mock
):
"""
"""
Ensure save was without refresh.
Ensure save was without refresh.
"""
"""
mocked_annotation
.
return_value
.
__getitem__
=
lambda
x
,
y
:
'test_id'
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=false'
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=false'
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
ann_mock
.
return_value
.
save
.
assert_called_once_with
(
refresh
=
False
)
mocked_annotation
.
return_value
.
save
.
assert_called_once_with
(
refresh
=
False
)
def
test_read
(
self
):
def
test_read
(
self
):
"""
"""
...
...
notesapi/v1/views.py
View file @
782ed102
...
@@ -54,7 +54,7 @@ class AnnotationListView(APIView):
...
@@ -54,7 +54,7 @@ class AnnotationListView(APIView):
"""
"""
Get a list of all annotations.
Get a list of all annotations.
"""
"""
# TODO: get user.
# TODO: get user
when auth will be done
.
user
=
None
user
=
None
annotations
=
Annotation
.
search
(
user
)
annotations
=
Annotation
.
search
(
user
)
...
@@ -65,12 +65,12 @@ class AnnotationListView(APIView):
...
@@ -65,12 +65,12 @@ class AnnotationListView(APIView):
"""
"""
Create a new annotation.
Create a new annotation.
"""
"""
if
request
.
DATA
is
not
None
:
annotation
=
Annotation
(
_filter_input
(
request
.
DATA
,
CREATE_FILTER_FIELDS
))
annotation
=
Annotation
(
_filter_input
(
request
.
DATA
,
CREATE_FILTER_FIELDS
))
refresh
=
request
.
QUERY_PARAMS
.
get
(
'refresh'
)
!=
u'false'
refresh
=
request
.
QUERY_PARAMS
.
get
(
'refresh'
)
!=
u'false'
annotation
.
save
(
refresh
=
refresh
)
annotation
.
save
(
refresh
=
refresh
)
location
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
annotation
[
'id'
]})
location
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
annotation
[
'id'
]})
return
Response
(
annotation
,
status
=
status
.
HTTP_201_CREATED
,
headers
=
{
'Location'
:
location
})
return
Response
(
annotation
,
status
=
status
.
HTTP_201_CREATED
,
headers
=
{
'Location'
:
location
})
...
...
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