def test_acquire_additional_lock(self):
    # mock out waitForConnect
    flexmock(zk.ZKTransaction)
    zk.ZKTransaction.should_receive('check_transaction')
    zk.ZKTransaction.should_receive('get_transaction_path').\
       and_return('/txn/path')
    zk.ZKTransaction.should_receive('get_lock_root_path').\
       and_return('/lock/root/path')
    zk.ZKTransaction.should_receive('get_transaction_prefix_path').\
       and_return('/rootpath/' + self.appid)

    fake_zookeeper = flexmock(name='fake_zoo', create='create',
      create_async='create_async', get='get', set_async='set_async',
      connected=lambda: True)
    fake_zookeeper.should_receive('start')
    fake_zookeeper.should_receive('retry').with_args('create', str, makepath=bool, sequence=bool,
      ephemeral=bool, value=str, acl=None).and_return("/some/lock/path")
    fake_zookeeper.should_receive('retry').with_args('create_async', str, value=str,
      acl=None, ephemeral=bool, makepath=bool, sequence=bool)
    fake_zookeeper.should_receive('retry').with_args('create_async', str, value=str,
      acl=str, ephemeral=bool, makepath=bool, sequence=bool)
    lock_list = ['path1', 'path2', 'path3'] 
    lock_list_str = zk.LOCK_LIST_SEPARATOR.join(lock_list)
    fake_zookeeper.should_receive('retry').with_args('get', str) \
      .and_return([lock_list_str])
    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.acquire_additional_lock(self.appid,
      "txid", "somekey", False))

    # Test for when we want to create a new ZK node for the lock path
    self.assertEquals(True, transaction.acquire_additional_lock(self.appid,
      "txid", "somekey", True))

    # Test for existing max groups
    lock_list = ['path' + str(num/1) for num in range(zk.MAX_GROUPS_FOR_XG)]
    lock_list_str = zk.LOCK_LIST_SEPARATOR.join(lock_list)
    fake_zookeeper.should_receive('retry').with_args('get', str) \
      .and_return([lock_list_str])

    transaction = zk.ZKTransaction(host="something", start_gc=False)
    self.assertRaises(zk.ZKTransactionException,
      transaction.acquire_additional_lock, self.appid, "txid", "somekey", False)

    # Test for when there is a node which already exists.
    fake_zookeeper.should_receive('retry').with_args('create', str, str, None,
      bool, bool, bool).and_raise(kazoo.exceptions.NodeExistsError)
    transaction = zk.ZKTransaction(host="something", start_gc=False)
    self.assertRaises(zk.ZKTransactionException,
      transaction.acquire_additional_lock, self.appid, "txid", "somekey", False)
dataset/ETHPy150Open AppScale/appscale/AppDB/test/unit/test_zookeeper.py/TestZookeeperTransaction.test_acquire_additional_lock/operator `+` -> `/`