Skip to content

Commit

Permalink
Improved coverage of test
Browse files Browse the repository at this point in the history
  • Loading branch information
brosner committed Feb 9, 2016
1 parent 6409239 commit 4e477cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pinax/api/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import unicode_literals

import json

from django.core.urlresolvers import reverse
from django.test import TestCase

Expand All @@ -11,4 +13,15 @@ def setUp(self):

def test_something(self):
r = self.client.get(reverse("user-list"))
self.assertEqual(r.status_code, 405)
self.assertEqual(r.status_code, 200)
self.assertEqual(r["Content-Type"], "application/vnd.api+json")
self.assertDictEqual(
{
"jsonapi": {"version": "1.0"},
"links": {
"self": "http://testserver/user/",
},
"data": [],
},
json.loads(r.content),
)
6 changes: 6 additions & 0 deletions pinax/api/tests/viewsets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import unicode_literals

from django.contrib.auth.models import User

from pinax.api import ResourceURL, ResourceViewSet


Expand All @@ -11,3 +13,7 @@ class UserViewSet(ResourceViewSet):
lookup_regex=r"\d+",
base_name="user",
)

def list(self, request):
users = User.objects.all()
return self.render(users, attributes=["username"])

0 comments on commit 4e477cc

Please sign in to comment.