summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-03-19 02:42:40 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-03-19 02:42:40 +0000
commit1a6d98dab97df7e4bfc6fd9c82183eb9a1349078 (patch)
tree869ea8a655dc92e847fe7fc7a83a3c7a4ec1ed63 /tests
parentbd0daa04f5c886c8eeebac0c48ef6a326cbf689e (diff)
Fixed #13686 -- Ensure that memcache handling of unicode values in add() and set_many() is consistent with the handling provided by get() and set(). Thanks to nedbatchelder for the report, and to jbalogh, accuser and Jacob Burch for their work ont the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15880 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/cache/tests.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 62d5eb6c87..2832bcbdd9 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -317,20 +317,48 @@ class BaseCacheTests(object):
u'Iñtërnâtiônàlizætiøn': u'Iñtërnâtiônàlizætiøn2',
u'ascii': {u'x' : 1 }
}
+ # Test `set`
for (key, value) in stuff.items():
self.cache.set(key, value)
self.assertEqual(self.cache.get(key), value)
+ # Test `add`
+ for (key, value) in stuff.items():
+ self.cache.delete(key)
+ self.cache.add(key, value)
+ self.assertEqual(self.cache.get(key), value)
+
+ # Test `set_many`
+ for (key, value) in stuff.items():
+ self.cache.delete(key)
+ self.cache.set_many(stuff)
+ for (key, value) in stuff.items():
+ self.assertEqual(self.cache.get(key), value)
+
def test_binary_string(self):
# Binary strings should be cachable
from zlib import compress, decompress
value = 'value_to_be_compressed'
compressed_value = compress(value)
+
+ # Test set
self.cache.set('binary1', compressed_value)
compressed_result = self.cache.get('binary1')
self.assertEqual(compressed_value, compressed_result)
self.assertEqual(value, decompress(compressed_result))
+ # Test add
+ self.cache.add('binary1-add', compressed_value)
+ compressed_result = self.cache.get('binary1-add')
+ self.assertEqual(compressed_value, compressed_result)
+ self.assertEqual(value, decompress(compressed_result))
+
+ # Test set_many
+ self.cache.set_many({'binary1-set_many': compressed_value})
+ compressed_result = self.cache.get('binary1-set_many')
+ self.assertEqual(compressed_value, compressed_result)
+ self.assertEqual(value, decompress(compressed_result))
+
def test_set_many(self):
# Multiple keys can be set using set_many
self.cache.set_many({"key1": "spam", "key2": "eggs"})