Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-231 Now 'issue_command' can use custom console name #232

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil
### Bug Fixes

- Fixed Secrets SDK requiring LD_LIBRARY_PATH to be defined when installed from wheel on Linux [#229](https://github.com/zowe/zowe-client-python-sdk/issues/229)
- Fixed 'issue_command' Console API function to provide custom console name [#231](https://github.com/zowe/zowe-client-python-sdk/issues/231)

## `1.0.0-dev11`

Expand Down
1 change: 1 addition & 0 deletions src/zos_console/zowe/zos_console_for_zowe_sdk/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def issue_command(self, command, console=None):
A JSON containing the response from the console command
"""
custom_args = self._create_custom_request_arguments()
custom_args["url"] = self.request_endpoint.replace("defcn", console or "defcn")
request_body = {"cmd": command}
custom_args["json"] = request_body
response_json = self.request_handler.perform_request("PUT", custom_args)
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_zos_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ def test_object_should_be_instance_of_class(self):
console = Console(self.session_details)
self.assertIsInstance(console, Console)

@mock.patch("requests.Session.send")
def test_issue_command_makes_request_to_the_default_console(self, mock_send):
"""Issued command should be sent to the correct default console name if no name is specified"""
is_console_name_correct = False
def send_request_side_effect(self, **other_args):
assert "/defcn" in self.url
return mock.Mock(headers={"Content-type": "application/json"}, status_code=200)
mock_send.side_effect = send_request_side_effect
Console(self.session_details).issue_command("TESTCMD")

@mock.patch("requests.Session.send")
def test_issue_command_makes_request_to_the_custom_console(self, mock_send):
"""Issued command should be sent to the correct custom console name if the console name is specified"""
is_console_name_correct = False
def send_request_side_effect(self, **other_args):
assert "/TESTCNSL" in self.url
return mock.Mock(headers={"Content-type": "application/json"}, status_code=200)
mock_send.side_effect = send_request_side_effect
Console(self.session_details).issue_command("TESTCMD", "TESTCNSL")

@mock.patch("requests.Session.send")
def test_get_response_should_return_messages(self, mock_send_request):
"""Getting z/OS Console response messages on sending a response key"""
Expand Down