def test_nonode_callback(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath', nonode_callback=lambda: ('default', 10)) rst, ver = v.get() self.assertEqual(('default', 10), (rst, ver))
def test_safe_delete(self): kv = zktx.ZKValue(self.zk, get_path=lambda: 'foo') kv.create('1') kv.delete() self.assertRaises(NoNodeError, kv.get) kv.safe_delete()
def test_set_or_create_acl(self): v = zktx.ZKValue(self.zkauthed, get_path=lambda: 'taclvalue') # create v.set_or_create('1') acl, _ = self.zkauthed.get_acls('taclvalue') self.assertEqual(acl, self.zkauthed._zkconf.kazoo_digest_acl())
def test_load(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath', load=lambda v: '(' + v + ')') self.zk.create('foopath', '1') rst, ver = v.get() self.assertEqual('(1)', rst)
def test_dump(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath', dump=lambda v: '(' + v + ')') v.create('1') rst, ver = self.zk.get('foopath') self.assertEqual('(1)', rst) v.set('2') rst, ver = self.zk.get('foopath') self.assertEqual('(2)', rst)
def test_version(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath') self.zk.create('foopath', '1') v.set('2', version=0) rst, ver = v.get() self.assertEqual('2', rst) self.assertRaises(BadVersionError, v.set, '2', version=0) self.assertRaises(BadVersionError, v.set, '2', version=2) self.assertRaises(BadVersionError, v.delete, version=0) self.assertRaises(BadVersionError, v.delete, version=2) v.delete()
def test_get_path(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath') v.create('1') rst, ver = self.zk.get('foopath') self.assertEqual('1', rst) rst, ver = v.get() self.assertEqual('1', rst) v.set('2') rst, ver = v.get() self.assertEqual('2', rst) v.delete() self.assertRaises(NoNodeError, v.get)
def test_set_or_create(self): v = zktx.ZKValue(self.zk, get_path=lambda: 'foopath') # create v.set_or_create('1') rst, ver = v.get() self.assertEqual('1', rst) self.assertEqual(0, ver) # set self.assertRaises(BadVersionError, v.set_or_create, '2', version=2) v.set_or_create('2', version=0) v.set_or_create('2', version=1) rst, ver = v.get() self.assertEqual('2', rst) self.assertEqual(2, ver)