diff --git a/.changes/unreleased/added-20260209-171617.yaml b/.changes/unreleased/added-20260209-171617.yaml new file mode 100644 index 000000000..5ee9486c6 --- /dev/null +++ b/.changes/unreleased/added-20260209-171617.yaml @@ -0,0 +1,6 @@ +kind: added +body: Add new 'fab find' command for searching the Fabric catalog across workspaces +time: 2026-02-09T17:16:17.2056327+02:00 +custom: + Author: nschachter + AuthorLink: https://github.com/nschachter diff --git a/docs/commands/find.md b/docs/commands/find.md new file mode 100644 index 000000000..57a7aebb8 --- /dev/null +++ b/docs/commands/find.md @@ -0,0 +1,55 @@ +# `find` Command + +Search the Fabric catalog for items across all workspaces. + +**Usage:** + +``` +fab find [-P ] [-l] [-q ] +``` + +**Parameters:** + +- ``: Search text. Matches display name, description, and workspace name. +- `-P, --params`: Filter parameters in `key=value` or `key!=value` format. Use brackets for multiple values: `type=[Lakehouse,Notebook]`. Use `!=` to exclude: `type!=Dashboard`. +- `-l, --long`: Show detailed table with IDs (name, id, type, workspace, workspace_id, description). Optional. +- `-q, --query`: JMESPath query to filter results client-side. Optional. + +**Examples:** + +``` +# search for items by name or description +fab find 'sales report' + +# search for lakehouses only +fab find 'data' -P type=Lakehouse + +# search for multiple item types (bracket syntax) +fab find 'dashboard' -P type=[Report,SemanticModel] + +# exclude a type +fab find 'data' -P type!=Dashboard + +# show detailed output with IDs +fab find 'sales' -l + +# combine filters +fab find 'finance' -P type=[Warehouse,Lakehouse] -l + +# project specific fields +fab find 'data' -q "[].{name: name, workspace: workspace}" +``` + +**Behavior:** + +- In interactive mode (`fab` shell), results are paged 50 at a time with "Press any key to continue..." prompts. +- In command-line mode (`fab find ...`), all results are fetched in a single pass (up to 1000 per API call). +- Type names are case-insensitive. `type=lakehouse` matches `Lakehouse`. +- The `-q` JMESPath filter is applied client-side after results are returned from the API. + +**Supported filter parameters:** + +| Parameter | Description | +|-----------|-------------| +| `type` | Filter by item type. Supports `eq` (default) and `ne` (`!=`) operators. | + diff --git a/src/fabric_cli/client/fab_api_catalog.py b/src/fabric_cli/client/fab_api_catalog.py new file mode 100644 index 000000000..da09a31ef --- /dev/null +++ b/src/fabric_cli/client/fab_api_catalog.py @@ -0,0 +1,47 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +"""Catalog API client for searching Fabric items across workspaces. + +API Reference: POST https://api.fabric.microsoft.com/v1/catalog/search +Required Scope: Catalog.Read.All +""" + +from argparse import Namespace + +from fabric_cli.client import fab_api_client as fabric_api +from fabric_cli.client.fab_api_types import ApiResponse + + +def search(args: Namespace, payload: dict) -> ApiResponse: + """Search the Fabric catalog for items. + + https://learn.microsoft.com/en-us/rest/api/fabric/core/catalog/search + + Args: + args: Namespace with request configuration + payload: Dict with search request body: + - search (required): Text to search across displayName, description, workspaceName + - pageSize: Number of results per page + - continuationToken: Token for pagination + - filter: OData filter string, e.g., "Type eq 'Report' or Type eq 'Lakehouse'" + + Returns: + ApiResponse with search results containing: + - value: List of ItemCatalogEntry objects + - continuationToken: Token for next page (if more results exist) + + Note: + The following item types are NOT searchable via this API: + Dashboard + + Note: Dataflow Gen1 and Gen2 are currently not searchable; only Dataflow Gen2 + CI/CD items are returned (as type 'Dataflow'). + Scorecards are returned as type 'Report'. + """ + args.uri = "catalog/search" + args.method = "post" + # raw_response=True so we handle pagination ourselves in fab_find + args.raw_response = True + return fabric_api.do_request(args, json=payload) + diff --git a/src/fabric_cli/commands/find/__init__.py b/src/fabric_cli/commands/find/__init__.py new file mode 100644 index 000000000..59e481eb9 --- /dev/null +++ b/src/fabric_cli/commands/find/__init__.py @@ -0,0 +1,2 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. diff --git a/src/fabric_cli/commands/find/fab_find.py b/src/fabric_cli/commands/find/fab_find.py new file mode 100644 index 000000000..d0114c6f1 --- /dev/null +++ b/src/fabric_cli/commands/find/fab_find.py @@ -0,0 +1,289 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +"""Find command for searching the Fabric catalog.""" + +import json +import os +from argparse import Namespace +from typing import Any + +import yaml + +from fabric_cli.client import fab_api_catalog as catalog_api +from fabric_cli.core import fab_constant +from fabric_cli.core.fab_decorators import handle_exceptions, set_command_context +from fabric_cli.core.fab_exceptions import FabricCLIError +from fabric_cli.errors import ErrorMessages +from fabric_cli.utils import fab_jmespath as utils_jmespath +from fabric_cli.utils import fab_ui as utils_ui +from fabric_cli.utils import fab_util as utils + + +def _load_type_config() -> dict[str, list[str]]: + """Load item type definitions from type_supported.yaml.""" + yaml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "type_supported.yaml") + with open(yaml_path, "r") as f: + return yaml.safe_load(f) + + +_TYPE_CONFIG = _load_type_config() +ALL_ITEM_TYPES = _TYPE_CONFIG["supported"] + _TYPE_CONFIG["unsupported"] +UNSUPPORTED_ITEM_TYPES = _TYPE_CONFIG["unsupported"] +SEARCHABLE_ITEM_TYPES = _TYPE_CONFIG["supported"] + + +@handle_exceptions() +@set_command_context() +def find_command(args: Namespace) -> None: + """Search the Fabric catalog for items.""" + if args.query: + args.query = utils.process_nargs(args.query) + + is_interactive = getattr(args, "fab_mode", None) == fab_constant.FAB_MODE_INTERACTIVE + payload = _build_search_payload(args, is_interactive) + + utils_ui.print_grey(f"Searching catalog for '{args.search_text}'...") + + if is_interactive: + _find_interactive(args, payload) + else: + _find_commandline(args, payload) + + +def _fetch_results(args: Namespace, payload: dict[str, Any]) -> tuple[list[dict], str | None]: + """Execute a catalog search request and return parsed results. + + Returns: + Tuple of (items list, continuation_token or None). + + Raises: + FabricCLIError: On API error or invalid response body. + """ + # raw_response=True in catalog_api.search means we must check status ourselves + response = catalog_api.search(args, payload) + _raise_on_error(response) + + try: + results = json.loads(response.text) + except json.JSONDecodeError: + raise FabricCLIError( + ErrorMessages.Find.invalid_response(), + fab_constant.ERROR_INVALID_JSON, + ) + + items = results.get("value", []) + continuation_token = results.get("continuationToken", "") or None + return items, continuation_token + + +def _print_search_summary(count: int, has_more: bool = False) -> None: + """Print the search result summary line.""" + count_msg = f"{count} item(s) found" + (" (more available)" if has_more else "") + utils_ui.print_grey("") + utils_ui.print_grey(count_msg) + utils_ui.print_grey("") + + +def _find_interactive(args: Namespace, payload: dict[str, Any]) -> None: + """Fetch and display results page by page, prompting between pages.""" + total_count = 0 + has_more = True + + while has_more: + items, continuation_token = _fetch_results(args, payload) + + if not items and total_count == 0: + utils_ui.print_grey("No items found.") + return + + total_count += len(items) + has_more = continuation_token is not None + _print_search_summary(len(items), has_more) + + _display_items(args, items) + + if not has_more: + break + + try: + utils_ui.print_grey("") + input("Press any key to continue... (Ctrl+C to stop)") + except (KeyboardInterrupt, EOFError): + utils_ui.print_grey("") + break + + payload = {"continuationToken": continuation_token} + + if total_count > 0: + utils_ui.print_grey("") + utils_ui.print_grey(f"{total_count} item(s) shown") + + +def _find_commandline(args: Namespace, payload: dict[str, Any]) -> None: + """Fetch all results across pages and display.""" + all_items: list[dict] = [] + has_more = True + + while has_more: + items, continuation_token = _fetch_results(args, payload) + all_items.extend(items) + has_more = continuation_token is not None + if has_more: + payload = {"continuationToken": continuation_token} + + if not all_items: + utils_ui.print_grey("No items found.") + return + + _print_search_summary(len(all_items)) + + _display_items(args, all_items) + + +def _build_search_payload(args: Namespace, is_interactive: bool) -> dict[str, Any]: + """Build the search request payload from command arguments.""" + request: dict[str, Any] = {"search": args.search_text} + request["pageSize"] = 50 if is_interactive else 1000 + + type_filter = _parse_type_from_params(args) + if type_filter: + op = type_filter["operator"] + types = type_filter["values"] + + if op == "eq": + if len(types) == 1: + request["filter"] = f"Type eq '{types[0]}'" + else: + or_clause = " or ".join(f"Type eq '{t}'" for t in types) + request["filter"] = f"({or_clause})" + elif op == "ne": + if len(types) == 1: + request["filter"] = f"Type ne '{types[0]}'" + else: + ne_clause = " and ".join(f"Type ne '{t}'" for t in types) + request["filter"] = f"({ne_clause})" + + return request + + +def _parse_type_from_params(args: Namespace) -> dict[str, Any] | None: + """Extract and validate item types from -P params. + + Supports: + -P type=Report → eq single + -P type=[Report,Lakehouse] → eq multiple (or) + -P type!=Dashboard → ne single + -P type!=[Dashboard,Report] → ne multiple (and) + + Returns dict with 'operator' ('eq' or 'ne') and 'values' list, or None. + """ + params_str = getattr(args, "params", None) + if not params_str: + return None + + # nargs="?" gives a string; nargs="*" gives a list (backward compat) + if isinstance(params_str, list): + params_str = ",".join(params_str) + + params_dict = utils.get_dict_from_params(params_str, max_depth=1) + + # Check for type key (with or without ! for ne operator) + type_value = None + operator = "eq" + for key, value in params_dict.items(): + # get_dict_from_params splits on first "=", so "type!=X" becomes key="type!", value="X" + clean_key = key.rstrip("!") + is_ne = key.endswith("!") + + if clean_key.lower() == "type": + type_value = value + operator = "ne" if is_ne else "eq" + else: + raise FabricCLIError( + ErrorMessages.Common.unsupported_parameter(clean_key), + fab_constant.ERROR_INVALID_INPUT, + ) + + if not type_value: + return None + + # Parse bracket syntax: [val1,val2] or plain: val1 + if type_value.startswith("[") and type_value.endswith("]"): + inner = type_value[1:-1] + types = [t.strip() for t in inner.split(",") if t.strip()] + else: + types = [type_value.strip()] + + all_types_lower = {t.lower(): t for t in ALL_ITEM_TYPES} + unsupported_lower = {t.lower() for t in UNSUPPORTED_ITEM_TYPES} + normalized = [] + for t in types: + t_lower = t.lower() + if t_lower in unsupported_lower and operator == "eq": + canonical = all_types_lower.get(t_lower, t) + raise FabricCLIError( + ErrorMessages.Common.type_not_supported(canonical), + fab_constant.ERROR_UNSUPPORTED_ITEM_TYPE, + ) + if t_lower not in all_types_lower: + close = [v for k, v in all_types_lower.items() if t_lower in k or k in t_lower] + hint = f" Did you mean {', '.join(close)}?" if close else " Use tab completion to see valid types." + raise FabricCLIError( + ErrorMessages.Find.unrecognized_type(t, hint), + fab_constant.ERROR_INVALID_ITEM_TYPE, + ) + normalized.append(all_types_lower[t_lower]) + + return {"operator": operator, "values": normalized} + + +def _raise_on_error(response) -> None: + """Raise FabricCLIError if the API response indicates failure.""" + if response.status_code != 200: + try: + error_data = json.loads(response.text) + error_code = error_data.get("errorCode", fab_constant.ERROR_UNEXPECTED_ERROR) + error_message = error_data.get("message", response.text) + except json.JSONDecodeError: + error_code = fab_constant.ERROR_UNEXPECTED_ERROR + error_message = response.text + + raise FabricCLIError( + ErrorMessages.Find.search_failed(error_message), + error_code, + ) + + +def _display_items(args: Namespace, items: list[dict]) -> None: + """Format and display search result items.""" + show_details = getattr(args, "long", False) + has_descriptions = any(item.get("description") for item in items) + + display_items = [] + for item in items: + if show_details: + entry = { + "name": item.get("displayName") or item.get("name"), + "id": item.get("id"), + "type": item.get("type"), + "workspace": item.get("workspaceName"), + "workspace_id": item.get("workspaceId"), + } + else: + entry = { + "name": item.get("displayName") or item.get("name"), + "type": item.get("type"), + "workspace": item.get("workspaceName"), + } + if has_descriptions: + entry["description"] = item.get("description") or "" + display_items.append(entry) + + if has_descriptions and not show_details: + utils.truncate_descriptions(display_items) + + if getattr(args, "query", None): + display_items = utils_jmespath.search(display_items, args.query) + + utils_ui.print_output_format(args, data=display_items, show_headers=True) diff --git a/src/fabric_cli/commands/find/type_supported.yaml b/src/fabric_cli/commands/find/type_supported.yaml new file mode 100644 index 000000000..e7157fcd0 --- /dev/null +++ b/src/fabric_cli/commands/find/type_supported.yaml @@ -0,0 +1,51 @@ +--- +# Item types for the find command (Catalog Search API) +# Reference: https://learn.microsoft.com/en-us/rest/api/fabric/core/catalog/search + +supported: + - AnomalyDetector + - ApacheAirflowJob + - CopyJob + - CosmosDBDatabase + - Dataflow + - Datamart + - DataPipeline + - DigitalTwinBuilder + - DigitalTwinBuilderFlow + - Environment + - Eventhouse + - EventSchemaSet + - Eventstream + - GraphModel + - GraphQLApi + - GraphQuerySet + - KQLDashboard + - KQLDatabase + - KQLQueryset + - Lakehouse + - Map + - MirroredAzureDatabricksCatalog + - MirroredDatabase + - MirroredWarehouse + - MLExperiment + - MLModel + - MountedDataFactory + - Notebook + - Ontology + - OperationsAgent + - PaginatedReport + - Reflex + - Report + - SemanticModel + - SnowflakeDatabase + - SparkJobDefinition + - SQLDatabase + - SQLEndpoint + - UserDataFunction + - VariableLibrary + - Warehouse + - WarehouseSnapshot + +unsupported: + # Types that exist in Fabric but are NOT searchable via the Catalog Search API + - Dashboard diff --git a/src/fabric_cli/core/fab_parser_setup.py b/src/fabric_cli/core/fab_parser_setup.py index ae91d37a9..53a96220b 100644 --- a/src/fabric_cli/core/fab_parser_setup.py +++ b/src/fabric_cli/core/fab_parser_setup.py @@ -14,6 +14,7 @@ from fabric_cli.parsers import fab_config_parser as config_parser from fabric_cli.parsers import fab_describe_parser as describe_parser from fabric_cli.parsers import fab_extension_parser as extension_parser +from fabric_cli.parsers import fab_find_parser as find_parser from fabric_cli.parsers import fab_fs_parser as fs_parser from fabric_cli.parsers import fab_global_params from fabric_cli.parsers import fab_jobs_parser as jobs_parser @@ -218,6 +219,7 @@ def create_parser_and_subparsers(): api_parser.register_parser(subparsers) # api auth_parser.register_parser(subparsers) # auth describe_parser.register_parser(subparsers) # desc + find_parser.register_parser(subparsers) # find extension_parser.register_parser(subparsers) # extension # version diff --git a/src/fabric_cli/errors/__init__.py b/src/fabric_cli/errors/__init__.py index d4c61be5c..526c39eea 100644 --- a/src/fabric_cli/errors/__init__.py +++ b/src/fabric_cli/errors/__init__.py @@ -8,6 +8,7 @@ from .context import ContextErrors from .cp import CpErrors from .export import ExportErrors +from .find import FindErrors from .hierarchy import HierarchyErrors from .labels import LabelsErrors from .mkdir import MkdirErrors @@ -24,6 +25,7 @@ class ErrorMessages: Context = ContextErrors Cp = CpErrors Export = ExportErrors + Find = FindErrors Hierarchy = HierarchyErrors Labels = LabelsErrors Mkdir = MkdirErrors diff --git a/src/fabric_cli/errors/common.py b/src/fabric_cli/errors/common.py index 801fafc03..6500ceb35 100644 --- a/src/fabric_cli/errors/common.py +++ b/src/fabric_cli/errors/common.py @@ -248,3 +248,11 @@ def gateway_property_not_supported_for_type( @staticmethod def query_not_supported_for_set(query: str) -> str: return f"Query '{query}' is not supported for set command" + + @staticmethod + def unsupported_parameter(key: str) -> str: + return f"'{key}' isn't a supported parameter" + + @staticmethod + def invalid_parameter_format(param: str) -> str: + return f"Invalid parameter format: '{param}'. Use key=value or key!=value." diff --git a/src/fabric_cli/errors/config.py b/src/fabric_cli/errors/config.py index 7b8545ecd..a38a15cb8 100644 --- a/src/fabric_cli/errors/config.py +++ b/src/fabric_cli/errors/config.py @@ -17,10 +17,6 @@ def invalid_configuration_value( def unknown_configuration_key(configurationKey: str) -> str: return f"'{configurationKey}' is not a recognized configuration key. Please check the available configuration keys" - @staticmethod - def invalid_parameter_format(params: str) -> str: - return f"Invalid parameter format: {params}" - @staticmethod def config_not_set(config_name: str, message: str) -> str: return f"{config_name} is not set. {message}" diff --git a/src/fabric_cli/errors/find.py b/src/fabric_cli/errors/find.py new file mode 100644 index 000000000..1924f5f52 --- /dev/null +++ b/src/fabric_cli/errors/find.py @@ -0,0 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + + +class FindErrors: + @staticmethod + def unrecognized_type(type_name: str, hint: str) -> str: + return f"'{type_name}' isn't a recognized item type.{hint}" + + @staticmethod + def search_failed(message: str) -> str: + return f"Catalog search failed: {message}" + + @staticmethod + def invalid_response() -> str: + return "Catalog search returned an invalid response." diff --git a/src/fabric_cli/parsers/fab_find_parser.py b/src/fabric_cli/parsers/fab_find_parser.py new file mode 100644 index 000000000..4162a1b7d --- /dev/null +++ b/src/fabric_cli/parsers/fab_find_parser.py @@ -0,0 +1,83 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +"""Parser for the find command.""" + +from argparse import Namespace, _SubParsersAction + +from fabric_cli.commands.find import fab_find as find +from fabric_cli.utils import fab_error_parser as utils_error_parser +from fabric_cli.utils import fab_ui as utils_ui + + +COMMAND_FIND_DESCRIPTION = "Search the Fabric catalog for items." + +commands = { + "Description": { + "find": "Search across all workspaces by name, description, or workspace name.", + }, +} + + +def register_parser(subparsers: _SubParsersAction) -> None: + """Register the find command parser.""" + examples = [ + "# search for items by name or description", + "$ find 'sales report'\n", + "# search for lakehouses only", + "$ find 'data' -P type=Lakehouse\n", + "# search for multiple item types (bracket syntax)", + "$ find 'dashboard' -P type=[Report,SemanticModel]\n", + "# exclude a type", + "$ find 'data' -P type!=Dashboard\n", + "# exclude multiple types", + "$ find 'data' -P type!=[Dashboard,Datamart]\n", + "# show detailed output with IDs", + "$ find 'sales' -l\n", + "# combine filters", + "$ find 'finance' -P type=[Warehouse,Lakehouse] -l\n", + "# filter results client-side with JMESPath", + "$ find 'sales' -q \"[?type=='Report']\"\n", + "# project specific fields", + "$ find 'data' -q \"[].{name: name, workspace: workspace}\"", + ] + + parser = subparsers.add_parser( + "find", + help=COMMAND_FIND_DESCRIPTION, + fab_examples=examples, + fab_learnmore=["_"], + ) + + parser.add_argument( + "search_text", + metavar="query", + help="Search text (matches display name, description, and workspace name)", + ) + parser.add_argument( + "-P", + "--params", + metavar="", + nargs="?", + help="Parameters in key=value or key!=value format. Use brackets for multiple values: type=[Lakehouse,Notebook]. Use != to exclude: type!=Dashboard", + ) + parser.add_argument( + "-l", + "--long", + action="store_true", + help="Show detailed output. Optional", + ) + parser.add_argument( + "-q", + "--query", + nargs="+", + help="JMESPath query to filter. Optional", + ) + + parser.usage = f"{utils_error_parser.get_usage_prog(parser)}" + parser.set_defaults(func=find.find_command) + + +def show_help(args: Namespace) -> None: + """Display help for the find command.""" + utils_ui.display_help(commands, custom_header=COMMAND_FIND_DESCRIPTION) diff --git a/src/fabric_cli/utils/fab_util.py b/src/fabric_cli/utils/fab_util.py index 8312a3864..ea7b99329 100644 --- a/src/fabric_cli/utils/fab_util.py +++ b/src/fabric_cli/utils/fab_util.py @@ -20,6 +20,7 @@ import json import platform import re +import shutil from typing import Any from fabric_cli.core import fab_constant, fab_state_config @@ -75,7 +76,7 @@ def get_dict_from_params(params: str | list[str], max_depth: int = 2) -> dict: # Result ['key1.key2=hello', 'key2={"hello":"testing","bye":2}', 'key3=[1,2,3]', 'key4={"key5":"value5"}'] # Example key1.key2=hello # Result ['key1.key=hello'] - pattern = r"((?:[\w\.]+=.+?)(?=(?:,\s*[\w\.]+=)|$))" + pattern = r"((?:[\w\.]+!?=.+?)(?=(?:,\s*[\w\.]+!?=)|$))" if params: if isinstance(params, list): @@ -89,7 +90,7 @@ def get_dict_from_params(params: str | list[str], max_depth: int = 2) -> dict: matches = re.findall(pattern, norm_params) if not matches: raise FabricCLIError( - ErrorMessages.Config.invalid_parameter_format(norm_params), + ErrorMessages.Common.invalid_parameter_format(norm_params), fab_constant.ERROR_INVALID_INPUT, ) @@ -234,3 +235,26 @@ def get_capacity_settings( az_resource_group, sku, ) + + +def truncate_descriptions(items: list[dict], other_fields: list[str] | None = None) -> None: + """Truncate description column so a table fits within terminal width. + + Args: + items: List of dicts with a 'description' key to truncate in place. + other_fields: Column names used to estimate non-description width. + Defaults to ["name", "type", "workspace"]. + """ + if other_fields is None: + other_fields = ["name", "type", "workspace"] + + term_width = shutil.get_terminal_size((120, 24)).columns + used = sum( + max((len(str(item.get(f, ""))) for item in items), default=0) + 3 + for f in other_fields + ) + max_desc = max(term_width - used - 3, 20) + for item in items: + desc = item.get("description", "") + if len(desc) > max_desc: + item["description"] = desc[: max_desc - 1] + "…" diff --git a/tests/test_commands/commands_parser.py b/tests/test_commands/commands_parser.py index 6035ad3c0..822725487 100644 --- a/tests/test_commands/commands_parser.py +++ b/tests/test_commands/commands_parser.py @@ -2,10 +2,8 @@ # Licensed under the MIT License. import platform -from prompt_toolkit import PromptSession from prompt_toolkit.input import DummyInput from prompt_toolkit.output import DummyOutput -from prompt_toolkit.history import InMemoryHistory from fabric_cli.core.fab_interactive import InteractiveCLI from fabric_cli.core.fab_parser_setup import CustomArgumentParser @@ -33,6 +31,9 @@ register_stop_parser, register_unassign_parser, ) +from fabric_cli.parsers.fab_find_parser import ( + register_parser as register_find_parser, +) from fabric_cli.parsers.fab_jobs_parser import register_parser as register_jobs_parser from fabric_cli.parsers.fab_labels_parser import ( register_parser as register_labels_parser, @@ -48,6 +49,7 @@ register_export_parser, register_import_parser, register_assign_parser, + register_find_parser, register_ln_parser, register_ls_parser, register_mv_parser, @@ -70,19 +72,23 @@ def __init__(self): self._parser = customArgumentParser.add_subparsers() for register_parser_handler in parserHandlers: register_parser_handler(self._parser) - self._interactiveCLI = InteractiveCLI(customArgumentParser, self._parser) - - # Override init_session for Windows compatibility + + # On Windows without a console, PromptSession() raises + # NoConsoleScreenBufferError. Patch PromptSession in the interactive + # module to inject DummyInput/DummyOutput before the singleton is created. if platform.system() == "Windows": - def test_init_session(session_history: InMemoryHistory) -> PromptSession: - # DummyInput and DummyOutput are test classes of prompt_toolkit to - # solve the NoConsoleScreenBufferError issue - return PromptSession( - history=session_history, input=DummyInput(), output=DummyOutput() - ) - self._interactiveCLI.init_session = test_init_session - # Reinitialize the session with test-friendly settings - self._interactiveCLI.session = self._interactiveCLI.init_session(self._interactiveCLI.history) + import fabric_cli.core.fab_interactive as _interactive_mod + + _orig_ps = _interactive_mod.PromptSession + + def _safe_prompt_session(*args, **kwargs): + kwargs.setdefault("input", DummyInput()) + kwargs.setdefault("output", DummyOutput()) + return _orig_ps(*args, **kwargs) + + _interactive_mod.PromptSession = _safe_prompt_session + + self._interactiveCLI = InteractiveCLI(customArgumentParser, self._parser) def exec_command(self, command: str) -> None: self._interactiveCLI.handle_command(command) diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_basic_search_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_basic_search_success.yaml new file mode 100644 index 000000000..3d427c945 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_basic_search_success.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000095", "type": "KQLQueryset", + "displayName": "MockItem1", "description": "Mock description 1", + "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000000", + "type": "Dataflow", "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000091", + "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000113", "type": "Dataflow", + "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000059", "type": "Dataflow", + "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000090", "type": "Dataflow", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000125", "type": "ApacheAirflowJob", + "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000105", "type": "ApacheAirflowJob", + "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000036", "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000020", "type": "Dataflow", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000030", "type": "SQLDatabase", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000002", "type": "Dataflow", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000080", "type": "SQLEndpoint", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000120", "type": "SQLDatabase", + "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000117", "type": "SQLEndpoint", + "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000114", "type": "SQLEndpoint", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000049", "type": "SQLDatabase", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000131", "type": "SQLDatabase", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000057", "type": "SQLEndpoint", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000062", "type": "OperationsAgent", + "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000055", "type": "SQLEndpoint", "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000016", "type": "MirroredDatabase", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000075", "type": "SQLEndpoint", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000026", "type": "SQLEndpoint", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000116", "type": "SQLDatabase", + "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000004", "type": "SQLDatabase", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000019", "type": "MirroredDatabase", + "displayName": "MockItem19", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000044", + "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000068", + "type": "SemanticModel", "displayName": "MockItem21", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000012", + "type": "DataAgent", "displayName": "MockItem22", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000079", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000118", + "type": "SemanticModel", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000097", + "type": "SemanticModel", "displayName": "MockItem24", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000123", "type": "DataAgent", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000056", "type": "SemanticModel", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000094", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000108", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000048", "type": "DataAgent", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000078", "type": "Eventhouse", + "displayName": "MockItem28", "description": "Mock description 2", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000025", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000015", + "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000005", + "type": "SQLEndpoint", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000115", + "type": "PaginatedReport", "displayName": "MockItem31", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000001", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000017", + "type": "SQLEndpoint", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000006", + "type": "DataPipeline", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000098", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 13", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000013", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjpudWxsLCJTZWFyY2giOiJkYXRhIn0="}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2392' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:53 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000035 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_json_output_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_json_output_success.yaml new file mode 100644 index 000000000..3d427c945 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_json_output_success.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000095", "type": "KQLQueryset", + "displayName": "MockItem1", "description": "Mock description 1", + "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000000", + "type": "Dataflow", "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000091", + "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000113", "type": "Dataflow", + "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000059", "type": "Dataflow", + "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000090", "type": "Dataflow", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000125", "type": "ApacheAirflowJob", + "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000105", "type": "ApacheAirflowJob", + "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000036", "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000020", "type": "Dataflow", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000030", "type": "SQLDatabase", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000002", "type": "Dataflow", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000080", "type": "SQLEndpoint", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000120", "type": "SQLDatabase", + "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000117", "type": "SQLEndpoint", + "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000114", "type": "SQLEndpoint", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000049", "type": "SQLDatabase", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000131", "type": "SQLDatabase", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000057", "type": "SQLEndpoint", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000062", "type": "OperationsAgent", + "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000055", "type": "SQLEndpoint", "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000016", "type": "MirroredDatabase", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000075", "type": "SQLEndpoint", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000026", "type": "SQLEndpoint", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000116", "type": "SQLDatabase", + "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000004", "type": "SQLDatabase", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000019", "type": "MirroredDatabase", + "displayName": "MockItem19", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000044", + "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000068", + "type": "SemanticModel", "displayName": "MockItem21", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000012", + "type": "DataAgent", "displayName": "MockItem22", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000079", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000118", + "type": "SemanticModel", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000097", + "type": "SemanticModel", "displayName": "MockItem24", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000123", "type": "DataAgent", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000056", "type": "SemanticModel", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000094", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000108", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000048", "type": "DataAgent", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000078", "type": "Eventhouse", + "displayName": "MockItem28", "description": "Mock description 2", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000025", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000015", + "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000005", + "type": "SQLEndpoint", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000115", + "type": "PaginatedReport", "displayName": "MockItem31", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000001", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000017", + "type": "SQLEndpoint", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000006", + "type": "DataPipeline", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000098", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 13", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000013", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjpudWxsLCJTZWFyY2giOiJkYXRhIn0="}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2392' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:53 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000035 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_multi_type_eq_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_multi_type_eq_success.yaml new file mode 100644 index 000000000..8447f44ce --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_multi_type_eq_success.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50, "filter": "(Type eq ''Report'' or Type eq ''Lakehouse'')"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000015", "type": "Lakehouse", + "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 2", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000128", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000083", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000064", + "type": "Lakehouse", "displayName": "MockItem4", "description": "Mock description 1", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000104", + "type": "Lakehouse", "displayName": "MockItem5", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000130", + "type": "Lakehouse", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000121", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000074", + "type": "Lakehouse", "displayName": "MockItem7", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000071", "type": "Lakehouse", "displayName": "MockItem8", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 1", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000087", + "type": "Lakehouse", "displayName": "MockItem9", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 9", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000033", "type": "Lakehouse", + "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000054", + "type": "Lakehouse", "displayName": "MockItem11", "description": "Mock description 2", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}], + "continuationToken": ""}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '1511' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:57 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000106 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_ne_multi_type_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_ne_multi_type_success.yaml new file mode 100644 index 000000000..1ce510ddc --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_ne_multi_type_success.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50, "filter": "(Type ne ''Report'' and Type ne ''Notebook'')"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000015", "type": "Lakehouse", + "displayName": "MockItem1", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 1", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000128", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000083", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000064", + "type": "Lakehouse", "displayName": "MockItem3", "description": "Mock description 1", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000104", + "type": "Lakehouse", "displayName": "MockItem4", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000130", + "type": "Lakehouse", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000121", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000074", + "type": "Lakehouse", "displayName": "MockItem6", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000071", "type": "Lakehouse", "displayName": "MockItem7", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000087", + "type": "Lakehouse", "displayName": "MockItem8", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 9", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000033", "type": "Lakehouse", + "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000054", + "type": "Lakehouse", "displayName": "MockItem10", "description": "Mock description 2", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}], + "continuationToken": ""}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '1511' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:57 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000106 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_no_results_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_no_results_success.yaml new file mode 100644 index 000000000..764cf62a7 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_no_results_success.yaml @@ -0,0 +1,48 @@ +interactions: +- request: + body: '{"search": "xyznonexistent98765zzz", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '52' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [], "continuationToken": ""}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '55' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:59 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000129 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_search_summary_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_search_summary_success.yaml new file mode 100644 index 000000000..3d427c945 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_search_summary_success.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000095", "type": "KQLQueryset", + "displayName": "MockItem1", "description": "Mock description 1", + "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000000", + "type": "Dataflow", "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000091", + "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000113", "type": "Dataflow", + "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000059", "type": "Dataflow", + "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000090", "type": "Dataflow", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000125", "type": "ApacheAirflowJob", + "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000105", "type": "ApacheAirflowJob", + "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000036", "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000020", "type": "Dataflow", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000030", "type": "SQLDatabase", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000002", "type": "Dataflow", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000080", "type": "SQLEndpoint", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000120", "type": "SQLDatabase", + "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000117", "type": "SQLEndpoint", + "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000114", "type": "SQLEndpoint", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000049", "type": "SQLDatabase", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000131", "type": "SQLDatabase", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000057", "type": "SQLEndpoint", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000062", "type": "OperationsAgent", + "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000055", "type": "SQLEndpoint", "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000016", "type": "MirroredDatabase", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000075", "type": "SQLEndpoint", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000026", "type": "SQLEndpoint", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000116", "type": "SQLDatabase", + "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000004", "type": "SQLDatabase", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000019", "type": "MirroredDatabase", + "displayName": "MockItem19", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000044", + "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000068", + "type": "SemanticModel", "displayName": "MockItem21", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000012", + "type": "DataAgent", "displayName": "MockItem22", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000079", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000118", + "type": "SemanticModel", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000097", + "type": "SemanticModel", "displayName": "MockItem24", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000123", "type": "DataAgent", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000056", "type": "SemanticModel", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000094", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000108", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000048", "type": "DataAgent", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000078", "type": "Eventhouse", + "displayName": "MockItem28", "description": "Mock description 2", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000025", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000015", + "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000005", + "type": "SQLEndpoint", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000115", + "type": "PaginatedReport", "displayName": "MockItem31", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000001", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000017", + "type": "SQLEndpoint", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000006", + "type": "DataPipeline", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000098", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 13", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000013", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjpudWxsLCJTZWFyY2giOiJkYXRhIn0="}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2392' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:53 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000035 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_type_case_insensitive_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_type_case_insensitive_success.yaml new file mode 100644 index 000000000..a9a535a5b --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_type_case_insensitive_success.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50, "filter": "Type eq ''Lakehouse''"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000015", "type": "Lakehouse", + "displayName": "MockItem1", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 1", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000128", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000083", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000064", + "type": "Lakehouse", "displayName": "MockItem3", "description": "Mock description 1", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000104", + "type": "Lakehouse", "displayName": "MockItem4", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000130", + "type": "Lakehouse", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000121", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000074", + "type": "Lakehouse", "displayName": "MockItem6", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000071", "type": "Lakehouse", "displayName": "MockItem7", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000087", + "type": "Lakehouse", "displayName": "MockItem8", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 9", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000033", "type": "Lakehouse", + "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000054", + "type": "Lakehouse", "displayName": "MockItem10", "description": "Mock description 2", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}], + "continuationToken": ""}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '1511' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:57 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000106 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_with_jmespath_query_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_with_jmespath_query_success.yaml new file mode 100644 index 000000000..3d427c945 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_with_jmespath_query_success.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000095", "type": "KQLQueryset", + "displayName": "MockItem1", "description": "Mock description 1", + "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000000", + "type": "Dataflow", "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000091", + "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000113", "type": "Dataflow", + "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000059", "type": "Dataflow", + "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000090", "type": "Dataflow", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000125", "type": "ApacheAirflowJob", + "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000105", "type": "ApacheAirflowJob", + "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000036", "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000020", "type": "Dataflow", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000030", "type": "SQLDatabase", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000002", "type": "Dataflow", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000080", "type": "SQLEndpoint", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000120", "type": "SQLDatabase", + "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000117", "type": "SQLEndpoint", + "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000114", "type": "SQLEndpoint", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000049", "type": "SQLDatabase", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000131", "type": "SQLDatabase", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000057", "type": "SQLEndpoint", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000062", "type": "OperationsAgent", + "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000055", "type": "SQLEndpoint", "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000016", "type": "MirroredDatabase", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000075", "type": "SQLEndpoint", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000026", "type": "SQLEndpoint", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000116", "type": "SQLDatabase", + "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000004", "type": "SQLDatabase", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000019", "type": "MirroredDatabase", + "displayName": "MockItem19", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000044", + "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000068", + "type": "SemanticModel", "displayName": "MockItem21", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000012", + "type": "DataAgent", "displayName": "MockItem22", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000079", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000118", + "type": "SemanticModel", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000097", + "type": "SemanticModel", "displayName": "MockItem24", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000123", "type": "DataAgent", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000056", "type": "SemanticModel", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000094", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000108", "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000048", "type": "DataAgent", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000078", "type": "Eventhouse", + "displayName": "MockItem28", "description": "Mock description 2", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000025", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000015", + "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000005", + "type": "SQLEndpoint", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000115", + "type": "PaginatedReport", "displayName": "MockItem31", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000001", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000017", + "type": "SQLEndpoint", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000006", + "type": "DataPipeline", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000098", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 13", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000013", + "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjpudWxsLCJTZWFyY2giOiJkYXRhIn0="}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2392' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:53 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000035 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_with_long_output_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_with_long_output_success.yaml new file mode 100644 index 000000000..5e9c2f265 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_with_long_output_success.yaml @@ -0,0 +1,156 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000095", "type": "KQLQueryset", + "displayName": "MockItem1", "description": "Mock description 1", + "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000000", + "type": "Dataflow", "displayName": "MockItem2", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000091", + "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000113", "type": "Dataflow", + "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000059", "type": "Dataflow", + "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000003", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000086", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000090", "type": "Dataflow", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000125", "type": "ApacheAirflowJob", + "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000105", "type": "ApacheAirflowJob", + "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000036", "type": "Dataflow", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000020", "type": "Dataflow", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000030", "type": "SQLDatabase", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000080", "type": "SQLEndpoint", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000120", "type": "SQLDatabase", + "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000002", "type": "Dataflow", + "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000117", "type": "SQLEndpoint", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000114", "type": "SQLEndpoint", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000049", "type": "SQLDatabase", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000131", "type": "SQLDatabase", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000057", "type": "SQLEndpoint", + "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000062", "type": "OperationsAgent", + "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000055", "type": "SQLEndpoint", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 4", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000016", "type": "MirroredDatabase", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000075", "type": "SQLEndpoint", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000026", "type": "SQLEndpoint", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000116", "type": "SQLDatabase", + "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 8", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000004", "type": "SQLDatabase", + "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000103", + "workspaceName": "Mock Workspace 7", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000019", "type": "MirroredDatabase", + "displayName": "MockItem19", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000044", + "type": "SQLEndpoint", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000048", + "type": "DataAgent", "displayName": "MockItem21", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000031", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000078", "type": "Eventhouse", "displayName": "MockItem22", "description": "Mock description 2", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000025", "type": "Warehouse", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000068", "type": "SemanticModel", "displayName": "MockItem24", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000012", "type": "DataAgent", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000015", "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", + "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000052", "type": "Lakehouse", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", + "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000005", "type": "SQLEndpoint", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 12", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000115", "type": "PaginatedReport", + "displayName": "MockItem28", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 3", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000001", "type": "Warehouse", + "displayName": "MockItem29", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 13", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000017", + "type": "SQLEndpoint", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000006", + "type": "DataPipeline", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000098", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 14", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000013", + "type": "Warehouse", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 15", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000053", + "type": "DataAgent", "displayName": "MockItem31", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000031", "workspaceName": "Mock Workspace 16", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000060", + "type": "DataAgent", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000061", "workspaceName": "Mock Workspace 17", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000041", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000063", + "type": "SemanticModel", "displayName": "MockItem33", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000128", + "type": "Lakehouse", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 14", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000079", + "type": "SemanticModel", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000118", + "type": "SemanticModel", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjpudWxsLCJTZWFyY2giOiJkYXRhIn0="}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2451' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:59 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000111 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_with_ne_filter_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_with_ne_filter_success.yaml new file mode 100644 index 000000000..333e40b39 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_with_ne_filter_success.yaml @@ -0,0 +1,155 @@ +interactions: +- request: + body: '{"search": "report", "pageSize": 50, "filter": "Type ne ''Dashboard''"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '69' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000018", "type": "Report", + "displayName": "MockItem1", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000007", + "type": "PaginatedReport", "displayName": "MockItem2", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", + "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000043", "type": "Report", "displayName": "MockItem3", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000027", "type": "Report", "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000014", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000082", "type": "Report", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000051", "type": "Report", "displayName": "MockItem6", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000058", "type": "Report", "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000034", "type": "Report", "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000077", "type": "Report", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000127", "type": "Report", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000047", "type": "Report", "displayName": "MockItem10", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000028", "type": "SemanticModel", "displayName": "MockItem11", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000085", "type": "Report", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000038", "type": "Report", "displayName": "MockItem4", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000073", "type": "Report", "displayName": "MockItem12", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000084", "type": "Report", "displayName": "MockItem13", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000122", "type": "Report", "displayName": "MockItem10", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000109", "type": "Report", "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000112", "type": "Report", "displayName": "MockItem8", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000102", "type": "Report", "displayName": "MockItem7", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000070", "type": "Report", "displayName": "MockItem3", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000110", "type": "Report", "displayName": "MockItem14", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000099", "type": "PaginatedReport", + "displayName": "MockItem15", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000126", + "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000076", "type": "Report", "displayName": "MockItem16", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000023", "type": "Report", "displayName": "MockItem17", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", + "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000050", "type": "Report", "displayName": "MockItem18", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000096", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": + "00000000-0000-0000-0000-000000000081", "type": "Report", "displayName": "MockItem19", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000101", "type": "Report", "displayName": "MockItem20", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000066", "type": "Report", "displayName": "MockItem21", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000039", "type": "Report", "displayName": "MockItem22", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000089", "type": "Report", "displayName": "MockItem23", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000065", "type": "Report", "displayName": "MockItem24", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000119", "type": "Report", "displayName": "MockItem25", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000124", "type": "Report", "displayName": "MockItem26", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", + "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000072", "type": "Report", "displayName": "MockItem27", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", + "workspaceName": "Mock Workspace 8", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000092", "type": "Report", "displayName": "MockItem28", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000010", "type": "Report", "displayName": "MockItem29", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000069", "type": "Report", "displayName": "MockItem30", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000088", "type": "Report", "displayName": "MockItem31", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", + "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000067", "type": "Report", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", + "workspaceName": "Mock Workspace 9", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000024", "type": "Report", + "displayName": "MockItem33", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 1", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000115", + "type": "PaginatedReport", "displayName": "MockItem34", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000107", + "type": "SemanticModel", "displayName": "MockItem35", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000046", + "type": "Report", "displayName": "MockItem36", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 10", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000100", + "type": "Report", "displayName": "MockItem37", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000008", + "type": "Report", "displayName": "MockItem38", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000009", + "type": "Report", "displayName": "MockItem39", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000037", + "type": "SemanticModel", "displayName": "MockItem32", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000042", "workspaceName": "Mock Workspace 9", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000011", "type": "SemanticModel", "displayName": "MockItem40", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000042", "workspaceName": "Mock Workspace 11", "catalogEntryType": "FabricItem"}], "continuationToken": + "eyJTa2lwIjo1MCwiRmlsdGVyIjoiVHlwZSBuZSAnRGFzaGJvYXJkJyIsIlNlYXJjaCI6InJlcG9ydCJ9"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:57:00 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000032 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_find/test_find_with_type_filter_success.yaml b/tests/test_commands/recordings/test_commands/test_find/test_find_with_type_filter_success.yaml new file mode 100644 index 000000000..a9a535a5b --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_find/test_find_with_type_filter_success.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{"search": "data", "pageSize": 50, "filter": "Type eq ''Lakehouse''"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/catalog/search + response: + body: + string: '{"value": [{"id": "00000000-0000-0000-0000-000000000015", "type": "Lakehouse", + "displayName": "MockItem1", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000045", "workspaceName": "Mock Workspace 1", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000052", + "type": "Lakehouse", "displayName": "MockItem2", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000022", "workspaceName": "Mock Workspace 2", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000128", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000029", "workspaceName": "Mock Workspace 3", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000083", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000040", "workspaceName": "Mock Workspace 4", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000064", + "type": "Lakehouse", "displayName": "MockItem3", "description": "Mock description 1", "workspaceId": "00000000-0000-0000-0000-000000000021", "workspaceName": "Mock Workspace 5", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000104", + "type": "Lakehouse", "displayName": "MockItem4", "description": "", + "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 6", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000130", + "type": "Lakehouse", "displayName": "MockItem5", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000121", + "type": "Lakehouse", "displayName": "MockItem1", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000074", + "type": "Lakehouse", "displayName": "MockItem6", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}, + {"id": "00000000-0000-0000-0000-000000000071", "type": "Lakehouse", "displayName": "MockItem7", "description": "", "workspaceId": + "00000000-0000-0000-0000-000000000086", "workspaceName": "Mock Workspace 8", + "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000087", + "type": "Lakehouse", "displayName": "MockItem8", + "description": "", "workspaceId": "00000000-0000-0000-0000-000000000031", + "workspaceName": "Mock Workspace 9", "catalogEntryType": + "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000033", "type": "Lakehouse", + "displayName": "MockItem9", "description": "", "workspaceId": "00000000-0000-0000-0000-000000000093", "workspaceName": "Mock Workspace 10", "catalogEntryType": "FabricItem"}, {"id": "00000000-0000-0000-0000-000000000054", + "type": "Lakehouse", "displayName": "MockItem10", "description": "Mock description 2", "workspaceId": "00000000-0000-0000-0000-000000000132", + "workspaceName": "Mock Workspace 7", "catalogEntryType": "FabricItem"}], + "continuationToken": ""}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '1511' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 16 Mar 2026 14:56:57 GMT + Pragma: + - no-cache + RequestId: + - 00000000-0000-0000-0000-000000000106 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/test_find.py b/tests/test_commands/test_find.py new file mode 100644 index 000000000..6adbbbd59 --- /dev/null +++ b/tests/test_commands/test_find.py @@ -0,0 +1,481 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +"""Tests for the find command — unit tests and e2e (VCR) tests.""" + +import json +from argparse import Namespace +from unittest.mock import MagicMock, patch + +import pytest + +from fabric_cli.commands.find import fab_find +from fabric_cli.core.fab_exceptions import FabricCLIError +from tests.test_commands.commands_parser import CLIExecutor + + +def _assert_strings_in_mock_calls( + strings: list[str], + should_exist: bool, + mock_calls, + require_all_in_same_args: bool = False, +): + """Assert that specified strings are present or absent in mock calls.""" + if require_all_in_same_args: + match_found = any( + all(string in str(call) for string in strings) for call in mock_calls + ) + else: + match_found = all( + any(string in str(call) for call in mock_calls) for string in strings + ) + + if should_exist: + assert match_found, f"Expected strings {strings} to {'all be present together' if require_all_in_same_args else 'be present'} in mock calls, but not found." + else: + assert not match_found, f"Expected strings {strings} to {'not all be present together' if require_all_in_same_args else 'not be present'} in mock calls, but found." + + +# Sample API responses for testing +SAMPLE_RESPONSE_WITH_RESULTS = { + "value": [ + { + "id": "0acd697c-1550-43cd-b998-91bfb12347c6", + "type": "Report", + "catalogEntryType": "FabricItem", + "displayName": "Monthly Sales Revenue", + "description": "Consolidated revenue report for the current fiscal year.", + "workspaceId": "18cd155c-7850-15cd-a998-91bfb12347aa", + "workspaceName": "Sales Department", + }, + { + "id": "123d697c-7848-77cd-b887-91bfb12347cc", + "type": "Lakehouse", + "catalogEntryType": "FabricItem", + "displayName": "Yearly Sales Revenue", + "description": "Consolidated revenue report for the current fiscal year.", + "workspaceId": "18cd155c-7850-15cd-a998-91bfb12347aa", + "workspaceName": "Sales Department", + }, + ], + "continuationToken": "lyJ1257lksfdfG==", +} + +SAMPLE_RESPONSE_EMPTY = { + "value": [], +} + + + +class TestBuildSearchPayload: + """Tests for _build_search_payload function.""" + + def test_basic_query_interactive(self): + args = Namespace(search_text="sales report", params=None, query=None) + payload = fab_find._build_search_payload(args, is_interactive=True) + + assert payload["search"] == "sales report" + assert payload["pageSize"] == 50 + assert "filter" not in payload + + def test_basic_query_commandline(self): + args = Namespace(search_text="sales report", params=None, query=None) + payload = fab_find._build_search_payload(args, is_interactive=False) + + assert payload["search"] == "sales report" + assert payload["pageSize"] == 1000 + assert "filter" not in payload + + +class TestParseTypeFromParams: + """Tests for _parse_type_from_params function.""" + + def test_no_params(self): + args = Namespace(params=None) + assert fab_find._parse_type_from_params(args) is None + + def test_empty_params(self): + args = Namespace(params="") + assert fab_find._parse_type_from_params(args) is None + +class TestFetchResults: + """Tests for _fetch_results helper.""" + + @patch("fabric_cli.client.fab_api_catalog.search") + def test_returns_items_and_token(self, mock_search): + response = MagicMock() + response.status_code = 200 + response.text = json.dumps(SAMPLE_RESPONSE_WITH_RESULTS) + mock_search.return_value = response + + args = Namespace() + items, token = fab_find._fetch_results(args, {"search": "test"}) + + assert len(items) == 2 + assert token == "lyJ1257lksfdfG==" + + @patch("fabric_cli.client.fab_api_catalog.search") + def test_returns_none_token_when_empty(self, mock_search): + response = MagicMock() + response.status_code = 200 + response.text = json.dumps(SAMPLE_RESPONSE_EMPTY) + mock_search.return_value = response + + args = Namespace() + items, token = fab_find._fetch_results(args, {"search": "test"}) + + assert items == [] + assert token is None + + @patch("fabric_cli.client.fab_api_catalog.search") + def test_raises_on_invalid_json(self, mock_search): + response = MagicMock() + response.status_code = 200 + response.text = "not json" + mock_search.return_value = response + + args = Namespace() + with pytest.raises(FabricCLIError) as exc_info: + fab_find._fetch_results(args, {"search": "test"}) + assert "invalid response" in str(exc_info.value) + + +class TestRaiseOnError: + """Tests for _raise_on_error function.""" + + def test_success_response(self): + response = MagicMock() + response.status_code = 200 + fab_find._raise_on_error(response) + + def test_error_response_raises_fabric_cli_error(self): + response = MagicMock() + response.status_code = 403 + response.text = json.dumps({ + "errorCode": "InsufficientScopes", + "message": "Missing required scope: Catalog.Read.All" + }) + + with pytest.raises(FabricCLIError) as exc_info: + fab_find._raise_on_error(response) + + assert "Catalog search failed" in str(exc_info.value) + assert "Missing required scope" in str(exc_info.value) + + def test_error_response_non_json(self): + response = MagicMock() + response.status_code = 500 + response.text = "Internal Server Error" + + with pytest.raises(FabricCLIError) as exc_info: + fab_find._raise_on_error(response) + + assert "Catalog search failed" in str(exc_info.value) + + +class TestSearchableItemTypes: + """Tests for item type lists loaded from YAML.""" + + def test_searchable_types_excludes_unsupported(self): + assert "Dashboard" not in fab_find.SEARCHABLE_ITEM_TYPES + assert "Dataflow" in fab_find.SEARCHABLE_ITEM_TYPES + assert "Report" in fab_find.SEARCHABLE_ITEM_TYPES + assert "Lakehouse" in fab_find.SEARCHABLE_ITEM_TYPES + + def test_all_types_includes_unsupported(self): + assert "Dashboard" in fab_find.ALL_ITEM_TYPES + + def test_types_loaded_from_yaml(self): + assert len(fab_find.SEARCHABLE_ITEM_TYPES) > 30 + assert len(fab_find.UNSUPPORTED_ITEM_TYPES) >= 1 + + +# --------------------------------------------------------------------------- +# E2E tests (VCR-recorded) +# +# These tests use the CLIExecutor to run actual find commands through the +# full CLI pipeline, with HTTP calls recorded/played back via VCR cassettes. +# +# To record cassettes: +# 1. Set env vars: +# $env:FAB_TOKEN = "" +# $env:FAB_TOKEN_ONELAKE = $env:FAB_TOKEN +# $env:FAB_API_ENDPOINT_FABRIC = "dailyapi.fabric.microsoft.com" +# 2. Run: +# pytest tests/test_commands/test_find.py::TestFindE2E --record -v +# --------------------------------------------------------------------------- + + +class TestFindE2E: + """End-to-end tests for the find command with VCR cassettes.""" + + @pytest.fixture(autouse=True) + def _mock_input(self, monkeypatch): + """Raise EOFError on input() to stop pagination after the first page.""" + monkeypatch.setattr("builtins.input", lambda *args: (_ for _ in ()).throw(EOFError)) + + def test_find_basic_search_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search returns results and prints output.""" + cli_executor.exec_command("find 'data'") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["name", "type", "workspace"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_with_type_filter_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with -P type= returns only matching types.""" + cli_executor.exec_command("find 'data' -P type=Lakehouse") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Lakehouse"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_type_case_insensitive_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with lowercase type=lakehouse returns same results.""" + cli_executor.exec_command("find 'data' -P type=lakehouse") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Lakehouse"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_with_long_output_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with -l includes IDs in output.""" + cli_executor.exec_command("find 'data' -l") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["id"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_no_results_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + ): + """Search for nonexistent term shows 'No items found'.""" + cli_executor.exec_command("find 'xyznonexistent98765zzz'") + + grey_output = " ".join(str(c) for c in mock_print_grey.call_args_list) + assert "No items found" in grey_output + + def test_find_with_ne_filter_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with type!=Dashboard excludes Dashboard items.""" + cli_executor.exec_command("find 'report' -P type!=Dashboard") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Type: Dashboard"], + should_exist=False, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_ne_multi_type_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with type!=[Report,Notebook] excludes both types.""" + cli_executor.exec_command("find 'data' -P type!=[Report,Notebook]") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Type: Report"], + should_exist=False, + mock_calls=mock_questionary_print.call_args_list, + ) + _assert_strings_in_mock_calls( + ["Type: Notebook"], + should_exist=False, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_unknown_type_failure( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + mock_fab_ui_print_error, + ): + """Search with unknown type shows error.""" + cli_executor.exec_command("find 'data' -P type=FakeType123") + + all_output = ( + str(mock_questionary_print.call_args_list) + + str(mock_print_grey.call_args_list) + + str(mock_fab_ui_print_error.call_args_list) + ) + assert "FakeType123" in all_output + assert "recognized item type" in all_output + + def test_find_unsupported_type_failure( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + mock_fab_ui_print_error, + ): + """Search with unsupported type shows error.""" + cli_executor.exec_command("find 'data' -P type=Dashboard") + + all_output = ( + str(mock_questionary_print.call_args_list) + + str(mock_print_grey.call_args_list) + + str(mock_fab_ui_print_error.call_args_list) + ) + assert "Dashboard" in all_output + assert "not supported" in all_output + + def test_find_invalid_param_format_failure( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + mock_fab_ui_print_error, + ): + """Search with malformed -P value shows error.""" + cli_executor.exec_command("find 'data' -P notakeyvalue") + + all_output = ( + str(mock_questionary_print.call_args_list) + + str(mock_print_grey.call_args_list) + + str(mock_fab_ui_print_error.call_args_list) + ) + assert "Invalid parameter" in all_output + + def test_find_unsupported_param_failure( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + mock_fab_ui_print_error, + ): + """Search with unknown param key shows error.""" + cli_executor.exec_command("find 'data' -P foo=bar") + + all_output = ( + str(mock_questionary_print.call_args_list) + + str(mock_print_grey.call_args_list) + + str(mock_fab_ui_print_error.call_args_list) + ) + assert "foo" in all_output + assert "supported parameter" in all_output + + def test_find_unsupported_param_ne_failure( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + mock_fab_ui_print_error, + ): + """Search with unknown param key using != shows error.""" + cli_executor.exec_command("find 'data' -P foo!=bar") + + all_output = ( + str(mock_questionary_print.call_args_list) + + str(mock_print_grey.call_args_list) + + str(mock_fab_ui_print_error.call_args_list) + ) + assert "foo" in all_output + assert "supported parameter" in all_output + + def test_find_with_jmespath_query_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with -q JMESPath query filters results locally.""" + cli_executor.exec_command("""find 'data' -q "[?type=='Report']" """) + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Report"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_multi_type_eq_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with type=[Report,Lakehouse] returns both types.""" + cli_executor.exec_command("find 'data' -P type=[Report,Lakehouse]") + + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["Report"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + _assert_strings_in_mock_calls( + ["Lakehouse"], + should_exist=True, + mock_calls=mock_questionary_print.call_args_list, + ) + + def test_find_json_output_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + ): + """Search with --output_format json returns valid JSON.""" + cli_executor.exec_command("find 'data' --output_format json") + + mock_questionary_print.assert_called() + # Find the JSON call (skip summary lines printed via print_grey → questionary.print) + json_output = None + for call in mock_questionary_print.call_args_list: + try: + json_output = json.loads(call.args[0]) + break + except (json.JSONDecodeError, IndexError): + continue + assert json_output is not None, "No valid JSON found in output" + assert "result" in json_output + assert "data" in json_output["result"] + assert len(json_output["result"]["data"]) > 0 + + def test_find_search_summary_success( + self, + cli_executor: CLIExecutor, + mock_questionary_print, + mock_print_grey, + ): + """Search with results prints summary with item count.""" + cli_executor.exec_command("find 'data'") + + grey_output = " ".join(str(c) for c in mock_print_grey.call_args_list) + assert "item(s) found" in grey_output + assert "more available" in grey_output