Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.http import HttpResponse | ||
|
||
def list(request, list_id): | ||
return HttpResponse(content_type='application/json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from lists import api | ||
|
||
urlpatterns = [ | ||
url(r'^lists/(\d+)/$', api.list, name='api_list'), | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)), | ||
] | ||
|