From 90d1af57f1b36c0e44c455a91a9c278053c85284 Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Sat, 24 Oct 2026 03:56:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D0=B2=D0=BE=D0=B7=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=82=D0=B5=D1=81=D1=82=20=D1=81=D0=BE=D0=B2=D0=BC?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D1=81?= =?UTF-8?q?=20jira-agent=20v14=20=D0=BF=D0=BE=20HTTP=20(I-3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- tests/test_agents.py | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_agents.py b/tests/test_agents.py index f7f4370..1840ed9 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -285,3 +285,48 @@ def test_agent_cannot_touch_foreign_command(hub_server_two_modules): assert e.value.status == 404 assert jira.get(f"/agent/commands/{jc['id']}")["id"] == jc["id"] assert stub.post(f"/agent/commands/{sc['id']}/result", {"status": "done", "result": {}})["status"] == "done" + + +def test_v14_agent_over_http_on_v6_base(tmp_path): + """I-3: база v6 → HTTP-сервер → прежний токен T-agent в форме запросов jira-agent v14, без прямых вызовов обработчиков.""" + import json + import threading + from pathlib import Path + + from jira_hub.core.client import HubClient + + make_v6_db(tmp_path / "hub.sqlite") + old = tmp_path / "release" # прежняя раскладка v14: release/agent.py + old.mkdir() + (old / "agent.py").write_text("AGENT_VERSION = 14\n", encoding="utf-8") + release.publish(old, old / "agent.py") + h = api.Hub(tmp_path / "hub.sqlite", backups_dir=tmp_path / "backups", release_root=old) + h.claim_wait = 0 + srv = api.make_server(h, "127.0.0.1", 0) + th = threading.Thread(target=srv.serve_forever, daemon=True) + th.start() + try: + a = HubClient(f"http://127.0.0.1:{srv.server_port}", "T-agent") + out = a.post("/agent/claim", {"agent_version": 14, "settings_version": 1, "last_jira_call_at": "2026-10-24T10:00:00+00:00", + "update_state": None, "launcher_version": 2}) + assert out["command"] is None and out["agent_release"]["version"] == 14 + conn = h.conn() + try: + row = conn.execute("SELECT last_call_at, agent_version FROM agent_status WHERE agent = 'jira'").fetchone() + assert row["last_call_at"] == "2026-10-24T10:00:00+00:00" and row["agent_version"] == "14" + finally: + conn.close() + expected = json.loads((Path(__file__).parent / "fixtures" / "settings_v6.json").read_text(encoding="utf-8"))["agent_keys"] + got = a.get("/agent/settings") + assert set(got) == set(expected) - {"board_id"} + assert a.get("/agent/release")["version"] == 14 + assert a.post("/agent/state", {"issues": [{"key": "A-1", "summary": "Т", "labels": []}], "links": [], + "neighbor_keys": []}) == {"issues": 1, "links": 0} + assert a.get("/agent/known-keys")["keys"] == ["A-1"] + item = {"history_id": "5001", "seq": 0, "key": "A-1", "created": "2026-10-22T09:00:00.000+0300", "author": "П", + "field_id": "status", "field_name": "status", "from": "3", "from_string": "a", "to": "4", "to_string": "b"} + assert a.post("/agent/history", {"command_id": None, "changes": [item]}) == {"accepted": 1, "duplicates": 0} + finally: + srv.shutdown() + srv.server_close() + th.join(5)