diff --git a/src/composer/cli/utilities.py b/src/composer/cli/utilities.py index 199ed095..c8c6f65b 100644 --- a/src/composer/cli/utilities.py +++ b/src/composer/cli/utilities.py @@ -73,9 +73,9 @@ def handle_api_result(result, show_json=False): # What's the rc? If status is present, use that # If not, use length of errors if "status" in result: - rc = bool(not result["status"]) + rc = int(not result["status"]) else: - rc = bool(len(result.get("errors", [])) > 0) + rc = int(len(result.get("errors", [])) > 0) # Caller should return if showing json, or status was present and False exit_now = show_json or ("status" in result and rc) diff --git a/tests/composer/test_utilities.py b/tests/composer/test_utilities.py index 7bc9c935..d2d02337 100644 --- a/tests/composer/test_utilities.py +++ b/tests/composer/test_utilities.py @@ -52,11 +52,13 @@ class CliUtilitiesTest(unittest.TestCase): """Test a result with no status and no error fields""" result = {"foo": "bar"} self.assertEqual(handle_api_result(result, show_json=False), (0, False)) + self.assertTrue(handle_api_result(result, show_json=False)[0] is 0) def test_api_result_2(self): """Test a result with errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field""" result = {"foo": "bar", "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} self.assertEqual(handle_api_result(result, show_json=False), (1, False)) + self.assertTrue(handle_api_result(result, show_json=False)[0] is 1) def test_api_result_3(self): """Test a result with status=True, and errors=[]"""