10
10
DEFAULT_GLOBAL_SEARCH_LIMIT ,
11
11
GlobalSearchOutput ,
12
12
ItemsGroup ,
13
- global_search ,
13
+ find_ids_by_name ,
14
14
)
15
15
16
16
@@ -234,6 +234,20 @@ def test_from_api_responses(self, parsed_global_search_response):
234
234
# Check group counts
235
235
for group in result .groups .values ():
236
236
assert group .count == 1
237
+ if group .type == 'table' :
238
+ assert group .items [0 ].additional_info ['bucket_id' ] is not None
239
+ assert group .items [0 ].additional_info ['bucket_name' ] is not None
240
+ elif group .type == 'configuration' :
241
+ assert group .items [0 ].additional_info ['component_id' ] is not None
242
+ assert group .items [0 ].additional_info ['component_name' ] is not None
243
+ elif group .type == 'configuration-row' :
244
+ assert group .items [0 ].additional_info ['component_id' ] is not None
245
+ assert group .items [0 ].additional_info ['component_name' ] is not None
246
+ assert group .items [0 ].additional_info ['configuration_id' ] is not None
247
+ assert group .items [0 ].additional_info ['configuration_name' ] is not None
248
+ elif group .type == 'flow' :
249
+ assert group .items [0 ].additional_info ['component_id' ] is not None
250
+ assert group .items [0 ].additional_info ['component_name' ] is not None
237
251
238
252
def test_from_api_responses_empty (self ):
239
253
"""Test creating answer from empty API response."""
@@ -246,11 +260,11 @@ def test_from_api_responses_empty(self):
246
260
247
261
248
262
class TestGlobalSearchTool :
249
- """Test cases for the global_search tool function."""
263
+ """Test cases for the find_ids_by_name tool function."""
250
264
251
265
@pytest .mark .asyncio
252
266
async def test_global_search_success (
253
- self , mocker : MockerFixture , mcp_context_client : Context , mock_global_search_response
267
+ self , mocker : MockerFixture , mcp_context_client : Context , mock_global_search_response : dict [ str , Any ]
254
268
):
255
269
"""Test successful global search."""
256
270
keboola_client = KeboolaClient .from_state (mcp_context_client .session .state )
@@ -259,7 +273,7 @@ async def test_global_search_success(
259
273
mock_response = GlobalSearchResponse .model_validate (mock_global_search_response )
260
274
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
261
275
262
- result = await global_search (
276
+ result = await find_ids_by_name (
263
277
ctx = mcp_context_client ,
264
278
name_prefixes = ['test' , 'table' ],
265
279
item_types = ('table' , 'configuration' ),
@@ -270,6 +284,16 @@ async def test_global_search_success(
270
284
assert isinstance (result , GlobalSearchOutput )
271
285
assert result .counts ['table' ] == 1
272
286
assert result .counts ['configuration' ] == 1
287
+ assert result .counts ['configuration-row' ] == 1
288
+ assert result .counts ['flow' ] == 1
289
+ assert len (result .groups ['table' ].items ) == 1
290
+ assert len (result .groups ['configuration' ].items ) == 1
291
+ assert result .groups ['configuration-row' ].count == 1
292
+ assert result .groups ['flow' ].count == 1
293
+ assert result .groups ['table' ].items [0 ].id == mock_response .items [0 ].id
294
+ assert result .groups ['configuration' ].items [0 ].id == mock_response .items [1 ].id
295
+ assert result .groups ['configuration-row' ].items [0 ].id == mock_response .items [2 ].id
296
+ assert result .groups ['flow' ].items [0 ].id == mock_response .items [3 ].id
273
297
274
298
# Verify the storage client was called with correct parameters
275
299
keboola_client .storage_client .global_search .assert_called_once_with (
@@ -287,7 +311,7 @@ async def test_global_search_default_parameters(
287
311
mock_response = GlobalSearchResponse .model_validate (mock_global_search_response )
288
312
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
289
313
290
- result = await global_search (ctx = mcp_context_client , name_prefixes = ['test' ])
314
+ result = await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ])
291
315
292
316
assert isinstance (result , GlobalSearchOutput )
293
317
@@ -308,7 +332,7 @@ async def test_global_search_limit_out_of_range(
308
332
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
309
333
310
334
# Test with limit too high
311
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 200 )
335
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 200 )
312
336
313
337
# Should use default limit
314
338
keboola_client .storage_client .global_search .assert_called_with (
@@ -317,7 +341,7 @@ async def test_global_search_limit_out_of_range(
317
341
318
342
# Test with limit too low
319
343
keboola_client .storage_client .global_search .reset_mock ()
320
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 0 )
344
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 0 )
321
345
322
346
# Should use default limit
323
347
keboola_client .storage_client .global_search .assert_called_with (
@@ -335,7 +359,7 @@ async def test_global_search_negative_offset(
335
359
mock_response = GlobalSearchResponse .model_validate (mock_global_search_response )
336
360
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
337
361
338
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' ], offset = - 10 )
362
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ], offset = - 10 )
339
363
340
364
# Should use offset 0
341
365
keboola_client .storage_client .global_search .assert_called_once_with (
@@ -349,7 +373,7 @@ async def test_global_search_feature_not_enabled(self, mocker: MockerFixture, mc
349
373
keboola_client .storage_client .is_enabled = mocker .AsyncMock (return_value = False )
350
374
351
375
with pytest .raises (ValueError , match = 'Global search is not enabled' ):
352
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' ])
376
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ])
353
377
354
378
@pytest .mark .asyncio
355
379
async def test_global_search_joins_prefixes (
@@ -362,7 +386,7 @@ async def test_global_search_joins_prefixes(
362
386
mock_response = GlobalSearchResponse .model_validate (mock_global_search_response )
363
387
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
364
388
365
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' , 'table' , 'data' ])
389
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' , 'table' , 'data' ])
366
390
367
391
# Should join with spaces
368
392
keboola_client .storage_client .global_search .assert_called_once_with (
@@ -380,7 +404,7 @@ async def test_global_search_with_valid_limit(
380
404
mock_response = GlobalSearchResponse .model_validate (mock_global_search_response )
381
405
keboola_client .storage_client .global_search = mocker .AsyncMock (return_value = mock_response )
382
406
383
- await global_search (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 75 )
407
+ await find_ids_by_name (ctx = mcp_context_client , name_prefixes = ['test' ], limit = 75 )
384
408
385
409
# Should use the provided limit
386
410
keboola_client .storage_client .global_search .assert_called_once_with (
0 commit comments