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
94043f89
Commit
94043f89
authored
Dec 26, 2014
by
Tim Babych
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all tests are in
parent
20c52ce0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
+43
-43
notesapi/v1/tests/test_views.py
+43
-43
No files found.
notesapi/v1/tests/test_views.py
View file @
94043f89
...
@@ -229,49 +229,49 @@ class AnnotationViewTests(BaseAnnotationViewTests):
...
@@ -229,49 +229,49 @@ class AnnotationViewTests(BaseAnnotationViewTests):
self
.
assertEqual
(
annotation
[
'text'
],
"Bar"
,
"annotation wasn't updated in db"
)
self
.
assertEqual
(
annotation
[
'text'
],
"Bar"
,
"annotation wasn't updated in db"
)
self
.
assertEqual
(
response
.
data
[
'text'
],
"Bar"
,
"update annotation should be returned in response"
)
self
.
assertEqual
(
response
.
data
[
'text'
],
"Bar"
,
"update annotation should be returned in response"
)
#
def test_update_without_payload_id(self):
def
test_update_without_payload_id
(
self
):
#
"""
"""
#
Test if update will be performed when there is no id in payload.
Test if update will be performed when there is no id in payload.
#
Tests if id is used from URL, regardless of what arrives in JSON payload.
Tests if id is used from URL, regardless of what arrives in JSON payload.
#
"""
"""
# self._create_annotation(text=u"Foo", id='123'
)
note
=
self
.
_create_annotation
(
text
=
u"Foo"
)
payload
=
self
.
payload
.
copy
()
# payload = {'text': 'Bar'}
payload
.
update
({
'text'
:
'Bar'
})
#
payload.update(self.headers)
payload
.
update
(
self
.
headers
)
# url = reverse('api:v1:annotations_detail', kwargs={'annotation_id': 123
})
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
note
[
'id'
]
})
#
response = self.client.put(url, payload, format='json')
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
#
self.assertEqual(response.status_code, status.HTTP_200_OK)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# annotation = self._get_annotation('123'
)
updated_note
=
self
.
_get_annotation
(
note
[
'id'
]
)
# self.assertEqual(annotation
['text'], "Bar", "annotation wasn't updated in db")
self
.
assertEqual
(
updated_note
[
'text'
],
"Bar"
,
"annotation wasn't updated in db"
)
#
def test_update_with_wrong_payload_id(self):
def
test_update_with_wrong_payload_id
(
self
):
#
"""
"""
#
Test if update will be performed when there is wrong id in payload.
Test if update will be performed when there is wrong id in payload.
#
Tests if id is used from URL, regardless of what arrives in JSON payload.
Tests if id is used from URL, regardless of what arrives in JSON payload.
#
"""
"""
# self._create_annotation(text=u"Foo", id='123'
)
note
=
self
.
_create_annotation
(
text
=
u"Foo"
)
payload
=
self
.
payload
.
copy
()
# url = reverse('api:v1:annotations_detail', kwargs={'annotation_id': 123
})
payload
.
update
({
'text'
:
'Bar'
,
'id'
:
'xxx'
})
# payload = {'text': 'Bar', 'id': 'abc'}
payload
.
update
(
self
.
headers
)
# payload.update(self.headers
)
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
note
[
'id'
]}
)
#
response = self.client.put(url, payload, format='json')
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
#
self.assertEqual(response.status_code, status.HTTP_200_OK)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# annotation = self._get_annotation('123'
)
updated_note
=
self
.
_get_annotation
(
note
[
'id'
]
)
# self.assertEqual(annotation
['text'], "Bar", "annotation wasn't updated in db")
self
.
assertEqual
(
updated_note
[
'text'
],
"Bar"
,
"annotation wasn't updated in db"
)
#
def test_update_notfound(self):
def
test_update_notfound
(
self
):
#
"""
"""
#
Test if annotation not exists with specified id and update was attempted on it.
Test if annotation not exists with specified id and update was attempted on it.
#
"""
"""
#
payload = {'id': '123', 'text': 'Bar'}
payload
=
{
'id'
:
'123'
,
'text'
:
'Bar'
}
#
payload.update(self.headers)
payload
.
update
(
self
.
headers
)
#
url = reverse('api:v1:annotations_detail', kwargs={'annotation_id': 123})
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
123
})
#
response = self.client.put(url, payload, format='json')
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
#
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
def
test_delete
(
self
):
def
test_delete
(
self
):
"""
"""
...
...
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