

def test_register_updated_key(self):
    flexmock(zk.ZKTransaction)
    zk.ZKTransaction.should_receive('get_valid_transaction_path').and_return('/txn/path')
    zk.ZKTransaction.should_receive('get_transaction_path').and_return('/txn/path')
    zk.ZKTransaction.should_receive('get_blacklist_root_path').and_return('bl_root_path')
    fake_zookeeper = flexmock(name='fake_zoo', exists='exists', set_async='set_async', connected=(lambda : True))
    fake_zookeeper.should_receive('start')
    fake_zookeeper.should_receive('retry').with_args('exists', str).and_return(True)
    fake_zookeeper.should_receive('retry').with_args('set_async', str, str)
    flexmock(kazoo.client)
    kazoo.client.should_receive('KazooClient').and_return(fake_zookeeper)
    transaction = zk.ZKTransaction(host='something', start_gc=False)
    self.assertEquals(True, transaction.register_updated_key(self.appid, '1', '2', 'somekey'))
    fake_zookeeper.should_receive('retry').with_args('exists', str).and_return(False)
    self.assertRaises(ZKTransactionException, transaction.register_updated_key, self.appid, '1', '2', 'somekey')

dataset/ETHPy150Open AppScale/appscale/AppDB/test/unit/test_zookeeper.py TestZookeeperTransaction.test_register_updated_key/original