Commit e83952d5 by Oleg Marshev

Fix pep8 violations.

parent d97c1ab8
[pep8]
ignore=E501
max_line_length=119
PACKAGES = notesserver notesapi
test: clean test: clean
./manage.py test --settings=notesserver.settings.test --with-coverage --cover-package=notesserver,notesapi \ ./manage.py test --settings=notesserver.settings.test --with-coverage \
--exclude-dir=notesserver/settings --cover-inclusive --cover-branches \ --exclude-dir=notesserver/settings --cover-inclusive --cover-branches \
--cover-html --cover-html-dir=coverage/html/ \ --cover-html --cover-html-dir=coverage/html/ \
--cover-xml --cover-xml-file=coverage/coverage.xml --cover-xml --cover-xml-file=coverage/coverage.xml \
$(foreach package,$(PACKAGES),--cover-package=$(package)) \
$(PACKAGES)
run: run:
./manage.py runserver 0.0.0.0:8042 ./manage.py runserver 0.0.0.0:8042
...@@ -13,3 +17,5 @@ shell: ...@@ -13,3 +17,5 @@ shell:
clean: clean:
coverage erase coverage erase
quality:
pep8 --config=.pep8 $(PACKAGES)
...@@ -4,6 +4,7 @@ class MockConsumer(object): ...@@ -4,6 +4,7 @@ class MockConsumer(object):
self.secret = 'top-secret' self.secret = 'top-secret'
self.ttl = 86400 self.ttl = 86400
class MockUser(object): class MockUser(object):
def __init__(self, id='alice', consumer=None): def __init__(self, id='alice', consumer=None):
self.id = id self.id = id
...@@ -15,5 +16,6 @@ class MockAuthenticator(object): ...@@ -15,5 +16,6 @@ class MockAuthenticator(object):
def request_user(self, request): def request_user(self, request):
return MockUser() return MockUser()
def mock_authorizer(*args, **kwargs): def mock_authorizer(*args, **kwargs):
return True return True
...@@ -65,11 +65,13 @@ class AnnotationViewTests(APITestCase): ...@@ -65,11 +65,13 @@ class AnnotationViewTests(APITestCase):
self.assertIn('id', response.data, "annotation id should be returned in response") self.assertIn('id', response.data, "annotation id should be returned in response")
expected_location = '/api/v1/annotations/{0}'.format(response.data['id']) expected_location = '/api/v1/annotations/{0}'.format(response.data['id'])
self.assertTrue(response['Location'].endswith(expected_location), "The response should have a Location header " self.assertTrue(
"with the URL to read the annotation that was created") response['Location'].endswith(expected_location),
"the response should have a Location header with the URL to read the annotation that was created"
)
#self.assertEqual(self.user.id, response.data['user']) # TODO: self.assertEqual(self.user.id, response.data['user'])
#self.assertEqual(self.user.consumer.key, response.data['consumer']) # TODO: self.assertEqual(self.user.consumer.key, response.data['consumer'])
def test_create_ignore_created(self): def test_create_ignore_created(self):
""" """
......
...@@ -69,7 +69,6 @@ class AnnotationListView(APIView): ...@@ -69,7 +69,6 @@ class AnnotationListView(APIView):
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})
...@@ -116,7 +115,6 @@ class AnnotationDetailView(APIView): ...@@ -116,7 +115,6 @@ class AnnotationDetailView(APIView):
return Response(annotation) return Response(annotation)
def delete(self, request, *args, **kwargs): def delete(self, request, *args, **kwargs):
""" """
Delete an annotation. Delete an annotation.
...@@ -142,6 +140,7 @@ def _filter_input(annotation, fields): ...@@ -142,6 +140,7 @@ def _filter_input(annotation, fields):
return annotation return annotation
def _convert_str(value, default=None): def _convert_str(value, default=None):
""" """
Convert given value to string. Convert given value to string.
......
import os, json import os
import json
DEBUG = False DEBUG = False
TEMPLATE_DEBUG = False TEMPLATE_DEBUG = False
...@@ -52,8 +53,9 @@ try: ...@@ -52,8 +53,9 @@ try:
AUTH_TOKENS = json.load(auth_file) AUTH_TOKENS = json.load(auth_file)
DATABASES = AUTH_TOKENS['DATABASES'] DATABASES = AUTH_TOKENS['DATABASES']
except IOError: except IOError:
DATABASES = {'default': { DATABASES = {
'ENGINE': 'django.db.backends.sqlite3', 'default': {
'NAME': ':memory:' 'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
} }
} }
...@@ -2,6 +2,7 @@ from django.core.urlresolvers import reverse ...@@ -2,6 +2,7 @@ from django.core.urlresolvers import reverse
from rest_framework import status from rest_framework import status
from rest_framework.test import APITestCase from rest_framework.test import APITestCase
class OperationalEndpointsTest(APITestCase): class OperationalEndpointsTest(APITestCase):
""" """
Tests for operational endpoints. Tests for operational endpoints.
......
...@@ -5,3 +5,5 @@ mock==1.0.1 ...@@ -5,3 +5,5 @@ mock==1.0.1
coverage==3.7.1 coverage==3.7.1
nose-exclude==0.2.0 nose-exclude==0.2.0
nose-ignore-docstring==0.2 nose-ignore-docstring==0.2
pep8==1.5.7
pylint==1.4.0
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