'Test for inserting various types of nested COLLECTION_TYPES into tables and UDTs'

def test_can_insert_nested_collections(self):

    if (self.cass_version < (2, 1, 3)):
        raise unittest.SkipTest('Support    for    nested    collections    was    introduced    in    Cassandra    2.1.3')
    c = Cluster(protocol_version=PROTOCOL_VERSION)
    s = c.connect(self.keyspace_name, wait_for_all_pools=True)
    s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple
    name = self._testMethodName
    s.execute(('\n                                                CREATE    TYPE    %s    (\n                                                                m    frozen<map<int,text>>,\n                                                                t    tuple<int,text>,\n                                                                l    frozen<list<int>>,\n                                                                s    frozen<set<int>>\n                                                )' % name))
    s.execute(('\n                                                CREATE    TYPE    %s_nested    (\n                                                                m    frozen<map<int,text>>,\n                                                                t    tuple<int,text>,\n                                                                l    frozen<list<int>>,\n                                                                s    frozen<set<int>>,\n                                                                u    frozen<%s>\n                                                )' % (name, name)))
    s.execute(('\n                                                CREATE    TABLE    %s    (\n                                                                k    int    PRIMARY    KEY,\n                                                                map_map    map<frozen<map<int,int>>,    frozen<map<int,int>>>,\n                                                                map_set    map<frozen<set<int>>,    frozen<set<int>>>,\n                                                                map_list    map<frozen<list<int>>,    frozen<list<int>>>,\n                                                                map_tuple    map<frozen<tuple<int,    int>>,    frozen<tuple<int>>>,\n                                                                map_udt    map<frozen<%s_nested>,    frozen<%s>>,\n                                                )' % (name, name, name)))
    validate = partial(self.insert_select_column, s, name)
    validate('map_map', OrderedMap([({1: 1, 2: 2}, {3: 3, 4: 4}), ({5: 5, 6: 6}, {7: 7, 8: 8})]))
    validate('map_set', OrderedMap([(set((1, 2)), set((3, 4))), (set((5, 6)), set((7, 8)))]))
    validate('map_list', OrderedMap([([1, 2], [3, 4]), ([5, 6], [7, 8])]))
    validate('map_tuple', OrderedMap([((1, 2), (3,)), ((4, 5), (6,))]))
    value = nested_collection_udt({1: 'v1', 2: 'v2'}, (3, 'v3'), [4, 5, 6, 7], set((8, 9, 10)))
    key = nested_collection_udt_nested(value.m, value.t, value.l, value.s, value)
    key2 = nested_collection_udt_nested({3: 'v3'}, value.t, value.l, value.s, value)
    validate('map_udt', OrderedMap([(key, value), (key2, value)]))
    c.shutdown()
