-
Notifications
You must be signed in to change notification settings - Fork 18
Ai 1172 Add Global Search Tool tests #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mariankrotil
merged 22 commits into
AI-1172-global-search
from
AI-1172-global-search-tests
Jul 14, 2025
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bac6149
AI-1172 test: add tests for global search tool and from_api_response …
mariankrotil 426c43d
AI-1172 test: add end2end integtest for global search tool
mariankrotil 09fa4eb
AI-1172 test: skip integtest for global search tool if it is not enab…
mariankrotil 5b2ed8d
Merge branch 'AI-1172-global-search' into AI-1172-global-search-tests
mariankrotil 59cd32a
AI-1172 chore: update version
mariankrotil 2dde986
AI-1172 refactor: update wrt changes
mariankrotil 588d9c3
AI-1172 refactor: move find_component_id tool to search tools
mariankrotil a2343a1
Merge branch 'AI-1172-global-search' into AI-1172-global-search-tests
mariankrotil 438a5c9
AI-1172 test: update tests wrt changes of AI-1172-global-search-tool
mariankrotil efc7bbc
Merge AI-1172-tests to AI-1172-ref
mariankrotil 4f13df9
AI-1172 fix: add await for coroutine method
mariankrotil cc9bb31
Merge branch 'AI-1172-global-search-tests' into AI-1172-search-tools-ref
mariankrotil 51147ff
AI-1172 chore: update version
mariankrotil cab25d9
Merge branch 'AI-1172-global-search' into AI-1172-global-search-tests
mariankrotil 419a815
AI-1172 refactor: rename variables and parameters wrt review and merge
mariankrotil 6759edb
AI-1172 fix: fix the config name to align with other test names (star…
mariankrotil b426187
AI-1172 test: revert config name change, use rather searching for oth…
mariankrotil b87a38a
AI-1172 test: rename the test config name to 'test_config1' to align …
mariankrotil bdb322d
Merge branch 'AI-1172-global-search' into AI-1172-global-search-tests
mariankrotil eded2ae
AI-1172 test: update tests wrt merge and add other testing values
mariankrotil f997732
Merge AI-1172-global-search-tests to AI-1172-refactor
mariankrotil e0be650
Merge pull request #204 from keboola/AI-1172-search-tools-ref
mariankrotil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import logging | ||
|
||
import pytest | ||
from fastmcp import Context | ||
|
||
from integtests.conftest import BucketDef, ConfigDef, TableDef | ||
from keboola_mcp_server.client import KeboolaClient | ||
from keboola_mcp_server.tools.search import GlobalSearchOutput, global_search | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_global_search_end_to_end( | ||
keboola_client: KeboolaClient, | ||
mcp_context: Context, | ||
buckets: list[BucketDef], | ||
tables: list[TableDef], | ||
configs: list[ConfigDef], | ||
) -> None: | ||
""" | ||
Test the global_search tool end-to-end by searching for entities that exist in the test project. | ||
This verifies that the search returns expected results for buckets, tables, and configurations. | ||
""" | ||
|
||
# skip this test if the global search is not available | ||
if not await keboola_client.storage_client.is_enabled('global-search'): | ||
LOG.warning('Global search is not available. Please enable it in the project settings.') | ||
pytest.skip('Global search is not available. Please enable it in the project settings.') | ||
|
||
# Search for test entities by name prefix 'test' which should match our test data | ||
result = await global_search( | ||
ctx=mcp_context, name_prefixes=['test'], entity_types=tuple(), limit=50, offset=0 # Search all types | ||
) | ||
|
||
# Verify the result structure | ||
assert isinstance(result, GlobalSearchOutput) | ||
assert isinstance(result.counts, dict) | ||
assert isinstance(result.type_groups, list) | ||
assert 'total' in result.counts | ||
|
||
# Verify we found some results | ||
assert result.counts['total'] > 0, 'Should find at least some test entities' | ||
|
||
# Create sets of expected IDs for verification | ||
expected_bucket_ids = {bucket.bucket_id for bucket in buckets} | ||
expected_table_ids = {table.table_id for table in tables} | ||
expected_config_ids = {config.configuration_id for config in configs if config.configuration_id} | ||
|
||
# Check that we can find test buckets | ||
bucket_groups = [group for group in result.type_groups if group.group_type == 'bucket'] | ||
if bucket_groups: | ||
bucket_group = bucket_groups[0] | ||
found_bucket_ids = {item.id for item in bucket_group.group_items} | ||
# At least some test buckets should be found | ||
assert found_bucket_ids.intersection(expected_bucket_ids), 'Should find at least one test bucket' | ||
|
||
# Check that we can find test tables | ||
table_groups = [group for group in result.type_groups if group.group_type == 'table'] | ||
if table_groups: | ||
table_group = table_groups[0] | ||
found_table_ids = {item.id for item in table_group.group_items} | ||
# At least some test tables should be found | ||
assert found_table_ids.intersection(expected_table_ids), 'Should find at least one test table' | ||
|
||
# Check that we can find test configurations | ||
config_groups = [group for group in result.type_groups if group.group_type == 'configuration'] | ||
if config_groups: | ||
config_group = config_groups[0] | ||
found_config_ids = {item.id for item in config_group.group_items} | ||
# At least some test configurations should be found | ||
assert found_config_ids.intersection(expected_config_ids), 'Should find at least one test configuration' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.