Пример #1
0
    def test_delete_entities(self):
        entity_proto1 = self.get_new_entity_proto("test",
                                                  "test_kind",
                                                  "bob",
                                                  "prop1name",
                                                  "prop1val",
                                                  ns="blah")
        row_key = "test/blah/test_kind:bob!"
        row_values = {
            row_key: {
                APP_ENTITY_SCHEMA[0]: entity_proto1.Encode(),
                APP_ENTITY_SCHEMA[1]: '1'
            }
        }

        zookeeper = flexmock()
        zookeeper.should_receive("get_valid_transaction_id").and_return(1)
        zookeeper.should_receive("register_updated_key").and_return(1)
        db_batch = flexmock()
        db_batch.should_receive("batch_put_entity").and_return(None)
        db_batch.should_receive("batch_get_entity").and_return(row_values)
        db_batch.should_receive("batch_delete").and_return(None)

        dd = DatastoreDistributed(db_batch, zookeeper)

        row_keys = [entity_proto1.key()]
        txn_hash = {row_key: 2}
        dd.delete_entities('test', row_keys, txn_hash, soft_delete=True)
Пример #2
0
  def test_delete_entities(self):
    entity_proto1 = self.get_new_entity_proto("test", "test_kind", "bob", "prop1name", 
                                              "prop1val", ns="blah")
    row_key = "test\x00blah\x00test_kind:bob\x01"
    row_values = {row_key:{APP_ENTITY_SCHEMA[0]: entity_proto1.Encode(),
                         APP_ENTITY_SCHEMA[1]: '1'}}

    zookeeper = flexmock()
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("register_updated_key").and_return(1)
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive("batch_get_entity").and_return(row_values)
    db_batch.should_receive('batch_mutate')

    dd = DatastoreDistributed(db_batch, zookeeper) 

    row_keys = [entity_proto1.key()]
    dd.delete_entities(row_keys)
  def test_delete_entities(self):
    entity_proto1 = self.get_new_entity_proto("test", "test_kind", "bob", "prop1name", 
                                              "prop1val", ns="blah")
    row_key = "test\x00blah\x00test_kind:bob!"
    row_values = {row_key:{APP_ENTITY_SCHEMA[0]: entity_proto1.Encode(),
                         APP_ENTITY_SCHEMA[1]: '1'}}

    zookeeper = flexmock()
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("register_updated_key").and_return(1)
    db_batch = flexmock()
    db_batch.should_receive("batch_put_entity").and_return(None)
    db_batch.should_receive("batch_get_entity").and_return(row_values)
    db_batch.should_receive("batch_delete").and_return(None)

    dd = DatastoreDistributed(db_batch, zookeeper) 

    row_keys = [entity_proto1.key()]
    txn_hash = {row_key: 2}
    dd.delete_entities('test', row_keys, txn_hash, soft_delete=True)