GData Server — Test Suites

The server has six pytest suites under ~/py/gdata-server: test_mcp_tools.py, test_json_robust.py, test_gdata_mcp_rest.py, test_patch_api.py, test_reorder.py, and test_mcp_transports.py all spin up their own in-process server and are fully self-contained. test_gdata.py is the exception -- see its section below.

test_mcp_tools.py — MCP tool coverage

Comprehensive coverage of every MCP tool call and operation variant. 119 tests (2026-07-08: added ops-shaped payload rejection to put, and apostrophe-escape repair regression tests to patch and batch).

Run: python -m pytest test_mcp_tools.py -v

Tools covered

get — basic get, get with include_block_ids, missing key (both modes)

put — returns rev + block_ids, if_rev match/mismatch (412), non-dict values, JSON-string unwrapping, ops-shaped payload rejection (both as native list and as a JSON string), list-of-dicts-without-op-key and empty-list still allowed

delete — existing key, non-existent key returns error

keys — returns sorted list, reflects creates and deletes

patch — append_block, insert_block, replace_block, delete_block, delete_blocks, patch_meta, insert_before, insert_after; block-ID and index addressing; if_rev guard (409); error cases; block-as-JSON-string with escaped-apostrophe repair

batch — multi-op, inserted_block_ids, if_rev guard, JSON-string ops unwrapping, ops-as-JSON-string with escaped-apostrophe repair, atomic rollback on failure, table_op embedded in batch, single rev increment

table_op — all 20 implemented ops: rename_column, insert_column (append / at position / after named / with values / with default), delete_column, move_column (to / after), reorder_columns, fill_column, set_columns, insert_row (list / dict / at end), append_row (list / dict), delete_row (by index / by index_col value), move_row, sort (asc / desc / multi-column), fill_row, set_cell (by name / index / null), set_caption, clear_caption, transpose, set_index, clear_index, replace (table-wide / column / no match), deduplicate (keep first / last / none / subset / no dups); block addressing by ID string; if_rev guard; error cases

list_tools — verifies all 7 tools are advertised

Design notes

Uses streamable HTTP transport only. Transport-level tests (SSE, cross-transport) live in test_mcp_transports.py.

All test keys live under test/mcp-tools/. The test DB is a temporary file; nothing touches the live notes store.

Autouse fixtures reset each test class's key before/after every test, so tests are independent.

Known interface gaps (2026-06-26)

Interface notes (2026-06-26)

table.deduplicate — implemented and passing. Was absent from the table_op tool description in list_tools() until 2026-06-26; now documented there.

Tests both SSE and Streamable HTTP transports, auth (401 without token), cross-transport visibility, and most patch/batch ops. Predates test_mcp_tools.py.

test_json_robust.py — _parse_json_robust unit tests (2026-07-08)

Direct unit tests of the shared _parse_json_robust helper, run against both copies (gdata_server.py and gdata_mcp_server.py) so a fix applied to only one shows up as a failure. 18 tests: plain apostrophes, escaped apostrophes (single/multiple/nested in ops payloads), a legitimately-escaped backslash followed by a literal apostrophe (must not be misdetected as the bug), apostrophe-repair combined with an unrelated bad escape (verifies the combined error message), and unrelated invalid JSON left unaffected. No server needed -- imports the function directly.

Run: python -m pytest test_json_robust.py -v

test_gdata_mcp_rest.py — gdata_mcp_server.py REST app (2026-07-08)

Integration tests for gdata_mcp_server.py's own REST HTTP surface (make_rest_app), covering two bugs: PUT ops-shaped payload rejection (plus confirming plain lists/strings/empty-lists/normal docs still store fine -- this is a general KV store, not JSONHTL-only), and REST batch apostrophe tolerance (a separate code path from the MCP batch tool, which has its own copy of the ops-string parsing). 13 tests.

Run: python -m pytest test_gdata_mcp_rest.py -v

test_patch_api.py and test_reorder.py — gdata_server.py REST surface

test_patch_api.py covers block-level POST /{key} patch operations against gdata_server.py (the standalone, non-MCP REST implementation) and the auto-reload middleware. 77 tests, including (2026-07-08) TestPutOpsShapeRejection and batch apostrophe/invalid-JSON cases in TestBatchOp -- gdata_server.py has its own separate copy of the ops-shape and apostrophe-repair fixes, mirroring gdata_mcp_server.py's.

test_reorder.py covers the reorder op (POST and PATCH /{key}) against gdata_mcp_server.py's REST app specifically.

Run: python -m pytest test_patch_api.py test_reorder.py -v

test_gdata.py — requires a live server (gotcha)

Older client-level test suite that expects a server already running at BASE_URL (default http://127.0.0.1:8020), unlike the other suites which spin up their own in-process server via a pytest fixture. Without a live server, 23 of its tests fail with requests.exceptions.ConnectionError -- this is expected/pre-existing, not a regression. Confirmed 2026-07-08 via git stash comparison before/after unrelated changes: same 23 failures either way. Start a server first (uvicorn gdata_server:app --port 8020) to run it properly, or just skip it and rely on the other suites.

Maintenance

Update test_mcp_tools.py whenever the MCP interface changes: new tools, new ops, new parameters, changed error behaviour. The tool descriptions in gdata_mcp_server.py list_tools() are the canonical interface spec.

version 2  ·  created 2026-06-26  ·  updated 2026-07-08  ·  tags gdata-server, testing, mcp