cinder/cinder/tests/unit/test_interface.py
Gorka Eguileor 2f0bd74604 Fix get_driver_options
Any new Cinder driver we add that doesn't have the "get_driver_options"
method defined will break the driver list generation tools.

The reason why it breaks them is because this method must be static, yet
our base driver class doesn't define it as static.

This patch:

- Sets the base method as static to prevent new drivers from breaking
  the tools.

- Documents the existence of this method for driver developers.

- Adds get_driver_options method for drivers that are missing it.

- Fix macrosan_client help message that breaks the doc building process.

Closes-Bug: #1838225
Change-Id: I4797724d7b55709f0903d522b0233242b867146d
2019-07-31 20:24:52 +02:00

60 lines
2.3 KiB
Python

# Copyright (c) 2019, Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from cinder.interface import util
from cinder import test
class GetDriversTestCase(test.TestCase):
def test_get_volume_drivers(self):
# Just ensure that it doesn't raise an exception
drivers = util.get_volume_drivers()
self.assertNotEqual(0, len(drivers))
for driver in drivers:
self.assertIsInstance(driver, util.DriverInfo)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.get_driver_options')
def test_get_volume_drivers_fail(self, driver_opt):
driver_opt.side_effect = ValueError
self.assertRaises(ValueError, util.get_volume_drivers)
def test_get_backup_drivers(self):
# Just ensure that it doesn't raise an exception
drivers = util.get_backup_drivers()
self.assertNotEqual(0, len(drivers))
for driver in drivers:
self.assertIsInstance(driver, util.DriverInfo)
@mock.patch('cinder.backup.drivers.ceph.CephBackupDriver.'
'get_driver_options')
def test_get_backup_drivers_fail(self, driver_opt):
driver_opt.side_effect = ValueError
self.assertRaises(ValueError, util.get_backup_drivers)
def test_get_fczm_drivers(self):
# Just ensure that it doesn't raise an exception
drivers = util.get_fczm_drivers()
self.assertNotEqual(0, len(drivers))
for driver in drivers:
self.assertIsInstance(driver, util.DriverInfo)
@mock.patch('cinder.zonemanager.drivers.cisco.cisco_fc_zone_driver.'
'CiscoFCZoneDriver.get_driver_options')
def test_get_fczm_drivers_fail(self, driver_opt):
driver_opt.side_effect = ValueError
self.assertRaises(ValueError, util.get_fczm_drivers)