'Ensure tuple subtypes are appropriately handled for maps, sets, and lists.'

def test_can_insert_tuples_all_collection_datatypes(self):

    if (self.cass_version < (2, 1, 0)):
        raise unittest.SkipTest('The    tuple    type    was    introduced    in    Cassandra    2.1')
    c = Cluster(protocol_version=PROTOCOL_VERSION)
    s = c.connect(self.keyspace_name)
    s.row_factory = dict_factory
    s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple
    values = []
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        values.append('v_{0}    frozen<tuple<list<{1}>>>'.format(len(values), datatype))
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        values.append('v_{0}    frozen<tuple<set<{1}>>>'.format(len(values), datatype))
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        datatype_1 = datatype_2 = datatype
        if (datatype == 'blob'):
            datatype_1 = 'ascii'
        values.append('v_{0}    frozen<tuple<map<{1},    {2}>>>'.format(len(values), datatype_1, datatype_2))
    if (set(COLLECTION_TYPES) != set(['tuple', 'list', 'map', 'set'])):
        raise NotImplemented('Missing    datatype    not    implemented:    {}'.format((set(COLLECTION_TYPES) - set(['tuple', 'list', 'map', 'set']))))
    s.execute(('CREATE    TABLE    tuple_non_primative    (k    int    PRIMARY    KEY,    %s)' % ',    '.join(values)))
    i = 0
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        created_tuple = tuple([[get_sample(datatype)]])
        s.execute('INSERT    INTO    tuple_non_primative    (k,    v_%s)    VALUES    (0,    %s)', (i, created_tuple))
        result = s.execute('SELECT    v_%s    FROM    tuple_non_primative    WHERE    k=0', (i,))[0]
        self.assertEqual(created_tuple, result[('v_%s' % i)])
        i += 1
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        created_tuple = tuple([sortedset([get_sample(datatype)])])
        s.execute('INSERT    INTO    tuple_non_primative    (k,    v_%s)    VALUES    (0,    %s)', (i, created_tuple))
        result = s.execute('SELECT    v_%s    FROM    tuple_non_primative    WHERE    k=0', (i,))[0]
        self.assertEqual(created_tuple, result[('v_%s' % i)])
        i += 1
    for datatype in PRIMITIVE_DATATYPES_KEYS:
        if (datatype == 'blob'):
            created_tuple = tuple([{get_sample('ascii'): get_sample(datatype)}])
        else:
            created_tuple = tuple([{get_sample(datatype): get_sample(datatype)}])
        s.execute('INSERT    INTO    tuple_non_primative    (k,    v_%s)    VALUES    (0,    %s)', (i, created_tuple))
        result = s.execute('SELECT    v_%s    FROM    tuple_non_primative    WHERE    k=0', (i,))[0]
        self.assertEqual(created_tuple, result[('v_%s' % i)])
        i += 1
    c.shutdown()
