Skip to content

Commit

Permalink
Merge branch 'Standardize-response' into Refactor-function-definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
pem70 committed Jun 17, 2024
2 parents 911b041 + 73700bf commit 41458df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

- Added logger class to core SDK [#185](https://github.com/zowe/zowe-client-python-sdk/issues/185)
- Added classes for handling `Datasets`, `USSFiles`, and `FileSystems` in favor of the single Files class. [#264](https://github.com/zowe/zowe-client-python-sdk/issues/264)
- Refactored tests into proper folders and files [#265](https://github.com/zowe/zowe-client-python-sdk/issues/265)
- Fixed the bug on `upload_file_to_dsn` [#104](https://github.com/zowe/zowe-client-python-sdk/issues/104)
- **Breaking:** Standardized `response` output based on `Content-Type`. [#266](https://github.com/zowe/zowe-client-python-sdk/issues/266)
- Refactored function `Datasets.create` definition [#214](https://github.com/zowe/zowe-client-python-sdk/issues/214)
- Refactored tests into proper folders and files and add more tests [#265](https://github.com/zowe/zowe-client-python-sdk/issues/265)
- **Breaking:** Standardized `response` outputs based on `Content-Type`. [#266](https://github.com/zowe/zowe-client-python-sdk/issues/266)

### Bug Fixes

- Fixed truncated responses when issuing TSO commands [#260](https://github.com/zowe/zowe-client-python-sdk/issues/260)
- Fixed a bug on `upload_file_to_dsn` where it would not properly convert line endings on Windows. [#104](https://github.com/zowe/zowe-client-python-sdk/issues/104)

## `1.0.0-dev15`

Expand Down
13 changes: 9 additions & 4 deletions src/zos_tso/zowe/zos_tso_for_zowe_sdk/tso.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import json

from zowe.core_for_zowe_sdk import SdkApi, constants


Expand Down Expand Up @@ -61,10 +62,8 @@ def issue_command(self, command):
command_output = self.send_tso_message(session_key, command)
tso_messages = self.retrieve_tso_messages(command_output)
while not any("TSO PROMPT" in message for message in command_output) or not tso_messages:
custom_args = self._create_custom_request_arguments()
custom_args["url"] = "{}/{}".format(self.request_endpoint, session_key)
command_output = self.request_handler.perform_request("GET", custom_args)["tsoData"]
tso_messages += self.retrieve_tso_messages(command_output)
command_output = self.__get_tso_data(session_key)
tso_messages += self.retrieve_tso_messages(command_output)
self.end_tso_session(session_key)
return tso_messages

Expand Down Expand Up @@ -206,3 +205,9 @@ def retrieve_tso_messages(self, response_json):
A list containing the TSO response messages
"""
return [message["TSO MESSAGE"]["DATA"] for message in response_json if "TSO MESSAGE" in message]

def __get_tso_data(self, session_key):
custom_args = self._create_custom_request_arguments()
custom_args["url"] = "{}/{}".format(self.request_endpoint, session_key)
command_output = self.request_handler.perform_request("GET", custom_args)["tsoData"]
return command_output
12 changes: 3 additions & 9 deletions tests/unit/files/datasets/test_delete.py
Original file line number Diff line number Diff line change
@@ -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 Datasets, Files, exceptions


class TestDeleteClass(TestCase):
Expand All @@ -26,23 +26,17 @@ def test_delete(self, mock_send_request):
mock_send_request.assert_called_once()

@mock.patch("requests.Session.send")
def test_delete_pram(self, mock_send_request):
def test_delete_param(self, mock_send_request):
"""Test list members sends request"""
self.files_instance = Files(self.test_profile)
mock_send_request.return_value = mock.Mock(headers={"Content-Type": "application/json"}, status_code=200)
mock_send_request.return_value.json.return_value = {}

test_cases = [
("MY.PDS", 1000, "m1"),
("MY.C", 100, "m2"),
("MY.D", 1000, "member"),
("MY.E", 500, "extended")
]
test_cases = [("MY.PDS", 1000, "m1"), ("MY.C", 100, "m2"), ("MY.D", 1000, "member"), ("MY.E", 500, "extended")]

for dataset_name, volume, member_name in test_cases:
result = self.files_instance.delete_data_set(dataset_name, volume, member_name)
self.assertEqual(result, {})
mock_send_request.assert_called()
prepared_request = mock_send_request.call_args[0][0]
self.assertEqual(prepared_request.method, "DELETE")

0 comments on commit 41458df

Please sign in to comment.