diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-09-04 02:20:26 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-09-04 02:20:26 +0000 |
| commit | b17f250907351923f39f8a50b87a35b26d2ca307 (patch) | |
| tree | bd0202dea501c6678a0b56b8e108194aab78468d /tests/othertests/cache.py | |
| parent | 5a58772a1ee470e2890d3c716ce4918555100a55 (diff) | |
[multi-db] Merge trunk to [3661]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/othertests/cache.py')
| -rw-r--r-- | tests/othertests/cache.py | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/tests/othertests/cache.py b/tests/othertests/cache.py deleted file mode 100644 index 81f2c20328..0000000000 --- a/tests/othertests/cache.py +++ /dev/null @@ -1,60 +0,0 @@ -# Unit tests for cache framework -# Uses whatever cache backend is set in the test settings file. - -from django.core.cache import cache -import time - -# functions/classes for complex data type tests -def f(): - return 42 -class C: - def m(n): - return 24 - -# simple set/get -cache.set("key", "value") -assert cache.get("key") == "value" - -# get with non-existent keys -assert cache.get("does not exist") is None -assert cache.get("does not exist", "bang!") == "bang!" - -# get_many -cache.set('a', 'a') -cache.set('b', 'b') -cache.set('c', 'c') -cache.set('d', 'd') -assert cache.get_many(['a', 'c', 'd']) == {'a' : 'a', 'c' : 'c', 'd' : 'd'} -assert cache.get_many(['a', 'b', 'e']) == {'a' : 'a', 'b' : 'b'} - -# delete -cache.set("key1", "spam") -cache.set("key2", "eggs") -assert cache.get("key1") == "spam" -cache.delete("key1") -assert cache.get("key1") is None -assert cache.get("key2") == "eggs" - -# has_key -cache.set("hello", "goodbye") -assert cache.has_key("hello") == True -assert cache.has_key("goodbye") == False - -# test data types -stuff = { - 'string' : 'this is a string', - 'int' : 42, - 'list' : [1, 2, 3, 4], - 'tuple' : (1, 2, 3, 4), - 'dict' : {'A': 1, 'B' : 2}, - 'function' : f, - 'class' : C, -} -for (key, value) in stuff.items(): - cache.set(key, value) - assert cache.get(key) == value - -# expiration -cache.set('expire', 'very quickly', 1) -time.sleep(2) -assert cache.get("expire") == None |
