Skip to content

Commit c9f0e61

Browse files
authored
Forms follow-up: fix update_form docstring, test cleanup, and submission ordering (#48)
1 parent cf5a339 commit c9f0e61

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/nc_mcp_server/tools/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ async def update_form(form_id: int, key_value_pairs: dict[str, Any]) -> str:
202202
expires (unix timestamp, 0 = never), showExpiration (bool),
203203
state (0=active, 1=closed, 2=archived), maxSubmissions (int,
204204
0 = unlimited), submissionMessage (str), access (object with
205-
permitAllUsers/showToAllUsers), fileFormat, filePath.
205+
permitAllUsers/showToAllUsers), fileFormat, path (destination
206+
folder for the generated submissions spreadsheet — must be sent
207+
together with fileFormat to (re)link the form to a file).
206208
207209
Returns:
208210
JSON of the updated form (refetched after the patch for convenience).

tests/integration/test_forms.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class TestFormLifecycle:
5151
@pytest.mark.asyncio
5252
async def test_create_produces_form_with_id(self, nc_mcp: McpTestHelper) -> None:
5353
created = json.loads(await nc_mcp.call("create_form"))
54+
await nc_mcp.call("update_form", form_id=created["id"], key_value_pairs={"title": "mcp-test-create-id"})
5455
assert isinstance(created["id"], int)
5556
assert created["ownerId"] == "admin"
5657
assert created["hash"]
@@ -338,11 +339,12 @@ async def test_delete_single_submission(self, nc_mcp: McpTestHelper) -> None:
338339
await nc_mcp.call("submit_form", form_id=form_id, answers={str(q_id): ["two"]})
339340
listing = json.loads(await nc_mcp.call("list_submissions", form_id=form_id))
340341
assert listing["filteredSubmissionsCount"] == 2
341-
first_id = listing["submissions"][0]["id"]
342-
result = json.loads(await nc_mcp.call("delete_submission", form_id=form_id, submission_id=first_id))
343-
assert result == {"deleted_submission_id": first_id}
342+
target_id = min(s["id"] for s in listing["submissions"])
343+
result = json.loads(await nc_mcp.call("delete_submission", form_id=form_id, submission_id=target_id))
344+
assert result == {"deleted_submission_id": target_id}
344345
after = json.loads(await nc_mcp.call("list_submissions", form_id=form_id))
345346
assert after["filteredSubmissionsCount"] == 1
347+
assert all(s["id"] != target_id for s in after["submissions"])
346348

347349
@pytest.mark.asyncio
348350
async def test_delete_all_submissions(self, nc_mcp: McpTestHelper) -> None:

0 commit comments

Comments
 (0)