'test for synchronously refreshing UDT metadata in keyspace
test_refresh_user_type_metadata tests that UDT metadata in a keyspace is refreshed when calling refresh_user_type_metadata().
It creates a second cluster object with schema_event_refresh_window=-1 such that schema refreshes are disabled
for schema change push events. It then alters the keyspace, creating a new UDT, using the first cluster
object, and verifies that the UDT metadata has not changed in the second cluster object. Finally, it calls
refresh_user_type_metadata() and verifies that the UDT metadata in the keyspace is updated in the second cluster object.
@since 2.6.0
@jira_ticket PYTHON-291
@expected_result UDT metadata in the keyspace should be refreshed when refresh_user_type_metadata() is called.
@test_category metadata'

def test_refresh_user_type_metadata(self):

    if (PROTOCOL_VERSION < 3):
        raise unittest.SkipTest('Protocol    3+    is    required    for    UDTs,    currently    testing    against    {0}'.format(PROTOCOL_VERSION))
    cluster2 = Cluster(protocol_version=PROTOCOL_VERSION, schema_event_refresh_window=(-1))
    cluster2.connect()
    self.assertEqual(cluster2.metadata.keyspaces[self.keyspace_name].user_types, {})
    self.session.execute('CREATE    TYPE    {0}.user    (age    int,    name    text)'.format(self.keyspace_name))
    self.assertEqual(cluster2.metadata.keyspaces[self.keyspace_name].user_types, {})
    cluster2.refresh_user_type_metadata(self.keyspace_name, 'user')
    self.assertIn('user', cluster2.metadata.keyspaces[self.keyspace_name].user_types)
    cluster2.shutdown()
