'Test to insure that protocol v1/v2 surface UDT metadata changes
@since 3.7.0
@jira_ticket PYTHON-106
@expected_result UDT metadata in the keyspace should be updated regardless of protocol version
@test_category metadata'

def test_refresh_user_type_metadata_proto_2(self):

    supported_versions = get_supported_protocol_versions()
    if ((2 not in supported_versions) or (CASSANDRA_VERSION < '2.1')):
        raise unittest.SkipTest('Protocol    versions    1    and    2    are    not    supported    in    Cassandra    version    '.format(CASSANDRA_VERSION))
    for protocol_version in (1, 2):
        cluster = Cluster(protocol_version=protocol_version)
        session = cluster.connect()
        self.assertEqual(cluster.metadata.keyspaces[self.keyspace_name].user_types, {})
        session.execute('CREATE    TYPE    {0}.user    (age    int,    name    text)'.format(self.keyspace_name))
        self.assertIn('user', cluster.metadata.keyspaces[self.keyspace_name].user_types)
        self.assertIn('age', cluster.metadata.keyspaces[self.keyspace_name].user_types['user'].field_names)
        self.assertIn('name', cluster.metadata.keyspaces[self.keyspace_name].user_types['user'].field_names)
        session.execute('ALTER    TYPE    {0}.user    ADD    flag    boolean'.format(self.keyspace_name))
        self.assertIn('flag', cluster.metadata.keyspaces[self.keyspace_name].user_types['user'].field_names)
        session.execute('ALTER    TYPE    {0}.user    RENAME    flag    TO    something'.format(self.keyspace_name))
        self.assertIn('something', cluster.metadata.keyspaces[self.keyspace_name].user_types['user'].field_names)
        session.execute('DROP    TYPE    {0}.user'.format(self.keyspace_name))
        self.assertEqual(cluster.metadata.keyspaces[self.keyspace_name].user_types, {})
        cluster.shutdown()
