-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from anexia/test_pandas
Test caching for pandas dataframe
- Loading branch information
Showing
5 changed files
with
49 additions
and
3 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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.urls import path | ||
|
||
from testapp.views.sync import index_view | ||
from testapp.views.sync import index_view, pandas_view | ||
|
||
urlpatterns = [ | ||
path('', index_view, name='index'), | ||
path('pandas_dataframe/', pandas_view, name='pandas_dataframe'), | ||
] |
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 |
---|---|---|
@@ -1,8 +1,27 @@ | ||
from django.http import HttpResponse | ||
from testapp.utils import retrieve_time | ||
from testapp.utils import retrieve_time, retrieve_dataframe_cached, retrieve_dataframe_uncached | ||
|
||
|
||
def index_view(request): | ||
retrieve_time() | ||
retrieve_time() | ||
return HttpResponse() | ||
|
||
|
||
def pandas_view(request): | ||
""" | ||
Esure that the cache_for_request decorator works with pandas dataframes. | ||
""" | ||
df1 = retrieve_dataframe_cached() | ||
df2 = retrieve_dataframe_cached() | ||
|
||
if not df1.equals(df2): | ||
raise Exception("Dataframes are not equal") | ||
|
||
df3 = retrieve_dataframe_uncached() | ||
df4 = retrieve_dataframe_uncached() | ||
|
||
if df3.equals(df4): | ||
raise Exception("Dataframes are equal") | ||
|
||
return HttpResponse() |