'test for synchronously refreshing UDF metadata in keyspace
test_refresh_user_function_metadata tests that UDF metadata in a keyspace is refreshed when calling
refresh_user_function_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
UDF, using the first cluster object, and verifies that the UDF metadata has not changed in the second cluster
object. Finally, it calls refresh_user_function_metadata() and verifies that the UDF metadata in the keyspace
is updated in the second cluster object.
@since 2.6.0
@jira_ticket PYTHON-291
@expected_result UDF metadata in the keyspace should be refreshed when refresh_user_function_metadata() is called.
@test_category metadata'

def test_refresh_user_function_metadata(self):

    if (PROTOCOL_VERSION < 4):
        raise unittest.SkipTest('Protocol    4+    is    required    for    UDFs,    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].functions, {})
    self.session.execute("CREATE    FUNCTION    {0}.sum_int(key    int,    val    int)\n                                                                                                                RETURNS    NULL    ON    NULL    INPUT\n                                                                                                                RETURNS    int\n                                                                                                                LANGUAGE    javascript    AS    'key    +    val';".format(self.keyspace_name))
    self.assertEqual(cluster2.metadata.keyspaces[self.keyspace_name].functions, {})
    cluster2.refresh_user_function_metadata(self.keyspace_name, UserFunctionDescriptor('sum_int', ['int', 'int']))
    self.assertIn('sum_int(int,int)', cluster2.metadata.keyspaces[self.keyspace_name].functions)
    cluster2.shutdown()
