Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix: address 7 third-round Copilot review comments

fabio.mantelmacher05eae688be05
diff --git a/wiremock/agent-harness/cli_anything/wiremock/core/stubs.py b/wiremock/agent-harness/cli_anything/wiremock/core/stubs.py
index 79249e7de..37e91c6e0 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/core/stubs.py
+++ b/wiremock/agent-harness/cli_anything/wiremock/core/stubs.py
@@ -63,7 +63,7 @@ class StubsManager:
) -> dict:
"""Helper: create a simple stub quickly."""
response = {"status": status}
- if body:
+ if body is not None:
response["body"] = body
response["headers"] = {"Content-Type": content_type}
mapping = {
diff --git a/wiremock/agent-harness/cli_anything/wiremock/tests/test_full_e2e.py b/wiremock/agent-harness/cli_anything/wiremock/tests/test_full_e2e.py
index 78a854573..c612f4ec7 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/tests/test_full_e2e.py
+++ b/wiremock/agent-harness/cli_anything/wiremock/tests/test_full_e2e.py
@@ -7,6 +7,7 @@ Tests for --help and argument parsing work without a server.
"""
import json
import os
+import shutil
import subprocess
import sys
import unittest
@@ -25,9 +26,9 @@ def _resolve_cli(name: str) -> list:
"""
if os.environ.get(CLI_ENV_KEY):
return [name]
- result = subprocess.run(["which", name], capture_output=True, text=True)
- if result.returncode == 0:
- return [result.stdout.strip()]
+ found = shutil.which(name)
+ if found:
+ return [found]
# Fall back to running the module directly
return [sys.executable, "-m", "cli_anything.wiremock.wiremock_cli"]
@@ -243,8 +244,8 @@ class TestLiveServer(unittest.TestCase):
"--body", '{"hello":"world"}')
self.assertEqual(result.returncode, 0)
created = json.loads(result.stdout)
- self.assertEqual(created["status"], "ok")
- stub_id = created["data"]["id"]
+ self.assertIn("id", created)
+ stub_id = created["id"]
self.assertIsNotNone(stub_id)
# List and find it
@@ -264,13 +265,13 @@ class TestLiveServer(unittest.TestCase):
result = _run("--json", "stub", "create", json.dumps(mapping))
self.assertEqual(result.returncode, 0)
data = json.loads(result.stdout)
- self.assertEqual(data["status"], "ok")
+ self.assertIn("id", data)
@skip_no_server
def test_stub_get(self):
# Create a stub first
r = _run("--json", "stub", "quick", "GET", "/get-test", "200")
- stub_id = json.loads(r.stdout)["data"]["id"]
+ stub_id = json.loads(r.stdout)["id"]
result = _run("--json", "stub", "get", stub_id)
self.assertEqual(result.returncode, 0)
@@ -281,7 +282,7 @@ class TestLiveServer(unittest.TestCase):
def test_stub_delete(self):
# Create then delete
r = _run("--json", "stub", "quick", "GET", "/delete-me", "200")
- stub_id = json.loads(r.stdout)["data"]["id"]
+ stub_id = json.loads(r.stdout)["id"]
result = _run("--json", "stub", "delete", stub_id)
self.assertEqual(result.returncode, 0)
diff --git a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
index e8aada179..034132fd0 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
+++ b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
@@ -50,15 +50,15 @@ from cli_anything.wiremock.core.stubs import StubsManager
def cli(ctx, host, port, scheme, user, password, json_mode):
"""WireMock CLI — manage stubs, requests, scenarios, and recordings."""
session = Session.from_env()
- if host:
+ if host is not None:
session.host = host
- if port:
+ if port is not None:
session.port = port
- if scheme:
+ if scheme is not None:
session.scheme = scheme
- if user:
+ if user is not None:
session.username = user
- if password:
+ if password is not None:
session.password = password
client = WireMockClient(
host=session.host,