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
a8aaab76
Commit
a8aaab76
authored
Nov 24, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test.
parent
b8349632
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
notesapi/v1/tests/test_views.py
+22
-0
notesserver/settings/dev.py
+2
-1
notesserver/settings/test.py
+1
-1
notesserver/test_views.py
+15
-1
No files found.
notesapi/v1/tests/test_views.py
View file @
a8aaab76
...
...
@@ -298,3 +298,25 @@ class AnnotationViewTests(APITestCase):
result
=
self
.
_get_search_results
(
'offset=foobar'
)
self
.
assertEqual
(
len
(
result
[
'rows'
]),
20
)
self
.
assertEqual
(
result
[
'rows'
][
0
],
first
)
def
test_read_all_no_annotations
(
self
):
"""
Tests list all annotations endpoint when no annotions are present in elasticsearch.
"""
url
=
reverse
(
'api:v1:annotations'
)
response
=
self
.
client
.
get
(
url
,
**
self
.
headers
)
self
.
assertEqual
(
len
(
response
.
data
),
0
,
"no annotation should be returned in response"
)
def
test_read_all
(
self
):
"""
Tests list all annotations.
"""
for
i
in
xrange
(
5
):
kwargs
=
{
'text'
:
'Foo_{}'
.
format
(
i
),
'id'
:
str
(
i
)}
self
.
_create_annotation
(
refresh
=
False
,
**
kwargs
)
es
.
conn
.
indices
.
refresh
(
es
.
index
)
url
=
reverse
(
'api:v1:annotations'
)
response
=
self
.
client
.
get
(
url
,
**
self
.
headers
)
self
.
assertEqual
(
len
(
response
.
data
),
5
,
"five annotations should be returned in response"
)
notesserver/settings/dev.py
View file @
a8aaab76
...
...
@@ -2,4 +2,5 @@ from .common import *
DEBUG
=
True
INSTALLED_APPS
=
(
'django_nose'
,)
ELASTICSEARCH_URL
=
'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX
=
'edx-notes-dev'
notesserver/settings/test.py
View file @
a8aaab76
...
...
@@ -12,7 +12,7 @@ DATABASES = {
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
INSTALLED_APPS
=
(
'django_nose'
,)
INSTALLED_APPS
+
=
(
'django_nose'
,)
ELASTICSEARCH_URL
=
'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX
=
'edx-notes-test'
notesserver/test_views.py
View file @
a8aaab76
...
...
@@ -10,5 +10,19 @@ class OperationalEndpointsTest(APITestCase):
"""
Test if server is alive.
"""
response
=
self
.
client
.
get
(
'/status'
,
follow
=
True
)
response
=
self
.
client
.
get
(
reverse
(
'status'
)
)
self
.
assertEquals
(
response
.
status_code
,
200
)
def
test_root
(
self
):
"""
Test root endpoint.
"""
response
=
self
.
client
.
get
(
reverse
(
'root'
))
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
,
{
"name"
:
"edX Notes API"
,
"version"
:
"1"
}
)
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