-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #32. @cache_response doesn't seem to be working with DRF 2.4
- Loading branch information
Chibisov Gennady
committed
Sep 9, 2014
1 parent
8aed65b
commit 2812b50
Showing
9 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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 @@ | ||
|
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 @@ | ||
|
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
|
||
from django.test import TestCase | ||
|
||
from .urls import urlpatterns | ||
|
||
|
||
class TestCacheResponseFunctionally(TestCase): | ||
urls = urlpatterns | ||
|
||
def test_should_return_response(self): | ||
resp = self.client.get('/hello/') | ||
self.assertEqual(resp.content, '"Hello world"') | ||
|
||
def test_should_return_same_response_if_cached(self): | ||
resp_1 = self.client.get('/hello/') | ||
resp_2 = self.client.get('/hello/') | ||
self.assertEqual(resp_1.content, resp_2.content) |
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,9 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.conf.urls import url | ||
|
||
from .views import HelloView | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^hello/$', HelloView.as_view(), name='hello'), | ||
] |
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,11 @@ | ||
# -*- coding: utf-8 -*- | ||
from rest_framework import views | ||
from rest_framework.response import Response | ||
|
||
from rest_framework_extensions.cache.decorators import cache_response | ||
|
||
|
||
class HelloView(views.APIView): | ||
@cache_response() | ||
def get(self, request, *args, **kwargs): | ||
return Response('Hello world') |
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