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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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, store_type=TestObjectStore) 16 self.creator = ObjectStoreCreator(_FooClass,
17 '3-0',
18 'test',
19 store_type=TestObjectStore)
17 20
18 def testVanilla(self): 21 def testVanilla(self):
19 store = self.creator.Create() 22 store = self.creator.Create()
20 self.assertEqual('_FooClass', store.namespace) 23 self.assertEqual('3-0/_FooClass@test', store.namespace)
21
22 def testWithVersion(self):
23 store = self.creator.Create(version=42)
24 self.assertEqual('_FooClass/42', store.namespace)
25 24
26 def testWithCategory(self): 25 def testWithCategory(self):
27 store = self.creator.Create(category='cat') 26 store = self.creator.Create(category='cat')
28 self.assertEqual('_FooClass/cat', store.namespace) 27 self.assertEqual('3-0/_FooClass@test/cat', store.namespace)
29 28
30 def testWithVersionAndCategory(self): 29 def testIllegalInput(self):
31 store = self.creator.Create(version=43, category='mat')
32 self.assertEqual('_FooClass/mat/43', store.namespace)
33
34 def testIllegalIinput(self):
35 self.assertRaises(AssertionError, self.creator.Create, category='5') 30 self.assertRaises(AssertionError, self.creator.Create, category='5')
36 self.assertRaises(AssertionError, self.creator.Create, category='forty2') 31 self.assertRaises(AssertionError, self.creator.Create, category='forty2')
37 self.assertRaises(AssertionError, self.creator.Create, version='twenty')
38 self.assertRaises(AssertionError, self.creator.Create, version='7a')
39 32
40 def testFactoryWithBranch(self): 33 def testFactoryWithBranch(self):
41 store = ObjectStoreCreator.Factory().Create( 34 store = ObjectStoreCreator.Factory('3-0', 'dev').Create(
42 _FooClass, store_type=TestObjectStore).Create() 35 _FooClass, store_type=TestObjectStore).Create()
43 self.assertEqual('_FooClass', store.namespace) 36 self.assertEqual('3-0/_FooClass@dev', store.namespace)
44 store = ObjectStoreCreator.Factory(branch='dev').Create(
45 _FooClass, store_type=TestObjectStore).Create()
46 self.assertEqual('_FooClass@dev', store.namespace)
47 37
48 if __name__ == '__main__': 38 if __name__ == '__main__':
49 unittest.main() 39 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698