Correct and optimize hpe3par tests
The volume_type_hos dict wasn't copied rather referenced by another variable in the tests that caused modifications in the original dict. This shouldn't be allowed in objects shared by multiple tests. This patch fixes it along with some minor updates as suggested in [1]. [1] Idda5512d8e35da401ee232524ec1d1fcd03bf9e2 Change-Id: Iba057bf5253b570582b029f2f2db3f9ddfc73dca
This commit is contained in:
parent
2c14226392
commit
5cf104546d
|
@ -14,9 +14,9 @@
|
|||
# under the License.
|
||||
"""Unit tests for OpenStack Cinder volume drivers."""
|
||||
|
||||
import mock
|
||||
|
||||
import ast
|
||||
import copy
|
||||
import mock
|
||||
|
||||
from oslo_utils import units
|
||||
|
||||
|
@ -3509,9 +3509,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
|
|||
# setup_mock_client drive with default configuration
|
||||
# and return the mock HTTP 3PAR client
|
||||
mock_client = self.setup_driver()
|
||||
volume_type_hos = self.volume_type_hos
|
||||
volume_type_hos['extra_specs']['convert_to_base'] = False
|
||||
_mock_volume_types.return_value = volume_type_hos
|
||||
_mock_volume_types.return_value = self.volume_type_hos
|
||||
|
||||
with mock.patch.object(hpecommon.HPE3PARCommon,
|
||||
'_create_client') as mock_create_client:
|
||||
|
@ -3553,7 +3551,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
|
|||
'getVolume.return_value': {}
|
||||
}
|
||||
mock_client = self.setup_driver(mock_conf=conf)
|
||||
volume_type_hos = self.volume_type_hos
|
||||
volume_type_hos = copy.deepcopy(self.volume_type_hos)
|
||||
volume_type_hos['extra_specs']['convert_to_base'] = True
|
||||
_mock_volume_types.return_value = volume_type_hos
|
||||
with mock.patch.object(hpecommon.HPE3PARCommon,
|
||||
|
@ -3606,9 +3604,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
|
|||
'getVolume.return_value': {}
|
||||
}
|
||||
mock_client = self.setup_driver(mock_conf=conf)
|
||||
volume_type_hos = self.volume_type_hos
|
||||
volume_type_hos['extra_specs']['convert_to_base'] = False
|
||||
_mock_volume_types.return_value = volume_type_hos
|
||||
_mock_volume_types.return_value = self.volume_type_hos
|
||||
with mock.patch.object(hpecommon.HPE3PARCommon,
|
||||
'_create_client') as mock_create_client:
|
||||
mock_create_client.return_value = mock_client
|
||||
|
@ -3661,7 +3657,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
|
|||
'getVolume.return_value': {}
|
||||
}
|
||||
mock_client = self.setup_driver(mock_conf=conf)
|
||||
volume_type_hos = self.volume_type_hos
|
||||
volume_type_hos = copy.deepcopy(self.volume_type_hos)
|
||||
volume_type_hos['extra_specs']['convert_to_base'] = True
|
||||
_mock_volume_types.return_value = volume_type_hos
|
||||
with mock.patch.object(hpecommon.HPE3PARCommon,
|
||||
|
|
|
@ -2100,7 +2100,7 @@ class HPE3PARCommon(object):
|
|||
|
||||
# by default, set convert_to_base to False
|
||||
convert_to_base = self._get_boolean_key_value(
|
||||
hpe3par_keys, 'convert_to_base', False)
|
||||
hpe3par_keys, 'convert_to_base')
|
||||
|
||||
# if provisioning is not set use thin
|
||||
default_prov = self.valid_prov_values[0]
|
||||
|
@ -2643,7 +2643,7 @@ class HPE3PARCommon(object):
|
|||
|
||||
# by default, set convert_to_base to False
|
||||
convert_to_base = self._get_boolean_key_value(
|
||||
hpe3par_keys, 'convert_to_base', False)
|
||||
hpe3par_keys, 'convert_to_base')
|
||||
|
||||
LOG.debug("convert_to_base: %(convert)s",
|
||||
{'convert': convert_to_base})
|
||||
|
@ -2971,9 +2971,9 @@ class HPE3PARCommon(object):
|
|||
|
||||
# Update v2 object as required for
|
||||
# _convert_to_base function
|
||||
v2['volume_type_id'] = \
|
||||
v2['volume_type_id'] = (
|
||||
self._get_3par_vol_comment_value(
|
||||
v1['comment'], 'volume_type_id')
|
||||
v1['comment'], 'volume_type_id'))
|
||||
|
||||
v2['id'] = self._get_3par_vol_comment_value(
|
||||
v2['comment'], 'volume_id')
|
||||
|
|
Loading…
Reference in New Issue