fix: correct vllm models-check test name and stripe cancel boolean (#270)

- vllm: rename test_empty_models_is_a_failure to
  test_models_check_parses_from_stub and fix its misleading docstring;
  it asserts positive-path parsing of the stub's served model list, not an
  empty-models failure.
- stripe: pass cancel_at_period_end as the boolean True instead of the
  string 'true', and normalize booleans to lowercase true/false during
  form encoding so the wire payload stays Stripe-compatible.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Magnus Hedemark
2026-08-03 20:37:46 -04:00
committed by GitHub
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent 3256a87bcb
commit 0ff373467c
2 changed files with 14 additions and 7 deletions
+12 -3
View File
@@ -48,8 +48,17 @@ def get_api_key() -> str:
return key return key
def _encode_form_fields(fields: Dict[str, Any]) -> bytes:
"""Encode form fields, mapping booleans to Stripe's lowercase true/false."""
normalized = {
key: "true" if value is True else "false" if value is False else value
for key, value in fields.items()
}
return urllib.parse.urlencode(normalized).encode("utf-8")
def api_request(method: str, path: str, api_key: str, def api_request(method: str, path: str, api_key: str,
fields: Optional[Dict[str, str]] = None) -> Dict[str, Any]: fields: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
base = f"{API_BASE}/{path.lstrip('/')}" base = f"{API_BASE}/{path.lstrip('/')}"
if fields and method == "GET": if fields and method == "GET":
query = "&".join(f"{key}={urllib.parse.quote(str(value))}" for key, value in fields.items()) query = "&".join(f"{key}={urllib.parse.quote(str(value))}" for key, value in fields.items())
@@ -57,7 +66,7 @@ def api_request(method: str, path: str, api_key: str,
data = None data = None
elif fields: elif fields:
url = base url = base
data = urllib.parse.urlencode(fields).encode("utf-8") data = _encode_form_fields(fields)
else: else:
url = base url = base
data = None data = None
@@ -168,7 +177,7 @@ def cmd_subscriptions_cancel(args: argparse.Namespace, api_key: str) -> Dict[str
# setting cancel_at_period_end back to false) rather than cancelling # setting cancel_at_period_end back to false) rather than cancelling
# immediately. # immediately.
payload = api_request("POST", f"subscriptions/{args.subscription_id}", api_key, payload = api_request("POST", f"subscriptions/{args.subscription_id}", api_key,
{"cancel_at_period_end": "true"}) {"cancel_at_period_end": True})
if payload.get("cancel_at_period_end") is not True: if payload.get("cancel_at_period_end") is not True:
raise StripeError( raise StripeError(
"Stripe did not confirm the cancellation (cancel_at_period_end is " "Stripe did not confirm the cancellation (cancel_at_period_end is "
+2 -4
View File
@@ -220,14 +220,12 @@ class ProbeTests(unittest.TestCase):
finally: finally:
large.stop() large.stop()
def test_empty_models_is_a_failure(self): def test_models_check_parses_from_stub(self):
# A server that responds 200 but lists no models must fail the models check. """The models check parses the stub's served model list (positive path)."""
proc = run_script( proc = run_script(
"--url", f"http://127.0.0.1:{self.server.port}", "--check", "models", "--json" "--url", f"http://127.0.0.1:{self.server.port}", "--check", "models", "--json"
) )
payload = load_json(proc) payload = load_json(proc)
# Stub lists test-model, so this is a sanity assertion on parsing, not a
# negative-path test; the negative path is covered by test_unreachable_server.
self.assertEqual(payload["checks"][0]["ok"], True) self.assertEqual(payload["checks"][0]["ok"], True)