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.
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
):
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
)
24 'class=_FooClass&app_version=%s' % GetAppVersion(),
26 self
.assertFalse(store
.start_empty
)
28 def testWithCategory(self
):
29 store
= self
._creator
.Create(_FooClass
, category
='hi')
31 'class=_FooClass&category=hi&app_version=%s' % GetAppVersion(),
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__':