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
d9cfbc65
Commit
d9cfbc65
authored
Nov 19, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add server test.
parent
97d8ede3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
2 deletions
+39
-2
.gitignore
+4
-1
notesapi/v1/tests/test_views.py
+7
-0
notesapi/v1/urls.py
+4
-1
notesserver/settings/common.py
+1
-0
notesserver/settings/production.py
+2
-0
notesserver/settings/test.py
+2
-0
notesserver/test_views.py
+14
-0
requirements/base.txt
+5
-0
No files found.
.gitignore
View file @
d9cfbc65
#
##
Python artifacts
# Python artifacts
*.pyc
# Coverage reports
.coverage
notesapi/v1/tests/test_views.py
View file @
d9cfbc65
...
...
@@ -130,6 +130,7 @@ class AnnotationViewTests(APITestCase):
@patch
(
'notesapi.v1.views.Annotation'
)
def
test_create_refresh
(
self
,
ann_mock
):
"""
Ensure save was with refresh.
"""
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=true'
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
...
...
@@ -138,6 +139,9 @@ class AnnotationViewTests(APITestCase):
@unittest.skip
(
"TODO"
)
@patch
(
'annotator.store.Annotation'
)
def
test_create_disable_refresh
(
self
,
ann_mock
):
"""
Ensure save was without refresh.
"""
url
=
reverse
(
'api:v1:annotations'
)
+
'?refresh=true'
response
=
self
.
client
.
post
(
url
,
{},
format
=
'json'
,
**
self
.
headers
)
ann_mock
.
return_value
.
save
.
assert_called_once_with
(
refresh
=
False
)
...
...
@@ -201,6 +205,9 @@ class AnnotationViewTests(APITestCase):
self
.
assertEqual
(
annotation
[
'text'
],
"Bar"
,
"annotation wasn't updated in db"
)
def
test_update_notfound
(
self
):
"""
Test if annotation not exists with specified id and update was attempted on it.
"""
payload
=
{
'id'
:
'123'
,
'text'
:
'Bar'
}
url
=
reverse
(
'api:v1:annotations_detail'
,
kwargs
=
{
'annotation_id'
:
123
})
response
=
self
.
client
.
put
(
url
,
payload
,
format
=
'json'
)
...
...
notesapi/v1/urls.py
View file @
d9cfbc65
from
django.conf.urls
import
patterns
,
url
,
include
from
django.views.generic
import
RedirectView
from
django.core.urlresolvers
import
reverse_lazy
from
notesapi.v1.views
import
AnnotationListView
,
AnnotationDetailView
,
AnnotationSearchView
urlpatterns
=
patterns
(
''
,
# nopep8
url
(
r'^annotations/$'
,
AnnotationListView
.
as_view
(),
name
=
'annotations'
),
url
(
r'^annotations/(?P<annotation_id>[a-zA-Z0-9_-]+)$'
,
AnnotationDetailView
.
as_view
(),
name
=
'annotations_detail'
),
url
(
r'^search$'
,
AnnotationSearchView
.
as_view
(),
name
=
'annotations_search'
)
url
(
r'^search$'
,
AnnotationSearchView
.
as_view
(),
name
=
'annotations_search'
),
url
(
r'^status/$'
,
RedirectView
.
as_view
(
url
=
reverse_lazy
(
'status'
)),
name
=
'status'
),
)
notesserver/settings/common.py
View file @
d9cfbc65
...
...
@@ -18,6 +18,7 @@ INSTALLED_APPS = (
'rest_framework'
,
'rest_framework_swagger'
,
'corsheaders'
,
'django_nose'
,
)
STATIC_URL
=
'/static/'
...
...
notesserver/settings/production.py
View file @
d9cfbc65
from
.common
import
*
ALLOWED_HOSTS
=
[
'*'
]
notesserver/settings/test.py
View file @
d9cfbc65
...
...
@@ -9,3 +9,5 @@ DATABASES = {
'NAME'
:
TEST_ROOT
/
"db"
/
"notesserver.db"
,
}
}
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
notesserver/test_views.py
0 → 100644
View file @
d9cfbc65
from
django.core.urlresolvers
import
reverse
from
rest_framework
import
status
from
rest_framework.test
import
APITestCase
class
OperationalEndpointsTest
(
APITestCase
):
"""
Tests for operational endpoints.
"""
def
test_status
(
self
):
"""
Test if server is alive.
"""
response
=
self
.
client
.
get
(
'/status'
,
follow
=
True
)
self
.
assertEquals
(
response
.
status_code
,
200
)
requirements/base.txt
View file @
d9cfbc65
...
...
@@ -5,4 +5,9 @@ elasticsearch==1.2.0
annotator==0.12.0
django-cors-headers==0.13
path.py==7.0
# Testing
django_nose==1.2
mock==1.0.1
coverage==3.7.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