'Test insertion of all collection types'

def test_can_insert_collection_datatypes(self):

    c = Cluster(protocol_version=PROTOCOL_VERSION)
    s = c.connect(self.keyspace_name)
    s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple
    alpha_type_list = ['zz    int    PRIMARY    KEY']
    col_names = ['zz']
    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)
            col_names.append('{0}_{1}'.format(chr((start_index + i)), chr((start_index + j))))
    s.execute('CREATE    TABLE    allcoltypes    ({0})'.format(',    '.join(alpha_type_list)))
    columns_string = ',    '.join(col_names)
    params = [0]
    for collection_type in COLLECTION_TYPES:
        for datatype in PRIMITIVE_DATATYPES_KEYS:
            params.append(get_collection_sample(collection_type, datatype))
    placeholders = ',    '.join((['%s'] * len(col_names)))
    s.execute('INSERT    INTO    allcoltypes    ({0})    VALUES    ({1})'.format(columns_string, placeholders), params)
    results = s.execute('SELECT    {0}    FROM    allcoltypes    WHERE    zz=0'.format(columns_string))[0]
    for (expected, actual) in zip(params, results):
        self.assertEqual(actual, expected)
    params = [0]
    for collection_type in COLLECTION_TYPES:
        for datatype in PRIMITIVE_DATATYPES_KEYS:
            params.append(get_collection_sample(collection_type, datatype))
    placeholders = ','.join((['?'] * len(col_names)))
    insert = s.prepare('INSERT    INTO    allcoltypes    ({0})    VALUES    ({1})'.format(columns_string, placeholders))
    s.execute(insert.bind(params))
    results = s.execute('SELECT    {0}    FROM    allcoltypes    WHERE    zz=0'.format(columns_string))[0]
    for (expected, actual) in zip(params, results):
        self.assertEqual(actual, expected)
    select = s.prepare('SELECT    {0}    FROM    allcoltypes    WHERE    zz=?'.format(columns_string))
    results = s.execute(select.bind([0]))[0]
    for (expected, actual) in zip(params, results):
        self.assertEqual(actual, expected)
    s.row_factory = ordered_dict_factory
    select = s.prepare('SELECT    *    FROM    allcoltypes')
    results = s.execute(select)[0]
    for (expected, actual) in zip(params, results.values()):
        self.assertEqual(actual, expected)
    c.shutdown()
