Skip to content

Commit a26cf3b

Browse files
committed
Changed tests to use firmware_feature_enabled() methods
Details: * In tests/end2end/utils.py, changed the skipif_no_storage_mgmt_feature() and skipif_storage_mgmt_feature() functions to use the Cpc.firmware_feature_enabled() method instead of the deprecated Cpc.feature_enabled() method. * In tests/unit/zhmcclient/test_cpc/partition.py, disabled the DeprecationWarning for using the deprecated Cpc/Partition.feature_enabled() in test function test_cpc/partition_feature_enabled(). That function intentionally tests the deprecated method. * In tests/end2end/test_cpc/partition.py, removed the tests of the deprecated Cpc/Partition.feature_enabled() methods in test functions test_cpc/partition_features(). Signed-off-by: Andreas Maier <[email protected]>
1 parent 0b3978f commit a26cf3b

File tree

6 files changed

+20
-37
lines changed

6 files changed

+20
-37
lines changed

changes/noissue.96.cleanup.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Test: Changed unit and end2end tests to use the `firmware_feature_enabled()`
2+
methods instead of the deprecated `feature_enabled()` methods, on Cpc and
3+
Partition objects.

tests/end2end/test_cpc.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def test_cpc_features(all_cpcs):
126126
- dpm_enabled property
127127
- maximum_active_partitions property
128128
- For firmware features:
129-
- feature_enabled() - deprecated
130129
- firmware_feature_enabled()
131130
- feature_info()
132131
- list_firmware_features()
@@ -178,9 +177,7 @@ def test_cpc_features(all_cpcs):
178177
fw_feature_name = 'dpm-storage-management'
179178
if cpc_fw_features is None:
180179
# The machine does not yet support firmware features
181-
with pytest.raises(ValueError):
182-
# The code to be tested: feature_enabled()
183-
cpc.feature_enabled(fw_feature_name)
180+
# The code to be tested
184181
enabled = cpc.firmware_feature_enabled(fw_feature_name)
185182
assert enabled is False
186183
else:
@@ -189,21 +186,14 @@ def test_cpc_features(all_cpcs):
189186
if not features:
190187
# The machine generally supports firmware features, but this
191188
# feature is not available
192-
with pytest.raises(ValueError):
193-
# The code to be tested: feature_enabled()
194-
cpc.feature_enabled(fw_feature_name)
195-
# The code to be tested: firmware_feature_enabled()
189+
# The code to be tested
196190
enabled = cpc.firmware_feature_enabled(fw_feature_name)
197191
assert enabled is False
198192
else:
199193
# The machine has this feature available
200-
# The code to be tested: feature_enabled()
201-
enabled = cpc.feature_enabled(fw_feature_name)
202-
exp_enabled = features[0]['state']
203-
assert_res_prop(enabled, exp_enabled,
204-
'available-features-list', cpc)
205-
# The code to be tested: firmware_feature_enabled()
194+
# The code to be tested
206195
enabled = cpc.firmware_feature_enabled(fw_feature_name)
196+
exp_enabled = features[0]['state']
207197
assert enabled == exp_enabled
208198
# Test: feature_info()
209199
if cpc_fw_features is None:

tests/end2end/test_partition.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from .utils import skip_warn, pick_test_resources, TEST_PREFIX, \
3333
standard_partition_props, runtest_find_list, runtest_get_properties, \
34-
pformat_as_dict, assert_res_prop, validate_firmware_features
34+
pformat_as_dict, validate_firmware_features
3535

3636
urllib3.disable_warnings()
3737

@@ -233,7 +233,6 @@ def test_partition_features(dpm_mode_cpcs):
233233
"""
234234
Test features of the CPC of a partition:
235235
- For firmware features:
236-
- feature_enabled() - deprecated
237236
- firmware_feature_enabled()
238237
- feature_info()
239238
- list_firmware_features()
@@ -266,9 +265,7 @@ def test_partition_features(dpm_mode_cpcs):
266265
fw_feature_name = 'dpm-storage-management'
267266
if cpc_fw_features is None:
268267
# The machine does not yet support firmware features
269-
with pytest.raises(ValueError):
270-
# The code to be tested: feature_enabled()
271-
part.feature_enabled(fw_feature_name)
268+
# The code to be tested
272269
enabled = part.firmware_feature_enabled(fw_feature_name)
273270
assert enabled is False
274271
else:
@@ -292,21 +289,14 @@ def test_partition_features(dpm_mode_cpcs):
292289
if fw_feature_name not in part_state_by_name:
293290
# The machine generally supports firmware features, but this
294291
# feature is not available
295-
with pytest.raises(ValueError):
296-
# The code to be tested: feature_enabled()
297-
part.feature_enabled(fw_feature_name)
298-
# The code to be tested: firmware_feature_enabled()
292+
# The code to be tested
299293
enabled = part.firmware_feature_enabled(fw_feature_name)
300294
assert enabled is False
301295
else:
302296
# The machine has this feature available
303-
# The code to be tested: feature_enabled()
304-
enabled = part.feature_enabled(fw_feature_name)
305-
exp_enabled = part_state_by_name[fw_feature_name]
306-
assert_res_prop(enabled, exp_enabled,
307-
'available-features-list', cpc)
308-
# The code to be tested: firmware_feature_enabled()
297+
# The code to be tested
309298
enabled = part.firmware_feature_enabled(fw_feature_name)
299+
exp_enabled = part_state_by_name[fw_feature_name]
310300
assert enabled == exp_enabled
311301
# Test: feature_info()
312302
if cpc_fw_features is None:

tests/end2end/utils.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,7 @@ def skipif_no_storage_mgmt_feature(cpc):
574574
Skip the test if the "DPM Storage Management" feature is not enabled for
575575
the specified CPC, or if the CPC does not yet support it.
576576
"""
577-
try:
578-
smf = cpc.feature_enabled('dpm-storage-management')
579-
except ValueError:
580-
smf = False
577+
smf = cpc.firmware_feature_enabled('dpm-storage-management')
581578
if not smf:
582579
skip_warn("DPM Storage Mgmt feature not enabled or not supported "
583580
f"on CPC {cpc.name}")
@@ -588,10 +585,7 @@ def skipif_storage_mgmt_feature(cpc):
588585
Skip the test if the "DPM Storage Management" feature is enabled for
589586
the specified CPC.
590587
"""
591-
try:
592-
smf = cpc.feature_enabled('dpm-storage-management')
593-
except ValueError:
594-
smf = False
588+
smf = cpc.firmware_feature_enabled('dpm-storage-management')
595589
if smf:
596590
skip_warn(f"DPM Storage Mgmt feature enabled on CPC {cpc.name}")
597591

tests/unit/zhmcclient/test_cpc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,9 @@ def test_cpc_list_api_features(
951951
"exp_feature_enabled, exp_exc_type, exp_exc_msg",
952952
FEATURE_ENABLED_TESTCASES
953953
)
954+
@pytest.mark.filterwarnings(
955+
"ignore:.*feature_enabled.*deprecated.*:DeprecationWarning"
956+
)
954957
def test_cpc_feature_enabled(
955958
self, desc, cpc_name, available_features, feature_name,
956959
exp_feature_enabled, exp_exc_type, exp_exc_msg):

tests/unit/zhmcclient/test_partition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ def test_partition_delete_create_same_name(self):
586586
"exp_feature_enabled, exp_exc_type, exp_exc_msg",
587587
FEATURE_ENABLED_TESTCASES
588588
)
589+
@pytest.mark.filterwarnings(
590+
"ignore:.*feature_enabled.*deprecated.*:DeprecationWarning"
591+
)
589592
def test_partition_feature_enabled(
590593
self, desc, partition_name, available_features, feature_name,
591594
exp_feature_enabled, exp_exc_type, exp_exc_msg):

0 commit comments

Comments
 (0)