'Test get_availability_zones.'

def test_get_availability_zones(self):

    agg2 = self._create_az('agg-az2', 'nova-test2')
    agg3 = self._create_az('agg-az3', 'nova-test3')
    service1 = self._create_service_with_topic('compute', 'host1', disabled=False)
    service2 = self._create_service_with_topic('compute', 'host2', disabled=True)
    service3 = self._create_service_with_topic('compute', 'host3', disabled=False)
    service4 = self._create_service_with_topic('compute', 'host4', disabled=True)
    self._create_service_with_topic('compute', 'host5', disabled=True)
    self._add_to_aggregate(service1, self.agg)
    self._add_to_aggregate(service2, self.agg)
    self._add_to_aggregate(service3, agg2)
    self._add_to_aggregate(service4, agg3)
    (zones, not_zones) = az.get_availability_zones(self.context)
    self.assertEqual(['nova-test', 'nova-test2'], zones)
    self.assertEqual(['nova-test3', 'nova'], not_zones)
    zones = az.get_availability_zones(self.context, True)
    self.assertEqual(['nova-test', 'nova-test2'], zones)
    (zones, not_zones) = az.get_availability_zones(self.context, with_hosts=True)
    self.assertJsonEqual(zones, [(u'nova-test2', set([u'host3'])), (u'nova-test', set([u'host1']))])
    self.assertJsonEqual(not_zones, [(u'nova-test3', set([u'host4'])), (u'nova', set([u'host5']))])
