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
e83952d5
Commit
e83952d5
authored
Nov 24, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pep8 violations.
parent
d97c1ab8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
12 deletions
+29
-12
.pep8
+3
-0
Makefile
+8
-2
notesapi/v1/tests/helpers.py
+2
-0
notesapi/v1/tests/test_views.py
+6
-4
notesapi/v1/views.py
+1
-2
notesserver/settings/common.py
+6
-4
notesserver/test_views.py
+1
-0
requirements/test.py
+2
-0
No files found.
.pep8
0 → 100644
View file @
e83952d5
[pep8]
ignore=E501
max_line_length=119
Makefile
View file @
e83952d5
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)
notesapi/v1/tests/helpers.py
View file @
e83952d5
...
@@ -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
notesapi/v1/tests/test_views.py
View file @
e83952d5
...
@@ -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
):
"""
"""
...
...
notesapi/v1/views.py
View file @
e83952d5
...
@@ -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.
...
...
notesserver/settings/common.py
View file @
e83952d5
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:'
}
}
}
}
notesserver/test_views.py
View file @
e83952d5
...
@@ -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.
...
...
requirements/test.py
View file @
e83952d5
...
@@ -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
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