'Test the insertion of prepared, registered UDTs'

def test_can_insert_prepared_registered_udts(self):

    c = Cluster(protocol_version=PROTOCOL_VERSION)
    s = c.connect(self.keyspace_name, wait_for_all_pools=True)
    s.execute('CREATE    TYPE    user    (age    int,    name    text)')
    User = namedtuple('user', ('age', 'name'))
    c.register_user_type(self.keyspace_name, 'user', User)
    s.execute('CREATE    TABLE    mytable    (a    int    PRIMARY    KEY,    b    frozen<user>)')
    insert = s.prepare('INSERT    INTO    mytable    (a,    b)    VALUES    (?,    ?)')
    s.execute(insert, (0, User(42, 'bob')))
    select = s.prepare('SELECT    b    FROM    mytable    WHERE    a=?')
    result = s.execute(select, (0,))
    row = result[0]
    self.assertEqual(42, row.b.age)
    self.assertEqual('bob', row.b.name)
    self.assertTrue((type(row.b) is User))
    s.execute("\n                                                CREATE    KEYSPACE    udt_test_prepared_registered2\n                                                WITH    replication    =    {    'class'    :    'SimpleStrategy',    'replication_factor':    '1'    }\n                                                ")
    s.set_keyspace('udt_test_prepared_registered2')
    s.execute('CREATE    TYPE    user    (state    text,    is_cool    boolean)')
    User = namedtuple('user', ('state', 'is_cool'))
    c.register_user_type('udt_test_prepared_registered2', 'user', User)
    s.execute('CREATE    TABLE    mytable    (a    int    PRIMARY    KEY,    b    frozen<user>)')
    insert = s.prepare('INSERT    INTO    mytable    (a,    b)    VALUES    (?,    ?)')
    s.execute(insert, (0, User('Texas', True)))
    select = s.prepare('SELECT    b    FROM    mytable    WHERE    a=?')
    result = s.execute(select, (0,))
    row = result[0]
    self.assertEqual('Texas', row.b.state)
    self.assertEqual(True, row.b.is_cool)
    self.assertTrue((type(row.b) is User))
    s.execute('DROP    KEYSPACE    udt_test_prepared_registered2')
    c.shutdown()
