Skip to content

Commit

Permalink
Mock: Consolidated the different assumptions in the zhmcclient mock s…
Browse files Browse the repository at this point in the history
…upport

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Jun 21, 2024
1 parent ef5ab80 commit fa1edfa
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 60 deletions.
5 changes: 5 additions & 0 deletions changes/noissue.4.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Mock: Consolidated the different assumptions in the zhmcclient mock support and
the end2end testcases regarding whether the implemented behavior depends on the
mocked HMC or CPC generation (e.g. support or not support the 'properties'
query parameter on some List operations). Now, the zhmcclient mock support
always implements only the behavior of the latest HMC / CPC generation.
4 changes: 1 addition & 3 deletions tests/end2end/test_activation_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def test_actprof_property(classic_mode_cpcs, profile_type): # noqa: F811
for cpc in classic_mode_cpcs:
assert not cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition
actprof_mgr = getattr(cpc, profile_type + '_activation_profiles')
Expand All @@ -242,5 +241,4 @@ def test_actprof_property(classic_mode_cpcs, profile_type): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, actprof.manager, non_list_prop, (2, 15))
runtest_get_properties(actprof.manager, non_list_prop)
4 changes: 1 addition & 3 deletions tests/end2end/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_adapter_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -110,8 +109,7 @@ def test_adapter_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, adapter.manager, non_list_prop, None)
runtest_get_properties(adapter.manager, non_list_prop)


def test_adapter_hs_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_capacity_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def test_capgrp_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -104,8 +103,7 @@ def test_capgrp_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, capgrp.manager, non_list_prop, None)
runtest_get_properties(capgrp.manager, non_list_prop)


def test_capgrp_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_console_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, client.consoles, non_list_prop, (2, 15))
runtest_get_properties(client.consoles, non_list_prop)


def test_console_list_features(hmc_session): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_cpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ def test_cpc_property(all_cpcs): # noqa: F811
for cpc in all_cpcs:
print(f"Testing with CPC {cpc.name}")

client = cpc.manager.client

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, cpc.manager, non_list_prop, (2, 14))
runtest_get_properties(cpc.manager, non_list_prop)


def test_cpc_features(all_cpcs): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_hba.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_hba_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -115,7 +114,7 @@ def test_hba_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, hba.manager, non_list_prop, None)
runtest_get_properties(hba.manager, non_list_prop)


def test_hba_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_ldap_server_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_ldapsrvdef_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, ldapsrvdef.manager, non_list_prop, None)
runtest_get_properties(ldapsrvdef.manager, non_list_prop)


def test_ldapsrvdef_crud(hmc_session): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_lpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def test_lpar_property(classic_mode_cpcs): # noqa: F811
for cpc in classic_mode_cpcs:
assert not cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -121,7 +120,7 @@ def test_lpar_property(classic_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, lpar.manager, non_list_prop, (2, 14))
runtest_get_properties(lpar.manager, non_list_prop)


TESTCASES_CONSOLE_LIST_PERMITTED_LPARS = [
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_nic_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -119,7 +118,7 @@ def test_nic_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, nic.manager, non_list_prop, None)
runtest_get_properties(nic.manager, non_list_prop)


def test_nic_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def test_part_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -112,8 +111,7 @@ def test_part_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, part.manager, non_list_prop, (2, 16))
runtest_get_properties(part.manager, non_list_prop)


def test_part_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_password_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_pwrule_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, pwrule.manager, non_list_prop, None)
runtest_get_properties(pwrule.manager, non_list_prop)


def test_pwrule_crud(hmc_session): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_port_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -113,7 +112,7 @@ def test_port_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, port.manager, non_list_prop, None)
runtest_get_properties(port.manager, non_list_prop)


def test_port_update(dpm_mode_cpcs): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_storage_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_stogrp_property(dpm_mode_cpcs): # noqa: F811
assert cpc.dpm_enabled
skipif_no_storage_mgmt_feature(cpc)

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -108,8 +107,7 @@ def test_stogrp_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, stogrp.manager, non_list_prop, None)
runtest_get_properties(stogrp.manager, non_list_prop)


def test_stogrp_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_storage_group_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def test_stogrptpl_property(dpm_mode_cpcs): # noqa: F811
skipif_no_storage_mgmt_feature(cpc)

console = cpc.manager.client.consoles.console
client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -112,8 +111,7 @@ def test_stogrptpl_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, stogrptpl.manager, non_list_prop, None)
runtest_get_properties(stogrptpl.manager, non_list_prop)


def test_stogrptpl_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_storage_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ def test_stovol_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, stovol.manager, non_list_prop, None)
runtest_get_properties(stovol.manager, non_list_prop)


def test_stovol_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end/test_storage_volume_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def test_stovoltpl_property(dpm_mode_cpcs): # noqa: F811
skipif_no_storage_mgmt_feature(cpc)

console = cpc.manager.client.consoles.console
client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -124,8 +123,7 @@ def test_stovoltpl_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, stovoltpl.manager, non_list_prop, None)
runtest_get_properties(stovoltpl.manager, non_list_prop)


def test_stovoltpl_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ def test_task_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, task.manager, non_list_prop, None)
runtest_get_properties(task.manager, non_list_prop)
2 changes: 1 addition & 1 deletion tests/end2end/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_user_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, user.manager, non_list_prop, None)
runtest_get_properties(user.manager, non_list_prop)


def test_user_crud(hmc_session): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_user_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_upatt_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, upatt.manager, non_list_prop, None)
runtest_get_properties(upatt.manager, non_list_prop)


def test_upatt_crud(hmc_session): # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/test_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_urole_property(hmc_session): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, urole.manager, non_list_prop, None)
runtest_get_properties(urole.manager, non_list_prop)


def test_urole_crud(hmc_session): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_virtual_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def test_vfunc_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -117,7 +116,7 @@ def test_vfunc_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, vfunc.manager, non_list_prop, None)
runtest_get_properties(vfunc.manager, non_list_prop)


def test_vfunc_crud(dpm_mode_cpcs): # noqa: F811
Expand Down
3 changes: 1 addition & 2 deletions tests/end2end/test_virtual_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def test_vswitch_property(dpm_mode_cpcs): # noqa: F811
for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

Expand All @@ -106,4 +105,4 @@ def test_vswitch_property(dpm_mode_cpcs): # noqa: F811
# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, vswitch.manager, non_list_prop, None)
runtest_get_properties(vswitch.manager, non_list_prop)
21 changes: 6 additions & 15 deletions tests/end2end/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,37 +398,28 @@ def runtest_find_list(session, manager, name, server_prop, client_prop,
prop_names=list_props + add_props)


def runtest_get_properties(
client, manager, non_list_prop, properties_hmc_version): # noqa: F811
def runtest_get_properties(manager, non_list_prop): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Run tests for pull_full_properties/pull_properties/get_property/prop
methods for a resource type.
Parameters:
client (zhmcclient.Client): Client of the manager.
manager (zhmcclient.BaseManager): Manager for listing the resources.
non_list_prop (string): Name of a resource property that is not returned
with the List HMC operation.
properties_hmc_version (tuple(int,int)): HMC version that
introduced the 'properties' query parameter for this resource type.
"""

assert isinstance(manager, zhmcclient.BaseManager)

# Get HMC version as a tuple (major, minor)
av = client.query_api_version()
hmc_version = tuple(int(v) for v in av['hmc-version'].split('.'))

# Indicates whether pull_properties() is expected to pull just the
# specified properties.
supports_properties = properties_hmc_version is not None \
and hmc_version >= properties_hmc_version \
and manager.supports_properties
# specified properties. We make this dependent only on whether the
# mock support for the resource implements it, and not on the HMC
# version, because the zhmcclient mock support only implements the
# latest CPC and HMC generation, for simplicity.
supports_properties = manager.supports_properties

# Part 1: First chunk of methods to be tested

Expand Down

0 comments on commit fa1edfa

Please sign in to comment.