'Test setting availability_zone correctly during volume create.'

@mock.patch.object(cinder.volume.api.API, 'list_availability_zones')
def test_create_volume_uses_default_availability_zone(self, mock_list_az):

    mock_list_az.return_value = ({'name': 'az1', 'available': True}, {'name': 'az2', 'available': True}, {'name': 'default-az', 'available': True})
    volume_api = cinder.volume.api.API()
    self.override_config('storage_availability_zone', 'az2')
    volume = volume_api.create(self.context, 1, 'name', 'description')
    self.assertEqual('az2', volume['availability_zone'])
    self.override_config('default_availability_zone', 'default-az')
    volume = volume_api.create(self.context, 1, 'name', 'description')
    self.assertEqual('default-az', volume['availability_zone'])
