Skip to content

Commit 42c80c9

Browse files
committed
fix(httpclient): json output
Signed-off-by: Chris Snow <[email protected]>
1 parent 72eba91 commit 42c80c9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

hpecp/cli/httpclient.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ def get(
5151
http_method="get",
5252
description="CLI HTTP GET",
5353
)
54-
print(response.text, file=sys.stdout)
54+
55+
try:
56+
response_info = json.dumps(response.json())
57+
except Exception:
58+
response_info = response.text
59+
60+
print(response_info, file=sys.stdout)
5561

5662
@base.intercept_exception
5763
def delete(

tests/cli_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def test_get(self, mock_get, mock_post):
334334
hpecp = self.cli.CLI()
335335
hpecp.httpclient.get(url="/some/url")
336336

337-
self.assertEqual(self.out.getvalue(), '{"foo":"bar"}\n')
337+
self.assertEqual(self.out.getvalue(), '{"foo": "bar"}\n')
338338

339339
def mocked_requests_delete(*args, **kwargs):
340340
if args[0] == "https://127.0.0.1:8080/some/url":

0 commit comments

Comments
 (0)