15
15
16
16
__metaclass__ = type
17
17
18
- import ansible .constants
19
- import ansible .errors
20
- import ansible .utils
21
18
from ibm_zos_core .tests .helpers .dataset import get_tmp_ds_name
22
19
23
20
def test_zos_tso_command_run_help (ansible_zos_module ):
@@ -50,7 +47,8 @@ def test_zos_tso_command_allocate_listing_delete(ansible_zos_module):
50
47
hosts = ansible_zos_module
51
48
default_temp_dataset = get_tmp_ds_name ()
52
49
command_string = [
53
- "alloc da('{0}') catalog lrecl(133) blksize(13300) recfm(f b) dsorg(po) cylinders space(5,5) dir(5)" .format (default_temp_dataset )
50
+ f"alloc da('{ default_temp_dataset } ') " +
51
+ "catalog lrecl(133) blksize(13300) recfm(f b) dsorg(po) cylinders space(5,5) dir(5)"
54
52
]
55
53
results_allocate = hosts .all .zos_tso_command (commands = command_string )
56
54
# Validate the correct allocation of dataset
@@ -59,34 +57,35 @@ def test_zos_tso_command_allocate_listing_delete(ansible_zos_module):
59
57
assert item .get ("rc" ) == 0
60
58
assert result .get ("changed" ) is True
61
59
# Validate listds of datasets and validate LISTDS using alias param 'command' of auth command
62
- results = hosts .all .zos_tso_command (commands = ["LISTDS '{0 }'" . format ( default_temp_dataset ) ])
60
+ results = hosts .all .zos_tso_command (commands = [f "LISTDS '{ default_temp_dataset } '" ])
63
61
for result in results .contacted .values ():
64
62
for item in result .get ("output" ):
65
63
assert item .get ("rc" ) == 0
66
64
assert result .get ("changed" ) is True
67
65
# Validate LISTDS using alias param 'command'
68
- results = hosts .all .zos_tso_command (command = "LISTDS '{0 }'" . format ( default_temp_dataset ) )
66
+ results = hosts .all .zos_tso_command (command = f "LISTDS '{ default_temp_dataset } '" )
69
67
for result in results .contacted .values ():
70
68
for item in result .get ("output" ):
71
69
assert item .get ("rc" ) == 0
72
70
assert result .get ("changed" ) is True
73
71
# Validate LISTCAT command and an unauth command
74
72
results = hosts .all .zos_tso_command (
75
- commands = ["LISTCAT ENT('{0 }')" . format ( default_temp_dataset ) ]
73
+ commands = [f "LISTCAT ENT('{ default_temp_dataset } ')" ]
76
74
)
77
75
for result in results .contacted .values ():
78
76
for item in result .get ("output" ):
79
77
assert item .get ("rc" ) == 0
80
78
assert result .get ("changed" ) is True
81
79
# Validate remove dataset
82
- results = hosts .all .zos_tso_command (commands = ["delete '{0 }'" . format ( default_temp_dataset ) ])
80
+ results = hosts .all .zos_tso_command (commands = [f "delete '{ default_temp_dataset } '" ])
83
81
for result in results .contacted .values ():
84
82
for item in result .get ("output" ):
85
83
assert item .get ("rc" ) == 0
86
84
assert result .get ("changed" ) is True
87
- # Expect the tso_command to fail here because the previous command will have already deleted the data set
85
+ # Expect the tso_command to fail here because
86
+ # the previous command will have already deleted the data set
88
87
# Validate data set was removed by previous call
89
- results = hosts .all .zos_tso_command (commands = ["delete '{0 }'" . format ( default_temp_dataset ) ])
88
+ results = hosts .all .zos_tso_command (commands = [f "delete '{ default_temp_dataset } '" ])
90
89
for result in results .contacted .values ():
91
90
for item in result .get ("output" ):
92
91
assert item .get ("rc" ) == 8
@@ -134,20 +133,11 @@ def test_zos_tso_command_multiple_commands(ansible_zos_module):
134
133
# The command that kicks off rc>0 which is allowed
135
134
def test_zos_tso_command_maxrc (ansible_zos_module ):
136
135
hosts = ansible_zos_module
137
- results = hosts .all .zos_tso_command (commands = ["LISTDSD DATASET('HLQ.DATA.SET') ALL GENERIC" ],max_rc = 4 )
138
- for result in results .contacted .values ():
139
- for item in result .get ("output" ):
140
- assert item .get ("rc" ) < 5
141
- assert result .get ("changed" ) is True
142
-
143
-
144
- # The positive test
145
- # The command that kicks off rc>0 which is allowed
146
- def test_zos_tso_command_maxrc (ansible_zos_module ):
147
- hosts = ansible_zos_module
148
- results = hosts .all .zos_tso_command (commands = ["LISTDSD DATASET('HLQ.DATA.SET') ALL GENERIC" ],max_rc = 4 )
136
+ results = hosts .all .zos_tso_command (
137
+ commands = ["LISTDSD DATASET('HLQ.DATA.SET') ALL GENERIC" ],
138
+ max_rc = 4
139
+ )
149
140
for result in results .contacted .values ():
150
141
for item in result .get ("output" ):
151
- print ( item )
152
142
assert item .get ("rc" ) < 5
153
143
assert result .get ("changed" ) is True
0 commit comments