def test_create_table(self): # Setup Expected Response name = "name3373707" expected_response = {"name": name} expected_response = table_pb2.Table(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = bigtable_admin_v2.BigtableTableAdminClient() # Setup Request parent = client.instance_path("[PROJECT]", "[INSTANCE]") table_id = "tableId-895419604" table = {} response = client.create_table(parent, table_id, table) assert expected_response == response assert len(channel.requests) == 1 expected_request = bigtable_table_admin_pb2.CreateTableRequest( parent=parent, table_id=table_id, table=table) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_table(self): # Setup Expected Response name = 'name3373707' expected_response = {'name': name} expected_response = table_pb2.Table(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = bigtable_admin_v2.BigtableTableAdminClient(channel=channel) # Setup Request parent = client.instance_path('[PROJECT]', '[INSTANCE]') table_id = 'tableId-895419604' table = {} response = client.create_table(parent, table_id, table) assert expected_response == response assert len(channel.requests) == 1 expected_request = bigtable_table_admin_pb2.CreateTableRequest( parent=parent, table_id=table_id, table=table) actual_request = channel.requests[0][1] assert expected_request == actual_request