Cover the chunks fallbacks on agent update and YAML import

A blank chunks on update and an unparsable one on import both fall back
to the default.
This commit is contained in:
arc53-machine committed 2026-09-28 14:55:43 +01:00
1 parent c40f06e10b
commit 56aebc882c
2 files changed
+24

No files matched your search

+7
View File
@@ -183,6 +183,13 @@ def test_import_without_chunks_uses_the_default(pg_conn):
assert agent["chunks"] == 6
def test_import_with_invalid_chunks_uses_the_default(pg_conn):
user = "u_invalid_chunks"
result = apply_import(pg_conn, user, _doc(name="Odd Bot", _slug="odd-bot", chunks="lots"))
agent = AgentsRepository(pg_conn).get(result["agent_id"], user)
assert agent["chunks"] == 6
def test_import_keeps_explicit_chunks(pg_conn):
user = "u_explicit_chunks"
result = apply_import(pg_conn, user, _doc(name="Off Bot", _slug="off-bot", chunks=0))
@@ -648,6 +648,23 @@ class TestUpdateAgent:
field in msg and user in msg for msg in warnings
), f"no WARN naming field={field!r} and user={user!r}; got {warnings!r}"
def test_blank_chunks_resets_to_the_default(self, app, pg_conn):
from docsgpt.api.user.agents.routes import UpdateAgent
from docsgpt.storage.db.repositories.agents import AgentsRepository
user = "u-upd-blank-chunks"
agent = _seed_agent(pg_conn, user=user)
with _patch_db(pg_conn), app.test_request_context(
f"/api/update_agent/{agent['id']}",
method="PUT",
json={"name": "n", "description": "d", "status": "draft", "chunks": ""},
):
from flask import request
request.decoded_token = {"sub": user}
response = UpdateAgent().put(str(agent["id"]))
assert response.status_code == 200
assert AgentsRepository(pg_conn).get(str(agent["id"]), user)["chunks"] == 6
def test_invalid_chunks_returns_400(self, app, pg_conn):
from docsgpt.api.user.agents.routes import UpdateAgent