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

def test_refresh_keyspace_metadata(self):

    cluster2 = Cluster(protocol_version=PROTOCOL_VERSION, schema_event_refresh_window=(-1))
    cluster2.connect()
    self.assertTrue(cluster2.metadata.keyspaces[self.keyspace_name].durable_writes)
    self.session.execute('ALTER    KEYSPACE    {0}    WITH    durable_writes    =    false'.format(self.keyspace_name))
    self.assertTrue(cluster2.metadata.keyspaces[self.keyspace_name].durable_writes)
    cluster2.refresh_keyspace_metadata(self.keyspace_name)
    self.assertFalse(cluster2.metadata.keyspaces[self.keyspace_name].durable_writes)
    cluster2.shutdown()
