'Test for inserting various types of COLLECTION_TYPES into UDT\'s'

def test_can_insert_udt_all_collection_datatypes(self):

    c = Cluster(protocol_version=PROTOCOL_VERSION)
    s = c.connect(self.keyspace_name, wait_for_all_pools=True)
    alpha_type_list = []
    start_index = ord('a')
    for (i, collection_type) in enumerate(COLLECTION_TYPES):
        for (j, datatype) in enumerate(PRIMITIVE_DATATYPES_KEYS):
            if (collection_type == 'map'):
                type_string = '{0}_{1}    {2}<{3},    {3}>'.format(chr((start_index + i)), chr((start_index + j)), collection_type, datatype)
            elif (collection_type == 'tuple'):
                type_string = '{0}_{1}    frozen<{2}<{3}>>'.format(chr((start_index + i)), chr((start_index + j)), collection_type, datatype)
            else:
                type_string = '{0}_{1}    {2}<{3}>'.format(chr((start_index + i)), chr((start_index + j)), collection_type, datatype)
            alpha_type_list.append(type_string)
    s.execute('\n                                                CREATE    TYPE    alldatatypes    ({0})\n                                '.format(',    '.join(alpha_type_list)))
    s.execute('CREATE    TABLE    mytable    (a    int    PRIMARY    KEY,    b    frozen<alldatatypes>)')
    alphabet_list = []
    for i in range(ord('a'), (ord('a') + len(COLLECTION_TYPES))):
        for j in range(ord('a'), (ord('a') + len(PRIMITIVE_DATATYPES_KEYS))):
            alphabet_list.append('{0}_{1}'.format(chr(i), chr(j)))
    Alldatatypes = namedtuple('alldatatypes', alphabet_list)
    c.register_user_type(self.keyspace_name, 'alldatatypes', Alldatatypes)
    params = []
    for collection_type in COLLECTION_TYPES:
        for datatype in PRIMITIVE_DATATYPES_KEYS:
            params.append(get_collection_sample(collection_type, datatype))
    insert = s.prepare('INSERT    INTO    mytable    (a,    b)    VALUES    (?,    ?)')
    s.execute(insert, (0, Alldatatypes(*params)))
    results = s.execute('SELECT    *    FROM    mytable')
    row = results[0].b
    for (expected, actual) in zip(params, row):
        self.assertEqual(expected, actual)
    c.shutdown()
