@@ -82,6 +82,31 @@ async def fake_request(method: str, url: httpx.URL, **kwargs: object) -> httpx.R
8282 assert result .columns [0 ].name == "id"
8383
8484
85+ def test_get_table_schema_quotes_table_name_path_segment () -> None :
86+ async def scenario () -> dict [str , object ]:
87+ captured : dict [str , object ] = {}
88+
89+ async def fake_request (method : str , url : httpx .URL , ** kwargs : object ) -> httpx .Response :
90+ captured ["method" ] = method
91+ captured ["url" ] = str (url )
92+ captured ["kwargs" ] = kwargs
93+ return httpx .Response (200 , json = {"table_name" : "analytics/events" , "columns" : []})
94+
95+ async with InsforgeClient (
96+ base_url = "https://example.com" ,
97+ api_key = "ins_test" ,
98+ ) as client :
99+ client .http_client .request = fake_request # type: ignore[method-assign]
100+ result = await client .database .get_table_schema ("analytics/events" )
101+ assert isinstance (result , DatabaseTableSchemaResponse )
102+ return captured
103+
104+ captured = asyncio .run (scenario ())
105+
106+ assert captured ["method" ] == "GET"
107+ assert captured ["url" ] == "https://example.com/api/database/tables/analytics%2Fevents/schema"
108+
109+
85110def test_create_table_uses_post_schema_endpoint_and_serializes_request_body () -> None :
86111 async def scenario () -> tuple [object , dict [str , object ]]:
87112 captured : dict [str , object ] = {}
@@ -164,6 +189,22 @@ async def fake_request(method: str, url: httpx.URL, **kwargs: object) -> httpx.R
164189 assert result .table_name == "posts"
165190
166191
192+ def test_update_table_schema_rejects_empty_mutation_request () -> None :
193+ async def scenario () -> None :
194+ async with InsforgeClient (
195+ base_url = "https://example.com" ,
196+ api_key = "ins_test" ,
197+ ) as client :
198+ await client .database .update_table_schema ("posts" )
199+
200+ try :
201+ asyncio .run (scenario ())
202+ except ValueError as exc :
203+ assert str (exc ) == "update_table_schema requires at least one schema operation"
204+ else :
205+ raise AssertionError ("update_table_schema should reject empty mutation requests" )
206+
207+
167208def test_update_table_schema_uses_patch_schema_endpoint_and_serializes_request_body () -> None :
168209 async def scenario () -> tuple [object , dict [str , object ]]:
169210 captured : dict [str , object ] = {}
0 commit comments