Commit bc647b91 authored by Mark Hewitt's avatar Mark Hewitt
Browse files

Merge branch 'fix/storage-delete-error' into 'main'

fix storage delete returns 204 error when deleted successfully

Closes #17

See merge request !15
parents 468b99ed a3bb0d4b
Pipeline #93741 passed with stages
in 4 minutes and 57 seconds
...@@ -28,6 +28,11 @@ For more information, specify the `-h` flag: ...@@ -28,6 +28,11 @@ For more information, specify the `-h` flag:
Change Log Change Log
========== ==========
0.0.33
------
- fix storage delete returns 204 error when deleted successfully
0.0.32 0.0.32
------ ------
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
""" OSDU command line environment""" """ OSDU command line environment"""
__VERSION__ = "0.0.32" __VERSION__ = "0.0.33"
...@@ -106,7 +106,7 @@ class CustomMainClickGroup(CustomClickGroup): ...@@ -106,7 +106,7 @@ class CustomMainClickGroup(CustomClickGroup):
f"\b\n\033[33mWARNING: You are using osdu cli version {current_version}; however version {latest_version} is available.\033[39m" # noqa: E501 pylint: disable=line-too-long f"\b\n\033[33mWARNING: You are using osdu cli version {current_version}; however version {latest_version} is available.\033[39m" # noqa: E501 pylint: disable=line-too-long
) )
formatter.write_text( formatter.write_text(
"\b\n\033[33mYou should consider upgrading via the 'pip install -U osdu-cli' command\033[39m" # noqa: E501 pylint: disable=line-too-long "\b\n\033[33mYou should consider upgrading via the 'pip install -U osducli' command\033[39m" # noqa: E501 pylint: disable=line-too-long
) )
......
...@@ -192,7 +192,7 @@ class CliOsduClient(OsduClient): ...@@ -192,7 +192,7 @@ class CliOsduClient(OsduClient):
config_url_key: str, config_url_key: str,
url_extra_path: str, url_extra_path: str,
ok_status_codes: list = None, ok_status_codes: list = None,
): ) -> requests.Response:
"""[summary] """[summary]
Args: Args:
...@@ -202,24 +202,10 @@ class CliOsduClient(OsduClient): ...@@ -202,24 +202,10 @@ class CliOsduClient(OsduClient):
ok_status_codes (list, optional): Status codes indicating successful call. Defaults to [200]. ok_status_codes (list, optional): Status codes indicating successful call. Defaults to [200].
Returns: Returns:
[type]: [description] requests.Response: Response object from the HTTP call
""" """
try: url = self.url_from_config(config_url_key, url_extra_path)
url = self.url_from_config(config_url_key, url_extra_path) return self.delete(url, ok_status_codes)
self.delete(url, ok_status_codes)
return
except HTTPError as ex:
logger.error(MSG_HTTP_ERROR)
logger.error("Error (%s) - %s", ex.response.status_code, ex.response.reason)
except ValueError as ex:
logger.error(MSG_JSON_DECODE_ERROR)
logger.debug(ex)
except (NoOptionError, NoSectionError) as ex:
logger.warning(
"Configuration missing from config ('%s'). Run 'osdu config update'", ex.args[0]
)
sys.exit(1)
def cli_put( def cli_put(
self, self,
......
...@@ -37,4 +37,7 @@ def delete(state: State, id: str): # pylint: disable=invalid-name,redefined-bui ...@@ -37,4 +37,7 @@ def delete(state: State, id: str): # pylint: disable=invalid-name,redefined-bui
""" """
connection = CliOsduClient(state.config) connection = CliOsduClient(state.config)
url = "records/" + id url = "records/" + id
connection.cli_delete(CONFIG_STORAGE_URL, url) connection.cli_delete(CONFIG_STORAGE_URL, url, [200, 204])
if state.is_user_friendly_mode():
print("1 record deleted")
...@@ -75,7 +75,7 @@ def version(state: State): ...@@ -75,7 +75,7 @@ def version(state: State):
version_info += f"Latest OSDU Cli Version {latest_version}\n" version_info += f"Latest OSDU Cli Version {latest_version}\n"
if current_version != latest_version: if current_version != latest_version:
version_info += f"\b\n\033[33mWARNING: You are using osdu cli version {current_version}; however version {latest_version} is available.\033[39m" # noqa: E501 pylint: disable=line-too-long version_info += f"\b\n\033[33mWARNING: You are using osdu cli version {current_version}; however version {latest_version} is available.\033[39m" # noqa: E501 pylint: disable=line-too-long
version_info += "\b\n\033[33mYou should consider upgrading via the 'pip install -U osdu-cli' command\033[39m" # noqa: E501 pylint: disable=line-too-long version_info += "\b\n\033[33mYou should consider upgrading via the 'pip install -U osducli' command\033[39m" # noqa: E501 pylint: disable=line-too-long
else: else:
version_info += "Latest OSDU Cli Version - unable to check!\n" version_info += "Latest OSDU Cli Version - unable to check!\n"
......
...@@ -52,7 +52,7 @@ class StatusTests(BaseTestCase): ...@@ -52,7 +52,7 @@ class StatusTests(BaseTestCase):
delete(state, _id) delete(state, _id)
mock_cli_delete.assert_called_once_with("storage_url", "records/" + _id) mock_cli_delete.assert_called_once_with("storage_url", "records/" + _id, [200, 204])
# def test_with_output(self): # def test_with_output(self):
# """Test json output""" # """Test json output"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment