From e491f738e99da701144bfbaca7365a85e81f2f7f Mon Sep 17 00:00:00 2001 From: pem70 Date: Fri, 7 Jun 2024 09:42:34 -0400 Subject: [PATCH] Remove unused imports and add test constants Signed-off-by: pem70 --- .vscode/settings.json | 3 ++- src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py | 1 - tests/unit/files/constants.py | 7 +++++++ tests/unit/files/datasets/test_copy.py | 11 +++-------- tests/unit/files/datasets/test_create.py | 13 +++---------- tests/unit/files/datasets/test_delete.py | 13 +++---------- tests/unit/files/datasets/test_get.py | 13 +++---------- tests/unit/files/datasets/test_list.py | 14 +++----------- tests/unit/files/datasets/test_migrate.py | 13 +++---------- tests/unit/files/datasets/test_rename.py | 12 +++--------- tests/unit/files/datasets/test_write.py | 13 +++---------- tests/unit/files/file_systems/test_file_systems.py | 13 +++---------- tests/unit/files/uss/test_uss.py | 13 +++---------- tests/unit/test_zos_console.py | 10 ++-------- tests/unit/test_zos_jobs.py | 10 ++-------- tests/unit/test_zos_tso.py | 10 ++-------- tests/unit/test_zosmf.py | 10 ++-------- 17 files changed, 47 insertions(+), 132 deletions(-) create mode 100644 tests/unit/files/constants.py diff --git a/.vscode/settings.json b/.vscode/settings.json index b378a106..028f87d3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "./src/zos_console", "./src/zos_files", "./src/zos_jobs", - "./src/zosmf" + "./src/zosmf", + "./src/zos_tso" ], } diff --git a/src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py b/src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py index fc2fffaf..f19433bd 100644 --- a/src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py +++ b/src/zos_files/zowe/zos_files_for_zowe_sdk/uss.py @@ -125,7 +125,6 @@ def get_content(self, filepath_name): A JSON with the contents of the specified USS file """ custom_args = self._create_custom_request_arguments() - # custom_args["params"] = {"filepath-name": filepath_name} custom_args["url"] = "{}fs{}".format(self.request_endpoint, filepath_name) response_json = self.request_handler.perform_request("GET", custom_args) return response_json diff --git a/tests/unit/files/constants.py b/tests/unit/files/constants.py new file mode 100644 index 00000000..ea00e7ac --- /dev/null +++ b/tests/unit/files/constants.py @@ -0,0 +1,7 @@ +profile = { + "host": "mock-url.com", + "user": "Username", + "password": "Password", + "port": 443, + "rejectUnauthorized": True, + } \ No newline at end of file diff --git a/tests/unit/files/datasets/test_copy.py b/tests/unit/files/datasets/test_copy.py index a2fe94b2..ab86119b 100644 --- a/tests/unit/files/datasets/test_copy.py +++ b/tests/unit/files/datasets/test_copy.py @@ -1,5 +1,6 @@ from unittest import TestCase, mock -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestCreateClass(TestCase): @@ -7,13 +8,7 @@ class TestCreateClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_copy_uss_to_dataset(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_create.py b/tests/unit/files/datasets/test_create.py index d8d9f44f..5a3b4554 100644 --- a/tests/unit/files/datasets/test_create.py +++ b/tests/unit/files/datasets/test_create.py @@ -1,7 +1,6 @@ -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestCreateClass(TestCase): @@ -9,13 +8,7 @@ class TestCreateClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_create_data_set_accept_valid_recfm(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_delete.py b/tests/unit/files/datasets/test_delete.py index 899cfb3d..5e6b9739 100644 --- a/tests/unit/files/datasets/test_delete.py +++ b/tests/unit/files/datasets/test_delete.py @@ -1,7 +1,6 @@ -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestDeleteClass(TestCase): @@ -9,13 +8,7 @@ class TestDeleteClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_delete(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_get.py b/tests/unit/files/datasets/test_get.py index 46438b62..6bd24dcd 100644 --- a/tests/unit/files/datasets/test_get.py +++ b/tests/unit/files/datasets/test_get.py @@ -1,7 +1,6 @@ -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestGetClass(TestCase): @@ -9,13 +8,7 @@ class TestGetClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_get(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_list.py b/tests/unit/files/datasets/test_list.py index 3e6d1349..06f77904 100644 --- a/tests/unit/files/datasets/test_list.py +++ b/tests/unit/files/datasets/test_list.py @@ -1,8 +1,6 @@ -"""Unit tests for the Zowe Python SDK z/OS Files package.""" -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestFilesClass(TestCase): @@ -10,13 +8,7 @@ class TestFilesClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_list_dsn(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_migrate.py b/tests/unit/files/datasets/test_migrate.py index 413911ba..27c7128d 100644 --- a/tests/unit/files/datasets/test_migrate.py +++ b/tests/unit/files/datasets/test_migrate.py @@ -1,7 +1,6 @@ -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestCreateClass(TestCase): @@ -9,13 +8,7 @@ class TestCreateClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_recall_migrated_dataset(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_rename.py b/tests/unit/files/datasets/test_rename.py index c3a70b49..ec6818c9 100644 --- a/tests/unit/files/datasets/test_rename.py +++ b/tests/unit/files/datasets/test_rename.py @@ -1,7 +1,7 @@ import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestCreateClass(TestCase): @@ -9,13 +9,7 @@ class TestCreateClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_rename_dataset(self, mock_send_request): diff --git a/tests/unit/files/datasets/test_write.py b/tests/unit/files/datasets/test_write.py index 1f0c84b2..0f478bbd 100644 --- a/tests/unit/files/datasets/test_write.py +++ b/tests/unit/files/datasets/test_write.py @@ -1,7 +1,6 @@ -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestWriteClass(TestCase): @@ -9,13 +8,7 @@ class TestWriteClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_write(self, mock_send_request): diff --git a/tests/unit/files/file_systems/test_file_systems.py b/tests/unit/files/file_systems/test_file_systems.py index 9e49596b..8783e2cb 100644 --- a/tests/unit/files/file_systems/test_file_systems.py +++ b/tests/unit/files/file_systems/test_file_systems.py @@ -1,8 +1,7 @@ """Unit tests for the Zowe Python SDK z/OS Files package.""" -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files, exceptions +from unit.files.constants import profile class TestFilesClass(TestCase): @@ -10,13 +9,7 @@ class TestFilesClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_create_zFS_file_system(self, mock_send_request): diff --git a/tests/unit/files/uss/test_uss.py b/tests/unit/files/uss/test_uss.py index 3a9ab204..299f142f 100644 --- a/tests/unit/files/uss/test_uss.py +++ b/tests/unit/files/uss/test_uss.py @@ -1,8 +1,7 @@ """Unit tests for the Zowe Python SDK z/OS Files package.""" -import re from unittest import TestCase, mock - -from zowe.zos_files_for_zowe_sdk import Files, exceptions, Datasets +from zowe.zos_files_for_zowe_sdk import Files +from unit.files.constants import profile class TestFilesClass(TestCase): @@ -10,13 +9,7 @@ class TestFilesClass(TestCase): def setUp(self): """Setup fixtures for File class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile @mock.patch("requests.Session.send") def test_delete_uss(self, mock_send_request): diff --git a/tests/unit/test_zos_console.py b/tests/unit/test_zos_console.py index 52e05ac2..252d7ab5 100644 --- a/tests/unit/test_zos_console.py +++ b/tests/unit/test_zos_console.py @@ -2,7 +2,7 @@ import unittest from unittest import mock - +from unit.files.constants import profile from zowe.zos_console_for_zowe_sdk import Console @@ -11,13 +11,7 @@ class TestConsoleClass(unittest.TestCase): def setUp(self): """Setup fixtures for Console class.""" - self.session_details = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.session_details = profile def test_object_should_be_instance_of_class(self): """Created object should be instance of Console class.""" diff --git a/tests/unit/test_zos_jobs.py b/tests/unit/test_zos_jobs.py index 5bb93528..ed102001 100644 --- a/tests/unit/test_zos_jobs.py +++ b/tests/unit/test_zos_jobs.py @@ -1,7 +1,7 @@ """Unit tests for the Zowe Python SDK z/OS Jobs package.""" from unittest import TestCase, mock - +from unit.files.constants import profile from zowe.zos_jobs_for_zowe_sdk import Jobs @@ -10,13 +10,7 @@ class TestJobsClass(TestCase): def setUp(self): """Setup fixtures for Jobs class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile def test_object_should_be_instance_of_class(self): """Created object should be instance of Jobs class.""" diff --git a/tests/unit/test_zos_tso.py b/tests/unit/test_zos_tso.py index 3e36d022..a18b0af6 100644 --- a/tests/unit/test_zos_tso.py +++ b/tests/unit/test_zos_tso.py @@ -1,7 +1,7 @@ """Unit tests for the Zowe Python SDK z/OS TSO package.""" from unittest import TestCase, mock - +from unit.files.constants import profile from zowe.zos_tso_for_zowe_sdk import Tso @@ -10,13 +10,7 @@ class TestTsoClass(TestCase): def setUp(self): """Setup fixtures for Tso class.""" - self.test_profile = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.test_profile = profile def test_object_should_be_instance_of_class(self): """Created object should be instance of Tso class.""" diff --git a/tests/unit/test_zosmf.py b/tests/unit/test_zosmf.py index 91a81e10..b133664e 100644 --- a/tests/unit/test_zosmf.py +++ b/tests/unit/test_zosmf.py @@ -2,7 +2,7 @@ import unittest from unittest import mock - +from unit.files.constants import profile from zowe.zosmf_for_zowe_sdk import Zosmf @@ -11,13 +11,7 @@ class TestZosmfClass(unittest.TestCase): def setUp(self): """Setup fixtures for Zosmf class.""" - self.connection_dict = { - "host": "mock-url.com", - "user": "Username", - "password": "Password", - "port": 443, - "rejectUnauthorized": True, - } + self.connection_dict = profile def test_object_should_be_instance_of_class(self): """Created object should be instance of Zosmf class."""