Commit d9cfbc65 by Oleg Marshev

Add server test.

parent 97d8ede3
### Python artifacts
# Python artifacts
*.pyc
# Coverage reports
.coverage
......@@ -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')
......
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'),
)
......@@ -18,6 +18,7 @@ INSTALLED_APPS = (
'rest_framework',
'rest_framework_swagger',
'corsheaders',
'django_nose',
)
STATIC_URL = '/static/'
......
from .common import *
ALLOWED_HOSTS = ['*']
......@@ -9,3 +9,5 @@ DATABASES = {
'NAME': TEST_ROOT / "db" / "notesserver.db",
}
}
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
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)
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment