Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/common/extensions/docs/server2/object_store_creator_test.py

Issue 14856006: Docserver: achieve online vs offline (cron vs instance) behaviour at the object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from test_object_store import TestObjectStore 8 from test_object_store import TestObjectStore
9 from object_store_creator import ObjectStoreCreator 9 from object_store_creator import ObjectStoreCreator
10 10
11 class _FooClass(object): 11 class _FooClass(object):
12 def __init__(self): pass 12 def __init__(self): pass
13 13
14 class ObjectStoreCreatorTest(unittest.TestCase): 14 class ObjectStoreCreatorTest(unittest.TestCase):
15 def setUp(self): 15 def setUp(self):
16 self.creator = ObjectStoreCreator(_FooClass, 16 self.creator = ObjectStoreCreator(_FooClass,
17 '3-0', 17 '3-0',
18 'test', 18 'test',
19 ObjectStoreCreator.START_POPULATED,
19 store_type=TestObjectStore) 20 store_type=TestObjectStore)
20 21
21 def testVanilla(self): 22 def testVanilla(self):
22 store = self.creator.Create() 23 store = self.creator.Create()
23 self.assertEqual('3-0/_FooClass@test', store.namespace) 24 self.assertEqual('3-0/_FooClass@test', store.namespace)
24 25
25 def testWithCategory(self): 26 def testWithCategory(self):
26 store = self.creator.Create(category='cat') 27 store = self.creator.Create(category='cat')
27 self.assertEqual('3-0/_FooClass@test/cat', store.namespace) 28 self.assertEqual('3-0/_FooClass@test/cat', store.namespace)
28 29
29 def testIllegalInput(self): 30 def testIllegalInput(self):
30 self.assertRaises(AssertionError, self.creator.Create, category='5') 31 self.assertRaises(AssertionError, self.creator.Create, category='5')
31 self.assertRaises(AssertionError, self.creator.Create, category='forty2') 32 self.assertRaises(AssertionError, self.creator.Create, category='forty2')
32 33
33 def testFactoryWithBranch(self): 34 def testFactoryWithBranch(self):
34 store = ObjectStoreCreator.Factory('3-0', 'dev').Create( 35 store = ObjectStoreCreator.Factory(
35 _FooClass, store_type=TestObjectStore).Create() 36 '3-0',
37 'dev',
38 ObjectStoreCreator.START_POPULATED).Create(
39 _FooClass, store_type=TestObjectStore).Create()
36 self.assertEqual('3-0/_FooClass@dev', store.namespace) 40 self.assertEqual('3-0/_FooClass@dev', store.namespace)
37 41
42 def testStartConfiguration(self):
43 store = (ObjectStoreCreator.TestFactory(
44 start_configuration=ObjectStoreCreator.START_POPULATED)
45 .Create(_FooClass).Create())
46 self.assertFalse(store.start_empty)
47 store = (ObjectStoreCreator.TestFactory(
48 start_configuration=ObjectStoreCreator.START_EMPTY)
49 .Create(_FooClass).Create())
50 self.assertTrue(store.start_empty)
51
38 if __name__ == '__main__': 52 if __name__ == '__main__':
39 unittest.main() 53 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698