def test_statement_timeout(self):
        valid_inputs = [-1, 0, 15, 1.5]

        for valid in valid_inputs:
            statement = SqlStatement("sql")
            statement.timeout = valid
            self.assertEqual(valid, statement.timeout)

        invalid_inputs = [-10, -100, "hey", None]

        for invalid in invalid_inputs:
            statement = SqlStatement("sql")
            with self.assertRaises((ValueError, AssertionError)):
                statement.timeout = invalid
    def test_execute_statement_with_timeout(self):
        entry_count = 100
        self._populate_map(entry_count, lambda v: Student(v, v))
        statement = SqlStatement("SELECT age FROM %s WHERE height < 10" %
                                 self.map_name)
        statement.timeout = 100
        result = self.client.sql.execute_statement(statement)

        six.assertCountEqual(self, [i for i in range(10)],
                             [row.get_object("age") for row in result])
        # Get the index of the is_active column
        is_active_index = row_metadata.find_column("is_active")

        # Get the object with the column index
        is_active = row.get_object_with_index(is_active_index)

        print(name, age, is_active)

# Construct a statement object to control the properties of the query
# Special keywords __key and this can be used to refer to key and value.
# Also, a placeholder parameters can be specified
statement = SqlStatement("SELECT __key, age FROM customers WHERE name LIKE ?")

# Parameters will replace the placeholders on the server side
statement.add_parameter("Jo%")
statement.timeout = 5

with client.sql.execute_statement(statement) as result:
    # Row metadata can also be retrieved from the result
    row_metadata = result.get_row_metadata().result()

    for row in result:
        key = row.get_object("__key")
        age = row.get_object("age")

        print(key, age)

# Parameters can be passed directly in the basic execution syntax
result = client.sql.execute(
    "SELECT this FROM customers WHERE age > ? AND age < ?", 30, 40)