-
Notifications
You must be signed in to change notification settings - Fork 26
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 #405 from open-dynaMIX/refactor_caching_data_sources
Refactor of caching for DataSources
- Loading branch information
Showing
9 changed files
with
189 additions
and
143 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
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,34 @@ | ||
from time import sleep | ||
|
||
from django.core.cache import cache | ||
|
||
from .data_sources import MyDataSource | ||
|
||
|
||
def test_set_cache(info): | ||
cache.clear() | ||
ds = MyDataSource() | ||
result = ds.get_data_test_string(info) | ||
assert result == "test string" | ||
assert cache.get("data_source_MyDataSource") == "test string" | ||
|
||
|
||
def test_get_from_cache(info): | ||
cache.clear() | ||
ds = MyDataSource() | ||
ds.get_data_uuid(info) | ||
cached_result = cache.get("data_source_MyDataSource") | ||
new_result = ds.get_data_uuid(info) | ||
assert cached_result == new_result | ||
|
||
|
||
def test_expired_cache(info): | ||
cache.clear() | ||
ds = MyDataSource() | ||
ds.get_data_expire(info) | ||
cached_result = cache.get("data_source_MyDataSource") | ||
|
||
sleep(1.1) | ||
new_result = ds.get_data_uuid(info) | ||
|
||
assert not cached_result == new_result |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.