Esempio n. 1
0
class ObjectStoreCreatorTest(unittest.TestCase):
    def setUp(self):
        self.creator = ObjectStoreCreator(_FooClass,
                                          '3-0',
                                          'test',
                                          store_type=TestObjectStore)

    def testVanilla(self):
        store = self.creator.Create()
        self.assertEqual('3-0/_FooClass@test', store.namespace)

    def testWithCategory(self):
        store = self.creator.Create(category='cat')
        self.assertEqual('3-0/_FooClass@test/cat', store.namespace)

    def testIllegalInput(self):
        self.assertRaises(AssertionError, self.creator.Create, category='5')
        self.assertRaises(AssertionError,
                          self.creator.Create,
                          category='forty2')

    def testFactoryWithBranch(self):
        store = ObjectStoreCreator.Factory('3-0', 'dev').Create(
            _FooClass, store_type=TestObjectStore).Create()
        self.assertEqual('3-0/_FooClass@dev', store.namespace)
Esempio n. 2
0
class ObjectStoreCreatorTest(unittest.TestCase):
  def setUp(self):
    self.creator = ObjectStoreCreator(_FooClass, store_type=TestObjectStore)

  def testVanilla(self):
    store = self.creator.Create()
    self.assertEqual('_FooClass', store.namespace)

  def testWithVersion(self):
    store = self.creator.Create(version=42)
    self.assertEqual('_FooClass/42', store.namespace)

  def testWithCategory(self):
    store = self.creator.Create(category='cat')
    self.assertEqual('_FooClass/cat', store.namespace)

  def testWithVersionAndCategory(self):
    store = self.creator.Create(version=43, category='mat')
    self.assertEqual('_FooClass/mat/43', store.namespace)

  def testIllegalIinput(self):
    self.assertRaises(AssertionError, self.creator.Create, category='5')
    self.assertRaises(AssertionError, self.creator.Create, category='forty2')
    self.assertRaises(AssertionError, self.creator.Create, version='twenty')
    self.assertRaises(AssertionError, self.creator.Create, version='7a')

  def testFactoryWithBranch(self):
    store = ObjectStoreCreator.Factory().Create(
        _FooClass, store_type=TestObjectStore).Create()
    self.assertEqual('_FooClass', store.namespace)
    store = ObjectStoreCreator.Factory(branch='dev').Create(
        _FooClass, store_type=TestObjectStore).Create()
    self.assertEqual('_FooClass@dev', store.namespace)
Esempio n. 3
0
class ObjectStoreCreatorTest(unittest.TestCase):
    def setUp(self):
        self._creator = ObjectStoreCreator(start_empty=False,
                                           store_type=TestObjectStore,
                                           disable_wrappers=True)

    def testVanilla(self):
        store = self._creator.Create(_FooClass)
        self.assertEqual('class=_FooClass&app_version=%s' % GetAppVersion(),
                         store.namespace)
        self.assertFalse(store.start_empty)

    def testWithCategory(self):
        store = self._creator.Create(_FooClass, category='hi')
        self.assertEqual(
            'class=_FooClass&category=hi&app_version=%s' % GetAppVersion(),
            store.namespace)
        self.assertFalse(store.start_empty)

    def testWithoutAppVersion(self):
        store = self._creator.Create(_FooClass, app_version=None)
        self.assertEqual('class=_FooClass', store.namespace)
        self.assertFalse(store.start_empty)

    def testStartConfiguration(self):
        store = self._creator.Create(_FooClass, start_empty=True)
        self.assertTrue(store.start_empty)
        store = self._creator.Create(_FooClass, start_empty=False)
        self.assertFalse(store.start_empty)
        self.assertRaises(ValueError, ObjectStoreCreator)

    def testIllegalCharacters(self):
        self.assertRaises(ValueError,
                          self._creator.Create,
                          _FooClass,
                          app_version='1&2')
        self.assertRaises(ValueError,
                          self._creator.Create,
                          _FooClass,
                          category='a=&b')