コード例 #1
0
  def test_remove_exists_filters(self):
    zk_client = flexmock()
    zk_client.should_receive('add_listener')

    zookeeper = flexmock(handle=zk_client)
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("acquire_lock").and_return(True)
    zookeeper.should_receive("release_lock").and_return(True)
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive("batch_delete").and_return(None)
    db_batch.should_receive("batch_put_entity").and_return(None)
    db_batch.should_receive("batch_get_entity").and_return(None)

    transaction_manager = flexmock()
    dd = DatastoreDistributed(db_batch, transaction_manager, zookeeper)
    self.assertEquals(dd.remove_exists_filters({}), {})

    filter_info = {"prop1":[(datastore_pb.Query_Filter.EQUAL, "1")],
      "prop2": [(datastore_pb.Query_Filter.EQUAL, "2")]}
    self.assertEquals(dd.remove_exists_filters(filter_info), filter_info)

    filter_info = {"prop1":[(datastore_pb.Query_Filter.EXISTS, "1")],
      "prop2": [(datastore_pb.Query_Filter.EXISTS, "2")]}
    self.assertEquals(dd.remove_exists_filters(filter_info), {})
コード例 #2
0
  def test_remove_exists_filters(self):
    zk_client = flexmock()
    zk_client.should_receive('add_listener')

    zookeeper = flexmock(handle=zk_client)
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version_sync').and_return(True)

    transaction_manager = flexmock()
    dd = DatastoreDistributed(db_batch, transaction_manager, zookeeper)
    self.assertEquals(dd.remove_exists_filters({}), {})

    filter_info = {
      "prop1": [(datastore_pb.Query_Filter.EQUAL, "1")],
      "prop2": [(datastore_pb.Query_Filter.EQUAL, "2")]
    }
    self.assertEquals(dd.remove_exists_filters(filter_info), filter_info)

    filter_info = {
      "prop1": [(datastore_pb.Query_Filter.EXISTS, "1")],
      "prop2": [(datastore_pb.Query_Filter.EXISTS, "2")]
    }
    self.assertEquals(dd.remove_exists_filters(filter_info), {})
コード例 #3
0
  def test_remove_exists_filters(self):
    zookeeper = flexmock()
    zookeeper.should_receive("get_transaction_id").and_return(1)
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("register_updated_key").and_return(1)
    zookeeper.should_receive("acquire_lock").and_return(True)
    zookeeper.should_receive("release_lock").and_return(True)
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive("batch_delete").and_return(None)
    db_batch.should_receive("batch_put_entity").and_return(None)
    db_batch.should_receive("batch_get_entity").and_return(None)

    dd = DatastoreDistributed(db_batch, zookeeper)
    self.assertEquals(dd.remove_exists_filters({}), {})

    filter_info = {"prop1":[(datastore_pb.Query_Filter.EQUAL, "1")],
      "prop2": [(datastore_pb.Query_Filter.EQUAL, "2")]}
    self.assertEquals(dd.remove_exists_filters(filter_info), filter_info)

    filter_info = {"prop1":[(datastore_pb.Query_Filter.EXISTS, "1")],
      "prop2": [(datastore_pb.Query_Filter.EXISTS, "2")]}
    self.assertEquals(dd.remove_exists_filters(filter_info), {})