cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / persistent_object_store_test.py
blob73b7f1f89973ee167b5db60612b4c8a61473825f
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 from environment_wrappers import CreatePersistentObjectStore
7 import unittest
9 class PersistentObjectStoreTest(unittest.TestCase):
10 '''Tests for PersistentObjectStore. These are all a bit contrived because
11 ultimately it comes down to our use of the appengine datastore API, and we
12 mock it out for tests anyway. Who knows whether it's correct.
13 '''
14 def testPersistence(self):
15 # First object store.
16 object_store = CreatePersistentObjectStore('test')
17 object_store.Set('key', 'value')
18 self.assertEqual('value', object_store.Get('key').Get())
19 # Other object store should have it too.
20 another_object_store = CreatePersistentObjectStore('test')
21 self.assertEqual('value', another_object_store.Get('key').Get())
22 # Setting in the other store should set in both.
23 mapping = {'key2': 'value2', 'key3': 'value3'}
24 another_object_store.SetMulti(mapping)
25 self.assertEqual(mapping, object_store.GetMulti(mapping.keys()).Get())
26 self.assertEqual(mapping,
27 another_object_store.GetMulti(mapping.keys()).Get())
28 # And delete.
29 object_store.DelMulti(mapping.keys())
30 self.assertEqual({}, object_store.GetMulti(mapping.keys()).Get())
31 self.assertEqual({}, another_object_store.GetMulti(mapping.keys()).Get())
33 def testNamespaceIsolation(self):
34 object_store = CreatePersistentObjectStore('test')
35 another_object_store = CreatePersistentObjectStore('another')
36 object_store.Set('key', 'value')
37 self.assertEqual(None, another_object_store.Get('key').Get())
39 if __name__ == '__main__':
40 unittest.main()