fix(контракт): mock — правки второго круга (R-03)

Закрыты находки второго круга: аренда строки проверяет срок, живая проверка ищется
по человеку (второе устройство берёт ту же), refresh учитывает свой срок, карточка
считает счётчики, в tools берутся только функции с описанием, запрошенная tool_choice
функция при отсутствии не подменяется чужой, срок кода — одна константа.

Проверки mock: 17, мутации правил краснеют; отпечаток набора обновлён.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-18 19:29:55 +10:00
co-authored by Claude Code
parent e089b22422
commit b2b9e9b545
4 changed files with 22 additions and 7 deletions
+12
View File
@@ -338,3 +338,15 @@ def test_expired_refresh_is_refused(device):
entry["refresh_expires"] = 0
r = c.post("/api/device/refresh", json={"refresh": token, "app_version": "0.2.2-rc.3"})
assert r.status_code == 401 and r.json()["code"] == "token_invalid"
def test_tool_choice_for_absent_function_makes_no_call(device):
c, h = device["client"], device["headers"]
r = c.post("/api/gateway/v1/chat/completions",
json={"model": "smeta", "messages": [{"role": "user", "content": "x"}],
"tools": [{"type": "function", "function": {
"name": "other_fn", "parameters": {"type": "object"}}}],
"tool_choice": {"type": "function",
"function": {"name": "find_base_price"}}},
headers=dict(h, **{"X-Tab-Id": "mock-tab-1"}))
assert "tool_calls" not in r.text and "Заглушка mock" in r.text