feat(proxy): add request parsing

This commit is contained in:
2026-01-02 13:57:09 -05:00
parent ba88ba01f3
commit caa435d972
2 changed files with 92 additions and 0 deletions

26
tests/unit/test_proxy.py Normal file
View File

@@ -0,0 +1,26 @@
import pytest
from grist_mcp.proxy import parse_proxy_request, ProxyRequest, ProxyError
def test_parse_proxy_request_valid_add_records():
body = {
"method": "add_records",
"table": "Orders",
"records": [{"item": "Widget", "qty": 10}],
}
request = parse_proxy_request(body)
assert request.method == "add_records"
assert request.table == "Orders"
assert request.records == [{"item": "Widget", "qty": 10}]
def test_parse_proxy_request_missing_method():
body = {"table": "Orders"}
with pytest.raises(ProxyError) as exc_info:
parse_proxy_request(body)
assert exc_info.value.code == "INVALID_REQUEST"
assert "method" in str(exc_info.value)