예제 #1
0
 def delete(self):
     """Delete this column family."""
     request_pb = messages_pb2.DeleteColumnFamilyRequest(name=self.name)
     client = self._table._cluster._client
     # We expect a `google.protobuf.empty_pb2.Empty`
     client._table_stub.DeleteColumnFamily(request_pb,
                                           client.timeout_seconds)
예제 #2
0
    def test_delete(self):
        from gcloud.bigtable._generated import (
            bigtable_table_service_messages_pb2 as messages_pb2)
        from gcloud.bigtable._generated import empty_pb2
        from gcloud.bigtable._testing import _FakeStub

        project_id = 'project-id'
        zone = 'zone'
        cluster_id = 'cluster-id'
        table_id = 'table-id'
        column_family_id = 'column-family-id'
        timeout_seconds = 7
        table_name = ('projects/' + project_id + '/zones/' + zone +
                      '/clusters/' + cluster_id + '/tables/' + table_id)
        column_family_name = table_name + '/columnFamilies/' + column_family_id

        client = _Client(timeout_seconds=timeout_seconds)
        table = _Table(table_name, client=client)
        column_family = self._makeOne(column_family_id, table)

        # Create request_pb
        request_pb = messages_pb2.DeleteColumnFamilyRequest(
            name=column_family_name)

        # Create response_pb
        response_pb = empty_pb2.Empty()

        # Patch the stub used by the API method.
        client._table_stub = stub = _FakeStub(response_pb)

        # Create expected_result.
        expected_result = None  # delete() has no return value.

        # Perform the method and check the result.
        self.assertEqual(stub.results, (response_pb, ))
        result = column_family.delete()
        self.assertEqual(stub.results, ())
        self.assertEqual(result, expected_result)
        self.assertEqual(stub.method_calls, [(
            'DeleteColumnFamily',
            (request_pb, timeout_seconds),
            {},
        )])