

def test_get_transaction_id(self):
    flexmock(zk.ZKTransaction)
    zk.ZKTransaction.should_receive('get_transaction_prefix_path').with_args(self.appid).and_return(('/rootpath/' + self.appid))
    path_to_create = ((('/rootpath/' + self.appid) + '/') + zk.APP_TX_PREFIX)
    zk.ZKTransaction.should_receive('get_txn_path_before_getting_id').with_args(self.appid).and_return(path_to_create)
    flexmock(time)
    time.should_receive('time').and_return(1000)
    fake_zookeeper = flexmock(name='fake_zoo', connected=(lambda : True))
    fake_zookeeper.should_receive('start')
    fake_zookeeper.should_receive('retry')
    flexmock(kazoo.client)
    kazoo.client.should_receive('KazooClient').and_return(fake_zookeeper)
    zk.ZKTransaction.should_receive('create_sequence_node').with_args(path_to_create, '1000').and_return(1)
    xg_path = ((path_to_create + '/1/') + zk.XG_PREFIX)
    zk.ZKTransaction.should_receive('get_xg_path').and_return(xg_path)
    zk.ZKTransaction.should_receive('create_node').with_args(xg_path, '1000')
    transaction = zk.ZKTransaction(host='something', start_gc=False)
    self.assertEquals(1, transaction.get_transaction_id(self.appid, is_xg=True))

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