ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
75 stars 44 forks source link

[module_utils/data_set] surface errors in `data_set_cataloged` function #1535

Open ketankelkar opened 3 weeks ago

ketankelkar commented 3 weeks ago
SUMMARY

Fixes #838

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.

ISSUE TYPE
COMPONENT NAME

ibm.ibm_zos_core.plugins.module_utils.data_set.py::DataSet.data_set_cataloged().