Skip to content

Commit

Permalink
Fix comments generate defaults and more
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMarcel99 committed Nov 21, 2024
1 parent d4a4a3b commit 351ccc8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 53 deletions.
16 changes: 6 additions & 10 deletions plugins/modules/zos_mvs_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
required: false
type: int
description:
- Specifies the maximum return code allowed for the program output. If the program generates a return code higher than the specified maximum, the module will fail.
- Specifies the maximum return code allowed for any program output.
default: 0
dds:
description:
- The input data source.
Expand Down Expand Up @@ -1857,7 +1858,7 @@ def run_module():
verbose=dict(type="bool", default=False),
parm=dict(type="str", required=False),
tmp_hlq=dict(type="str", required=False, default=None),
max_rc=dict(type="int", required=False),
max_rc=dict(type="int", required=False, default=0),
dds=dict(
type="list",
elements="dict",
Expand Down Expand Up @@ -1908,19 +1909,14 @@ def run_module():
response = build_response(program_response.rc, dd_statements, program_response.stdout)
result = combine_dicts(result, response)

if program_response.rc != 0 and max_rc is None:
if program_response.rc > max_rc:
raise ZOSRawError(
program,
"{0} {1}".format(program_response.stdout, program_response.stderr),
)

if program_response.rc != 0 and program_response.rc <= max_rc:
if program_response.rc != 0:
result["changed"] = False
elif program_response.rc != 0 and program_response.rc > max_rc:
raise ZOSRawError(
program,
"{0} {1}".format(program_response.stdout, program_response.stderr),
)
else:
result["changed"] = True

Expand Down Expand Up @@ -2102,7 +2098,7 @@ def parse_and_validate_args(params):
verbose=dict(type="bool", default=False),
parm=dict(type="str", required=False),
tmp_hlq=dict(type="qualifier_or_empty", required=False, default=None),
max_rc=dict(type="int", required=False),
max_rc=dict(type="int", required=False, default=0),
dds=dict(
type="list",
elements="dict",
Expand Down
71 changes: 28 additions & 43 deletions tests/functional/modules/test_zos_mvs_raw_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,51 +976,36 @@ def test_data_set_name_special_characters(ansible_zos_module):
if idcams_dataset:
hosts.all.zos_data_set(name=idcams_dataset, state="absent")

@pytest.mark.parametrize("max_rc", [2, 4, 8, 16])
@pytest.mark.parametrize("max_rc", [4, 8])
def test_new_disposition_for_data_set_members_max_rc(ansible_zos_module, max_rc):
idcams_dataset = None
try:
hosts = ansible_zos_module
default_data_set = get_tmp_ds_name()
default_data_set_with_member = default_data_set + '(MEM)'
hosts.all.zos_data_set(name=default_data_set, state="absent")
idcams_dataset, idcams_listcat_dataset_cmd = get_temp_idcams_dataset(hosts)

results = hosts.all.zos_mvs_raw(
program_name="idcams",
auth=True,
max_rc=max_rc,
dds=[
{
"dd_data_set":{
"dd_name":SYSPRINT_DD,
"data_set_name":default_data_set_with_member,
"disposition":"new",
"type":"pds",
"directory_blocks":15,
"return_content":{
"type":"text"
},
},
},
{
"dd_input":{
"dd_name":SYSIN_DD,
"content":idcams_listcat_dataset_cmd
hosts = ansible_zos_module
results = hosts.all.zos_mvs_raw(
program_name="idcams",
auth=True,
max_rc=max_rc,
dds=[
{
"dd_output":{
"dd_name":"sysprint",
"return_content":{
"type":"text"
}
},
],
)
for result in results.contacted.values():
assert result.get("changed") is False
assert result.get("ret_code", {}).get("code", -1) == 8
if max_rc < 8:
assert result.get("failed") is True
assert result.get("msg") is not None
finally:
hosts.all.zos_data_set(name=default_data_set, state="absent")
if idcams_dataset:
hosts.all.zos_data_set(name=idcams_dataset, state="absent")
}
},
{
"dd_input":{
"dd_name":"sysin",
"content":" DELETE THIS.DATASET.DOES.NOT.EXIST"
}
},
],
)
for result in results.contacted.values():
assert result.get("changed") is False
assert result.get("ret_code", {}).get("code", -1) == 8
if max_rc != 8:
assert result.get("msg") is not None
assert result.get("failed") is True

# ---------------------------------------------------------------------------- #
# Input DD Tests #
Expand Down

0 comments on commit 351ccc8

Please sign in to comment.