Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(e2e): require a 200 inside the regenerate grace window and drop the helper docstrings

Yuneng Jiang45cc2ed08225
diff --git a/tests/e2e/access_control/test_access_control_e2e.py b/tests/e2e/access_control/test_access_control_e2e.py
index c30dadc49ae..9d01f2915e7 100644
--- a/tests/e2e/access_control/test_access_control_e2e.py
+++ b/tests/e2e/access_control/test_access_control_e2e.py
@@ -76,8 +76,6 @@ class TestAccessControl:
def test_llm_api_routes_group_grants_every_llm_endpoint(
self, client: AccessControlClient, resources: ResourceManager
) -> None:
- """allowed_routes=["llm_api_routes"] names a route group, not a path: one
- entry must open every LLM endpoint while the management routes stay shut."""
key = client.llm_only_key()
resources.defer(lambda: client.delete_key(key))
@@ -89,7 +87,9 @@ class TestAccessControl:
f"200 must carry a real completion, not an error envelope: {chat.body[:300]}"
)
- embedding = unwrap(client.proxy.embed(key, EmbedBody(model=EMBEDDING_MODEL, input=f"route group {unique_marker()}")))
+ embedding = unwrap(
+ client.proxy.embed(key, EmbedBody(model=EMBEDDING_MODEL, input=f"route group {unique_marker()}"))
+ )
assert embedding.model, f"llm_api_routes key reached /embeddings but got no model back: {embedding}"
denied = client.create_model_status(key, f"e2e-route-group-{unique_marker()}")
diff --git a/tests/e2e/management/test_key_management_e2e.py b/tests/e2e/management/test_key_management_e2e.py
index d4347b8c0e7..8b7d5f0eb6f 100644
--- a/tests/e2e/management/test_key_management_e2e.py
+++ b/tests/e2e/management/test_key_management_e2e.py
@@ -90,8 +90,6 @@ def _is_budget_block(outcome: StreamingResponse) -> bool:
def _spend_until_budget_blocks(client: ManagementClient, key: str) -> None:
- """Drive paid calls until the key's max_budget refuses one. The first call spends,
- the reservation counter trips the cap, and the next call is the 429."""
for _ in range(40):
outcome = client.chat_status(key, SPEND_MODEL, f"spend {unique_marker()}")
if _is_budget_block(outcome):
@@ -105,8 +103,6 @@ def _spend_until_budget_blocks(client: ManagementClient, key: str) -> None:
def _settled_spend(client: ManagementClient, key: str) -> float | None:
- """The key's recorded spend once it is positive and unchanged across two reads a
- poll interval apart, so no batched spend write is still in flight when we reset."""
first = client.proxy.key_info(key).spend or 0.0
time.sleep(client.proxy.poll_interval)
second = client.proxy.key_info(key).spend or 0.0
diff --git a/tests/e2e/management/test_management_e2e.py b/tests/e2e/management/test_management_e2e.py
index eace8f2e3b4..476165b715d 100644
--- a/tests/e2e/management/test_management_e2e.py
+++ b/tests/e2e/management/test_management_e2e.py
@@ -12,6 +12,7 @@ from __future__ import annotations
import math
import time
from collections.abc import Callable
+from typing import Final
import pytest
@@ -377,12 +378,12 @@ class TestKeyRegeneration:
new_key = client.regenerate_key(old_key, grace_period=REGENERATE_GRACE_PERIOD)
resources.defer(lambda: client.proxy.delete_key(new_key))
- revoke_at = time.monotonic() + REGENERATE_GRACE_SECONDS
+ revoke_at: Final = time.monotonic() + REGENERATE_GRACE_SECONDS
assert new_key != old_key, "regenerate returned the same key string, so no rotation happened"
def old_accepted() -> bool | None:
outcome = client.chat_status(old_key, "gpt-5.5", f"say hi {unique_marker()}")
- return True if outcome.status_code != 401 else None
+ return True if outcome.ok else None
_ = _poll(client, old_accepted, "old key was rejected 401 inside its grace period at the deadline")
assert time.monotonic() < revoke_at, (