@@ -939,3 +939,47 @@ def test_fetch_gdg(ansible_zos_module):
939
939
940
940
if os .path .exists (dest_path ):
941
941
shutil .rmtree (dest_path )
942
+
943
+
944
+ @pytest .mark .parametrize ("relative_path" , ["tmp/" , "." , "../tmp/" , "~/tmp/" ])
945
+ def test_fetch_uss_file_relative_path_not_present_on_local_machine (ansible_zos_module , relative_path ):
946
+ hosts = ansible_zos_module
947
+ current_working_directory = os .getcwd ()
948
+ src = "/etc/profile"
949
+
950
+ # If the test suite is running on root to avoid an issue we check the current directory
951
+ # Also, user can run the tests from ibm_zos_core or tests folder, so this will give us the absolute path of our working dir.
952
+ if relative_path == "../tmp/" :
953
+ aux = os .path .basename (os .path .normpath (current_working_directory ))
954
+ relative_path = "../" + aux + "/tmp/"
955
+
956
+ params = {
957
+ "src" : src ,
958
+ "dest" : relative_path ,
959
+ "flat" :True
960
+ }
961
+
962
+ # Case to create the dest path to verify allow running on any path.
963
+ # There are some relative paths for which we need to change our cwd to be able to validate that
964
+ # the path returned by the module is correct.
965
+ if relative_path == "~/tmp/" :
966
+ dest = os .path .expanduser ("~" )
967
+ dest = dest + "/tmp"
968
+ elif relative_path == "." :
969
+ dest = current_working_directory + "/profile"
970
+ else :
971
+ dest = current_working_directory + "/tmp"
972
+
973
+ try :
974
+ results = hosts .all .zos_fetch (** params )
975
+
976
+ for result in results .contacted .values ():
977
+ assert result .get ("changed" ) is True
978
+ assert result .get ("data_set_type" ) == "USS"
979
+ assert result .get ("module_stderr" ) is None
980
+ assert dest == result .get ("dest" )
981
+ dest = result .get ("dest" )
982
+
983
+ finally :
984
+ if os .path .exists (dest ):
985
+ os .remove (dest )
0 commit comments