'Test to validate hostfilter reacts correctly when the predicate return
a different subset of the hosts
HostFilterPolicy
@since 3.8
@jira_ticket PYTHON-961
@expected_result the excluded hosts are ignored
@test_category policy'

def test_predicate_changes(self):

    external_event = True
    contact_point = '127.0.0.1'
    single_host = {Host(contact_point, SimpleConvictionPolicy)}
    all_hosts = {Host('127.0.0.{}'.format(i), SimpleConvictionPolicy) for i in (1, 2, 3)}
    predicate = (lambda host: ((host.address == contact_point) if external_event else True))
    cluster = Cluster((contact_point,), load_balancing_policy=HostFilterPolicy(RoundRobinPolicy(), predicate=predicate), protocol_version=PROTOCOL_VERSION, topology_event_refresh_window=0, status_event_refresh_window=0)
    session = cluster.connect(wait_for_all_pools=True)
    queried_hosts = set()
    for _ in range(10):
        response = session.execute('SELECT    *    from    system.local')
        queried_hosts.update(response.response_future.attempted_hosts)
    self.assertEqual(queried_hosts, single_host)
    external_event = False
    futures = session.update_created_pools()
    wait_futures(futures, timeout=cluster.connect_timeout)
    queried_hosts = set()
    for _ in range(10):
        response = session.execute('SELECT    *    from    system.local')
        queried_hosts.update(response.response_future.attempted_hosts)
    self.assertEqual(queried_hosts, all_hosts)
