DataSet.data_set_cataloged function previously only returned True or False, but failed to account for exceptions which occurred during the LISTCAT.
The fix now raises an MVSCmdExecError if the return code from LISTCAT is too high.
This PR also introduces a new unit test file for module_utils/data_set.py. The unit tests do NOT check any functionality as they never connect to an actual z/OS system. A DummyModule steps in whenever the AnsibleModuleHelper object is invoked, in this case, namely when run_command is invoked to execute an mvscmd to invoke IDCAMS's LISTCAT ENTRIES command. PS, i tried to use the word invoke as frequently as possible in that last sentence. The DummyModule takes as parameters rc, stdout, and stderr and spits them right back as the return structure for the defined run_command. The test contains string output from successful and failed invocations of mvscmd and paired with the appropriate rc, these unit tests mock the behavior of LISTCAT and allow the code paths in the data_set_cataloged function to be exercised.
SUMMARY
Fixes #838
838
DataSet.data_set_cataloged
function previously only returnedTrue
orFalse
, but failed to account for exceptions which occurred during the LISTCAT.The fix now raises an
MVSCmdExecError
if the return code from LISTCAT is too high.This PR also introduces a new unit test file for module_utils/data_set.py. The unit tests do NOT check any functionality as they never connect to an actual z/OS system. A DummyModule steps in whenever the AnsibleModuleHelper object is invoked, in this case, namely when
run_command
is invoked to execute anmvscmd
to invokeIDCAMS
'sLISTCAT ENTRIES
command. PS, i tried to use the wordinvoke
as frequently as possible in that last sentence. The DummyModule takes as parametersrc, stdout, and stderr
and spits them right back as the return structure for the definedrun_command
. The test contains string output from successful and failed invocations ofmvscmd
and paired with the appropriaterc
, these unit tests mock the behavior of LISTCAT and allow the code paths in thedata_set_cataloged
function to be exercised.ISSUE TYPE
COMPONENT NAME
ibm.ibm_zos_core.plugins.module_utils.data_set.py::DataSet.data_set_cataloged().