Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / object_store_creator_test.py
blob217571bf8594503044558b7eea9e496b01ee3b6e
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 import unittest
8 from environment import GetAppVersion
9 from test_object_store import TestObjectStore
10 from object_store_creator import ObjectStoreCreator
12 class _FooClass(object):
13 def __init__(self): pass
15 class ObjectStoreCreatorTest(unittest.TestCase):
16 def setUp(self):
17 self._creator = ObjectStoreCreator(start_empty=False,
18 store_type=TestObjectStore,
19 disable_wrappers=True)
21 def testVanilla(self):
22 store = self._creator.Create(_FooClass)
23 self.assertEqual(
24 'class=_FooClass&app_version=%s' % GetAppVersion(),
25 store.namespace)
26 self.assertFalse(store.start_empty)
28 def testWithCategory(self):
29 store = self._creator.Create(_FooClass, category='hi')
30 self.assertEqual(
31 'class=_FooClass&category=hi&app_version=%s' % GetAppVersion(),
32 store.namespace)
33 self.assertFalse(store.start_empty)
35 def testWithoutAppVersion(self):
36 store = self._creator.Create(_FooClass, app_version=None)
37 self.assertEqual('class=_FooClass', store.namespace)
38 self.assertFalse(store.start_empty)
40 def testStartConfiguration(self):
41 store = self._creator.Create(_FooClass, start_empty=True)
42 self.assertTrue(store.start_empty)
43 store = self._creator.Create(_FooClass, start_empty=False)
44 self.assertFalse(store.start_empty)
45 self.assertRaises(ValueError, ObjectStoreCreator)
47 def testIllegalCharacters(self):
48 self.assertRaises(ValueError,
49 self._creator.Create, _FooClass, app_version='1&2')
50 self.assertRaises(ValueError,
51 self._creator.Create, _FooClass, category='a=&b')
53 if __name__ == '__main__':
54 unittest.main()