'Same test as DCAwareRoundRobinPolicyTest.test_get_distance()
Except a FakeCluster is needed for the metadata variable and
policy.child_policy is needed to change child policy settings'

def test_get_distance(self):

    policy = TokenAwarePolicy(DCAwareRoundRobinPolicy('dc1', used_hosts_per_remote_dc=0))
    host = Host('ip1', SimpleConvictionPolicy)
    host.set_location_info('dc1', 'rack1')
    policy.populate(self.FakeCluster(), [host])
    self.assertEqual(policy.distance(host), HostDistance.LOCAL)
    remote_host = Host('ip2', SimpleConvictionPolicy)
    remote_host.set_location_info('dc2', 'rack1')
    self.assertEqual(policy.distance(remote_host), HostDistance.IGNORED)
    policy._child_policy.used_hosts_per_remote_dc = 1
    self.assertEqual(policy.distance(remote_host), HostDistance.IGNORED)
    policy.populate(self.FakeCluster(), [host, remote_host])
    self.assertEqual(policy.distance(remote_host), HostDistance.REMOTE)
    second_remote_host = Host('ip3', SimpleConvictionPolicy)
    second_remote_host.set_location_info('dc2', 'rack1')
    policy.populate(self.FakeCluster(), [host, remote_host, second_remote_host])
    distances = set([policy.distance(remote_host), policy.distance(second_remote_host)])
    self.assertEqual(distances, set([HostDistance.REMOTE, HostDistance.IGNORED]))
