Skip to content

Commit

Permalink
E124
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 25, 2013
1 parent 6173d09 commit 19fabd2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*.pyc
*~
.*.swp
.*.sw?
\#*#
/docs/_build
/django
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
exclude=venv,.tox,migrations,docs
ignore=E124,E128
ignore=E128

[wheel]
universal = 1
9 changes: 6 additions & 3 deletions tests/testapp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def post_list(self, request, *args, **kwargs):
})

message = form.save()
data = self.api.serialize_instance(message,
data = self.api.serialize_instance(
message,
build_absolute_uri=request.build_absolute_uri,
)
return self.serialize_response(data,
Expand Down Expand Up @@ -54,11 +55,13 @@ def info(request, api):
])

api_v1.register(Group)
api_v1.register(Person,
api_v1.register(
Person,
serializer=partial(serialize_model_instance, exclude=('is_active',)),
)
api_v1.register(EmailAddress)
api_v1.register(Message,
api_v1.register(
Message,
view_class=MessageResource,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/testapp/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class SetActiveForm(forms.Form):


urlpatterns = patterns('',
resource_url('list', False, resources.ListView, suffix='',
resource_url(
'list', False, resources.ListView, suffix='',
paginate_by=5,
search_form=ResourceSearchForm,
),
Expand Down
9 changes: 6 additions & 3 deletions tests/testapp/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def get_json(self, uri, status_code=200):

def test_info(self):
self.assertEqual(self.client.get('/api/v1/').status_code, 406)
response = self.client.get('/api/v1/',
response = self.client.get(
'/api/v1/',
HTTP_ACCEPT='application/json',
)
self.assertEqual(response.status_code, 200)
Expand Down Expand Up @@ -141,7 +142,8 @@ def test_http_methods(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(response['Allow'], 'GET, HEAD, OPTIONS')

response = self.client.post('/api/v1/person/',
response = self.client.post(
'/api/v1/person/',
HTTP_ACCEPT='application/json',
)
self.assertEqual(response.status_code, 405)
Expand Down Expand Up @@ -187,7 +189,8 @@ def test_unsupported_content_type(self):
response = self.client.post('/api/v1/message/', {
})

response = self.client.post('/api/v1/message/',
response = self.client.post(
'/api/v1/message/',
'blabla',
'application/octet-stream', # Unsupported
HTTP_ACCEPT='application/json',
Expand Down
6 changes: 4 additions & 2 deletions tests/testapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ class EmailAddressSearchForm(SearchForm):
choices=Person.RELATIONSHIP_CHOICES)


emailaddress_views = ModelView(EmailAddress,
emailaddress_views = ModelView(
EmailAddress,
paginate_by=5,
search_form=EmailAddressSearchForm,
)


message_views = ModelView(Message,
message_views = ModelView(
Message,
paginate_by=5,
)

0 comments on commit 19fabd2

Please sign in to comment.