Navigation Menu

Skip to content

Commit

Permalink
start despiking with api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hjwp committed Apr 21, 2016
1 parent f384468 commit ddd0e11
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lists/api.py
@@ -0,0 +1,4 @@
from django.http import HttpResponse

def list(request, list_id):
return HttpResponse(content_type='application/json')
8 changes: 8 additions & 0 deletions lists/api_urls.py
@@ -0,0 +1,8 @@
from django.conf.urls import url

from lists import api

urlpatterns = [
url(r'^lists/(\d+)/$', api.list, name='api_list'),
]

17 changes: 17 additions & 0 deletions lists/tests/test_api.py
@@ -0,0 +1,17 @@
import json

from django.test import TestCase

from lists.models import List, Item


class APIGetListItemsTest(TestCase):
base_url = '/api/lists/{}/'

def test_get_returns_json_200(self):
list_ = List.objects.create()
response = self.client.get(self.base_url.format(list_.id))
self.assertEqual(response.status_code, 200)
self.assertEqual(response['content-type'], 'application/json')


2 changes: 2 additions & 0 deletions superlists/urls.py
@@ -1,12 +1,14 @@
from django.conf.urls import include, url
from lists import views as list_views
from lists import urls as list_urls
from lists import api_urls
from accounts import urls as account_urls

urlpatterns = [
url(r'^$', list_views.home_page, name='home'),
url(r'^lists/', include(list_urls)),
url(r'^accounts/', include(account_urls)),
# url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include(api_urls)),
]

0 comments on commit ddd0e11

Please sign in to comment.