From c36b7fcac21fbf954e79c580b692337adde64a80 Mon Sep 17 00:00:00 2001 From: Mark Rawlings Date: Thu, 18 Jul 2024 16:40:50 +0100 Subject: [PATCH] Remove "<", ">" from default `uninstallReason` (#137) The OpsRamp API actively rejects an `uninstallReason` that contains the characters "<", or ">". Remove those character to make the default operation valid. Both forms have been verified using Postman: - `""` - is rejected - `"Not specified"` - is accepted - Fix associated unit test. Drive-by: - add another comma to make 'black' happy --- opsramp/integrations.py | 2 +- tests/test_integration.py | 2 +- tests/test_script.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opsramp/integrations.py b/opsramp/integrations.py index 1093639..74077ac 100755 --- a/opsramp/integrations.py +++ b/opsramp/integrations.py @@ -84,7 +84,7 @@ def create(self, type_name, definition): resp = self.creator_api.post(type_name, json=definition) return resp - def delete(self, uuid, uninstall_reason=""): + def delete(self, uuid, uninstall_reason="Not specified"): json_payload = {"uninstallReason": uninstall_reason} return self.api.delete(suffix=uuid, json=json_payload) diff --git a/tests/test_integration.py b/tests/test_integration.py index b21574f..83ffe6d 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -128,7 +128,7 @@ def test_instance_delete(self): # Test that the delete function inserts a default reason # if we don't provide one. - expected_send = {"uninstallReason": ""} + expected_send = {"uninstallReason": "Not specified"} with requests_mock.Mocker() as m: adapter = m.delete(url, json=expected_response, complete_qs=True) actual_response = group.delete(uuid=thisid) diff --git a/tests/test_script.py b/tests/test_script.py index 8f24e5a..944d6af 100644 --- a/tests/test_script.py +++ b/tests/test_script.py @@ -48,7 +48,7 @@ def test_mkBadParameter(self): name="pname", description="pdesc", datatype="STRING", - optional=True + optional=True, # deliberately missing default value )