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

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

Issue 15009006: Docserver: refactor Servlet, ObjectStore, and ServerInstance architecture to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, redirect fix 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 appengine_wrappers import GetAppVersion
8 from test_object_store import TestObjectStore 9 from test_object_store import TestObjectStore
9 from object_store_creator import ObjectStoreCreator 10 from object_store_creator import ObjectStoreCreator
10 11
11 class _FooClass(object): 12 class _FooClass(object):
12 def __init__(self): pass 13 def __init__(self): pass
13 14
14 class ObjectStoreCreatorTest(unittest.TestCase): 15 class ObjectStoreCreatorTest(unittest.TestCase):
15 def setUp(self): 16 def setUp(self):
16 self.creator = ObjectStoreCreator(_FooClass, 17 self._creator = ObjectStoreCreator('trunk',
17 '3-0', 18 start_empty=False,
18 'test', 19 store_type=TestObjectStore,
19 store_type=TestObjectStore) 20 disable_wrappers=True)
20 21
21 def testVanilla(self): 22 def testVanilla(self):
22 store = self.creator.Create() 23 store = self._creator.Create(_FooClass)
23 self.assertEqual('3-0/_FooClass@test', store.namespace) 24 self.assertEqual(
25 'class=_FooClass&channel=trunk&app_version=%s' % GetAppVersion(),
26 store.namespace)
27 self.assertFalse(store.start_empty)
24 28
25 def testWithCategory(self): 29 def testWithCategory(self):
26 store = self.creator.Create(category='cat') 30 store = self._creator.Create(_FooClass, category='hi')
27 self.assertEqual('3-0/_FooClass@test/cat', store.namespace) 31 self.assertEqual(
32 'class=_FooClass&category=hi&channel=trunk&app_version=%s' %
33 GetAppVersion(),
34 store.namespace)
35 self.assertFalse(store.start_empty)
28 36
29 def testIllegalInput(self): 37 def testWithoutChannel(self):
30 self.assertRaises(AssertionError, self.creator.Create, category='5') 38 store = self._creator.Create(_FooClass, channel=None)
31 self.assertRaises(AssertionError, self.creator.Create, category='forty2') 39 self.assertEqual('class=_FooClass&app_version=%s' % GetAppVersion(),
40 store.namespace)
41 self.assertFalse(store.start_empty)
32 42
33 def testFactoryWithBranch(self): 43 def testWithoutAppVersion(self):
34 store = ObjectStoreCreator.Factory('3-0', 'dev').Create( 44 store = self._creator.Create(_FooClass, app_version=None)
35 _FooClass, store_type=TestObjectStore).Create() 45 self.assertEqual('class=_FooClass&channel=trunk', store.namespace)
36 self.assertEqual('3-0/_FooClass@dev', store.namespace) 46 self.assertFalse(store.start_empty)
47
48 def testStartConfiguration(self):
49 store = self._creator.Create(_FooClass, start_empty=True)
50 self.assertTrue(store.start_empty)
51 store = self._creator.Create(_FooClass, start_empty=False)
52 self.assertFalse(store.start_empty)
53 self.assertRaises(ValueError, ObjectStoreCreator, 'foo')
54
55 def testIllegalCharacters(self):
56 self.assertRaises(ValueError,
57 self._creator.Create, _FooClass, channel='foo=')
58 self.assertRaises(ValueError,
59 self._creator.Create, _FooClass, app_version='1&2')
60 self.assertRaises(ValueError,
61 self._creator.Create, _FooClass, category='a=&b')
37 62
38 if __name__ == '__main__': 63 if __name__ == '__main__':
39 unittest.main() 64 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698