~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to test/unit/common/test_memcached.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Soren Hansen, Chuck Short
  • Date: 2012-09-07 19:02:36 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20120907190236-fqrmbzm7v6zivs8d
Tags: 1.7.0-0ubuntu1
[ Soren Hansen ]
* Update debian/watch to account for symbolically named tarballs and
  use newer URL.
* Run unit tests at build time.
* Fix Launchpad URLs in debian/watch.

[ Chuck Short ]
* New upstream release
* debian/control: Add pubthon-moc as a build dep
* debian/rules: Dont fail if testsuite fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 # -*- coding: utf8 -*-
1
2
# Copyright (c) 2010-2012 OpenStack, LLC.
2
3
#
3
4
# Licensed under the Apache License, Version 2.0 (the "License");
161
162
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
162
163
        memcache_client.set('some_key', [4, 5, 6])
163
164
        self.assertEquals(memcache_client.get('some_key'), [4, 5, 6])
 
165
        memcache_client.set('some_key', ['simple str', 'utf8 str éà'])
 
166
        # As per http://wiki.openstack.org/encoding, we should expect to have unicode
 
167
        self.assertEquals(memcache_client.get('some_key'), ['simple str', u'utf8 str éà'])
164
168
        self.assert_(float(mock.cache.values()[0][1]) == 0)
165
169
        esttimeout = time.time() + 10
166
170
        memcache_client.set('some_key', [1, 2, 3], timeout=10)
239
243
        self.assertEquals(memcache_client.get_multi(('some_key2', 'some_key1',
240
244
            'not_exists'), 'multi_key'), [[4, 5, 6], [1, 2, 3], None])
241
245
 
 
246
    def test_serialization(self):
 
247
        memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'],
 
248
                                                 allow_pickle=True)
 
249
        mock = MockMemcached()
 
250
        memcache_client._client_cache['1.2.3.4:11211'] = [(mock, mock)] * 2
 
251
        memcache_client.set('some_key', [1, 2, 3])
 
252
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
 
253
        memcache_client._allow_pickle = False
 
254
        memcache_client._allow_unpickle = True
 
255
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
 
256
        memcache_client._allow_unpickle = False
 
257
        self.assertEquals(memcache_client.get('some_key'), None)
 
258
        memcache_client.set('some_key', [1, 2, 3])
 
259
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
 
260
        memcache_client._allow_unpickle = True
 
261
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
 
262
        memcache_client._allow_pickle = True
 
263
        self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
242
264
 
243
265
if __name__ == '__main__':
244
266
    unittest.main()