test(openrouter): cover rerank error-handling edge cases

Cover map_cohere_rerank_params with no optional params and
get_error_class fallbacks for unparseable or non-OpenRouter-shaped
error bodies, taking the new transformation module to 100% patch
coverage.
This commit is contained in:
parijat1222q 2026-10-22 05:00:32 +05:30
parent 5813929e43
commit de12c9abc1

View file

@ -200,6 +200,41 @@ def test_get_error_class_extracts_openrouter_error_message():
assert error.status_code == 401
def test_map_cohere_rerank_params_returns_empty_dict_when_params_are_none():
mapped = _config().map_cohere_rerank_params(
non_default_params=None,
model="cohere/rerank-v3.5",
drop_params=False,
query="q",
documents=["a", "b"],
)
assert mapped == {}
def test_get_error_class_keeps_unparseable_error_message():
error = _config().get_error_class(
error_message="upstream timeout",
status_code=500,
headers={},
)
assert error.message == "upstream timeout"
assert error.status_code == 500
def test_get_error_class_keeps_original_message_without_error_payload():
raw = json.dumps({"detail": "not an OpenRouter error shape"})
error = _config().get_error_class(
error_message=raw,
status_code=400,
headers={},
)
assert error.message == raw
@pytest.mark.respx(assert_all_called=True)
@pytest.mark.asyncio
@pytest.mark.parametrize("sync_mode", [True, False])