diff --git a/.changes/unreleased/optimization-20260203-163440.yaml b/.changes/unreleased/optimization-20260203-163440.yaml new file mode 100644 index 00000000..2b0e3974 --- /dev/null +++ b/.changes/unreleased/optimization-20260203-163440.yaml @@ -0,0 +1,6 @@ +kind: optimization +body: Add visual divider between folders and items in `ls` command on workspaces with text output format +time: 2026-02-03T16:34:40.477661885Z +custom: + Author: ayeshurun + AuthorLink: https://github.com/ayeshurun diff --git a/src/fabric_cli/commands/fs/ls/fab_fs_ls_item.py b/src/fabric_cli/commands/fs/ls/fab_fs_ls_item.py index f2e1e19a..cb94d5a8 100644 --- a/src/fabric_cli/commands/fs/ls/fab_fs_ls_item.py +++ b/src/fabric_cli/commands/fs/ls/fab_fs_ls_item.py @@ -15,7 +15,15 @@ def exec(workspace: Workspace, args): show_details = bool(args.long) show_all = bool(args.all) ws_elements: list[Union[Item, Folder]] = utils_fs.get_ws_elements(workspace) - sorted_elements_dict = utils_fs.sort_ws_elements(ws_elements, show_details) + + folder_listing_enabled = ( + fab_state_config.get_config(fab_constant.FAB_FOLDER_LISTING_ENABLED) == "true" + ) + + if folder_listing_enabled: + sorted_elements_dict = utils_fs.sort_ws_elements_with_divider(ws_elements, show_details) + else: + sorted_elements_dict = utils_fs.sort_ws_elements(ws_elements, show_details) show_hidden = ( show_all or fab_state_config.get_config(fab_constant.FAB_SHOW_HIDDEN) == "true" @@ -25,6 +33,6 @@ def exec(workspace: Workspace, args): data=sorted_elements_dict, args=args, show_details=show_details, - columns=sorted_elements_dict[0].keys() if sorted_elements_dict else [], + columns=list(sorted_elements_dict[0].keys()) if sorted_elements_dict else [], hidden_data=VirtualItemContainerType if show_hidden else None, ) diff --git a/src/fabric_cli/utils/fab_cmd_fs_utils.py b/src/fabric_cli/utils/fab_cmd_fs_utils.py index 1e7252fb..e5e4b12d 100644 --- a/src/fabric_cli/utils/fab_cmd_fs_utils.py +++ b/src/fabric_cli/utils/fab_cmd_fs_utils.py @@ -2,7 +2,7 @@ # Licensed under the MIT License. -from typing import Union +from typing import Sequence, Union from fabric_cli.core import fab_constant, fab_state_config from fabric_cli.core.fab_commands import Command @@ -78,7 +78,7 @@ def get_ws_elements(parent: Workspace | Folder) -> list[Union[Item, Folder]]: return ws_elements -def sort_ws_elements(ws_elements: list[Union[Item, Folder]], show_details): +def sort_ws_elements(ws_elements: Sequence[Union[Item, Folder]], show_details): if not ws_elements: return [] @@ -90,3 +90,27 @@ def sort_ws_elements(ws_elements: list[Union[Item, Folder]], show_details): {key: getattr(item, key) for key in columns if hasattr(item, key)} for item in sorted_elements ] + + +def sort_ws_elements_with_divider( + ws_elements: list[Union[Item, Folder]], show_details: bool +) -> list[dict]: + """Sort workspace elements: folders first, divider, then items.""" + if not ws_elements: + return [] + + folders = [el for el in ws_elements if isinstance(el, Folder)] + items = [el for el in ws_elements if isinstance(el, Item)] + columns = ["name", "id"] if show_details else ["name"] + + result = [] + has_both = bool(folders and items) + if folders: + if has_both: + result.append({key: ("[Folders]" if key == "name" else "") for key in columns}) + result.extend(sort_ws_elements(folders, show_details)) + if items: + if has_both: + result.append({key: ("[Items]" if key == "name" else "") for key in columns}) + result.extend(sort_ws_elements(items, show_details)) + return result diff --git a/tests/test_commands/recordings/test_commands/test_ls/class_setup.yaml b/tests/test_commands/recordings/test_commands/test_ls/class_setup.yaml index 611cb45a..854bf78e 100644 --- a/tests/test_commands/recordings/test_commands/test_ls/class_setup.yaml +++ b/tests/test_commands/recordings/test_commands/test_ls/class_setup.yaml @@ -115,7 +115,7 @@ interactions: response: body: string: '{"value": [{"id": "00000000-0000-0000-0000-000000000004", "displayName": - "mocked_fabriccli_capacity_name", "sku": "F16", "region": "Central US", "state": + "mocked_fabriccli_capacity_name", "sku": "F2", "region": "Central US", "state": "Active"}]}' headers: Access-Control-Expose-Headers: @@ -129,11 +129,11 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 12:01:42 GMT + - Thu, 05 Feb 2026 13:48:02 GMT Pragma: - no-cache RequestId: - - 523bf25d-7c17-488c-abf7-cb5143f4dcca + - af55f273-fdb0-41c9-bf85-607803366fb5 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -167,7 +167,7 @@ interactions: uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"id": "8345c10e-7b97-44ce-8111-806b95aad368", "displayName": "fabriccli_WorkspacePerTestclass_000001", + string: '{"id": "ebe5f85c-0343-4508-9d2d-a8299cfea504", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}' headers: Access-Control-Expose-Headers: @@ -177,17 +177,17 @@ interactions: Content-Encoding: - gzip Content-Length: - - '190' + - '187' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 12:01:51 GMT + - Thu, 05 Feb 2026 13:48:09 GMT Location: - - https://api.fabric.microsoft.com/v1/workspaces/8345c10e-7b97-44ce-8111-806b95aad368 + - https://api.fabric.microsoft.com/v1/workspaces/ebe5f85c-0343-4508-9d2d-a8299cfea504 Pragma: - no-cache RequestId: - - 02e2ce7e-93b5-4e49-b0e0-a0b5b9705974 + - 831b42b8-59e6-45bf-96b0-7985c7063e11 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -219,7 +219,7 @@ interactions: response: body: string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "8345c10e-7b97-44ce-8111-806b95aad368", + "My workspace", "description": "", "type": "Personal"}, {"id": "ebe5f85c-0343-4508-9d2d-a8299cfea504", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: @@ -230,15 +230,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2937' + - '2901' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 12:05:04 GMT + - Thu, 05 Feb 2026 13:48:51 GMT Pragma: - no-cache RequestId: - - 020a5b97-907a-43e0-a88b-9ddd69410743 + - c3f8f00d-5ab2-48c3-813c-b155b598a7d0 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -266,108 +266,7 @@ interactions: User-Agent: - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/8345c10e-7b97-44ce-8111-806b95aad368/items - response: - body: - string: '{"value": [{"id": "b51a7eb5-9481-425a-8037-d6723709f8d4", "type": "SQLEndpoint", - "displayName": "fabcli000002dtdm", "description": "", "workspaceId": "8345c10e-7b97-44ce-8111-806b95aad368", - "folderId": "dae78c10-fe9c-4e10-a115-1845eb5b6ef9"}, {"id": "13372126-888e-466b-a7b9-8b635c6f8333", - "type": "Lakehouse", "displayName": "fabcli000002dtdm", "description": "", - "workspaceId": "8345c10e-7b97-44ce-8111-806b95aad368", "folderId": "dae78c10-fe9c-4e10-a115-1845eb5b6ef9"}]}' - headers: - Access-Control-Expose-Headers: - - RequestId - Cache-Control: - - no-store, must-revalidate, no-cache - Content-Encoding: - - gzip - Content-Length: - - '247' - Content-Type: - - application/json; charset=utf-8 - Date: - - Wed, 11 Feb 2026 12:05:05 GMT - Pragma: - - no-cache - RequestId: - - f9198688-df06-40f1-b2f1-83785cc3e9fd - Strict-Transport-Security: - - max-age=31536000; includeSubDomains - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - deny - home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ - request-redirected: - - 'true' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) - method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/8345c10e-7b97-44ce-8111-806b95aad368/folders?recursive=True - response: - body: - string: '{"value": [{"id": "dae78c10-fe9c-4e10-a115-1845eb5b6ef9", "displayName": - "fabcli000001", "workspaceId": "8345c10e-7b97-44ce-8111-806b95aad368"}]}' - headers: - Access-Control-Expose-Headers: - - RequestId - Cache-Control: - - no-store, must-revalidate, no-cache - Content-Encoding: - - gzip - Content-Length: - - '143' - Content-Type: - - application/json; charset=utf-8 - Date: - - Wed, 11 Feb 2026 12:05:06 GMT - Pragma: - - no-cache - RequestId: - - 13c26542-f28d-43eb-a690-d66c8693a81c - Strict-Transport-Security: - - max-age=31536000; includeSubDomains - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - deny - home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ - request-redirected: - - 'true' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) - method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/8345c10e-7b97-44ce-8111-806b95aad368/folders?recursive=True + uri: https://api.fabric.microsoft.com/v1/workspaces/ebe5f85c-0343-4508-9d2d-a8299cfea504/items response: body: string: '{"value": [{"id": "dae78c10-fe9c-4e10-a115-1845eb5b6ef9", "displayName": @@ -384,11 +283,11 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 12:05:06 GMT + - Thu, 05 Feb 2026 13:48:51 GMT Pragma: - no-cache RequestId: - - 9a08c101-6530-48a9-af1c-c0498ca10eb0 + - c4c73c19-cae6-4865-b3b9-86e803fdf296 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -418,7 +317,7 @@ interactions: User-Agent: - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: DELETE - uri: https://api.fabric.microsoft.com/v1/workspaces/8345c10e-7b97-44ce-8111-806b95aad368 + uri: https://api.fabric.microsoft.com/v1/workspaces/ebe5f85c-0343-4508-9d2d-a8299cfea504 response: body: string: '' @@ -434,11 +333,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 11 Feb 2026 12:05:08 GMT + - Thu, 05 Feb 2026 13:48:51 GMT Pragma: - no-cache RequestId: - - 4d32ff8d-8b20-43ef-9974-7c3a91fcc908 + - 7af2a487-ebea-4831-a586-ab5259143e49 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: diff --git a/tests/test_commands/recordings/test_commands/test_set/test_virtual_item_not_supported_failure.yaml b/tests/test_commands/recordings/test_commands/test_ls/test_ls_workspace_with_folders_and_items_divider.yaml similarity index 59% rename from tests/test_commands/recordings/test_commands/test_set/test_virtual_item_not_supported_failure.yaml rename to tests/test_commands/recordings/test_commands/test_ls/test_ls_workspace_with_folders_and_items_divider.yaml index 08d0ec22..f0edaa51 100644 --- a/tests/test_commands/recordings/test_commands/test_set/test_virtual_item_not_supported_failure.yaml +++ b/tests/test_commands/recordings/test_commands/test_ls/test_ls_workspace_with_folders_and_items_divider.yaml @@ -11,13 +11,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "81065bd8-e334-4715-b170-dedb4cd514e6", + string: '{"value": [{"id": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "a32f2c4b-828b-4897-8b4b-9225c45db8d6", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: @@ -28,15 +28,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2091' + - '567' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:40 GMT + - Mon, 08 Sep 2025 17:20:23 GMT Pragma: - no-cache RequestId: - - 958715d8-9506-4f0e-aa9c-07f751db655c + - 61e92751-0d8b-4362-b775-9fecc1fc5435 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -44,7 +44,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -62,16 +62,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6 + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders?recursive=True response: body: - string: '{"id": "81065bd8-e334-4715-b170-dedb4cd514e6", "displayName": "fabriccli_WorkspacePerTestclass_000001", - "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", - "capacityRegion": "Central US", "oneLakeEndpoints": {"blobEndpoint": "https://centralus-onelake.blob.fabric.microsoft.com", - "dfsEndpoint": "https://centralus-onelake.dfs.fabric.microsoft.com"}, "capacityAssignmentProgress": - "Completed"}' + string: '{"value": []}' headers: Access-Control-Expose-Headers: - RequestId @@ -80,15 +76,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '296' + - '32' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:39 GMT + - Mon, 08 Sep 2025 17:20:24 GMT Pragma: - no-cache RequestId: - - 37fc74e3-5297-4f43-8c05-3c28f78c21eb + - 12ee0302-e5b8-40d1-a64d-a473fc90fef0 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -96,7 +92,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -114,16 +110,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6 + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders?recursive=True response: body: - string: '{"id": "81065bd8-e334-4715-b170-dedb4cd514e6", "displayName": "fabriccli_WorkspacePerTestclass_000001", - "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", - "capacityRegion": "Central US", "oneLakeEndpoints": {"blobEndpoint": "https://centralus-onelake.blob.fabric.microsoft.com", - "dfsEndpoint": "https://centralus-onelake.dfs.fabric.microsoft.com"}, "capacityAssignmentProgress": - "Completed"}' + string: '{"value": []}' headers: Access-Control-Expose-Headers: - RequestId @@ -132,15 +124,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '296' + - '32' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:40 GMT + - Mon, 08 Sep 2025 17:20:23 GMT Pragma: - no-cache RequestId: - - 188c9d75-631e-4bbd-9220-2caa2b009646 + - 79a8d04c-d593-4347-8c35-dcf826ac4e02 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -148,14 +140,14 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: code: 200 message: OK - request: - body: null + body: '{"description": "Created by fab", "displayName": "fabcli000001"}' headers: Accept: - '*/*' @@ -164,37 +156,36 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '68' Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: POST - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6/provisionIdentity + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders response: body: - string: 'null' + string: '{"id": "8a745177-5b9e-432f-b37a-3194f6d29aac", "displayName": "fabcli000001", + "workspaceId": "a32f2c4b-828b-4897-8b4b-9225c45db8d6"}' headers: Access-Control-Expose-Headers: - - RequestId,Location,Retry-After,x-ms-operation-id + - RequestId,Location Cache-Control: - no-store, must-revalidate, no-cache Content-Encoding: - gzip Content-Length: - - '24' + - '131' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:41 GMT + - Mon, 08 Sep 2025 17:20:23 GMT Location: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/dbb74b3b-99c5-4c1c-ae10-91ad32a59afe + - https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders/8a745177-5b9e-432f-b37a-3194f6d29aac Pragma: - no-cache RequestId: - - f47cd8be-5ec0-48e7-9d54-1c928deddb7a - Retry-After: - - '5' + - c12f800b-e0a2-4a59-a04e-2903b2854608 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -202,14 +193,12 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' - x-ms-operation-id: - - dbb74b3b-99c5-4c1c-ae10-91ad32a59afe status: - code: 202 - message: Accepted + code: 201 + message: Created - request: body: null headers: @@ -222,41 +211,42 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/dbb74b3b-99c5-4c1c-ae10-91ad32a59afe + uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"status": "Succeeded", "createdTimeUtc": "2025-12-31T14:38:41.4469362", - "lastUpdatedTimeUtc": "2025-12-31T14:38:42.7752692", "percentComplete": 100, - "error": null}' + string: '{"value": [{"id": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "a32f2c4b-828b-4897-8b4b-9225c45db8d6", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: Access-Control-Expose-Headers: - - RequestId,Location,x-ms-operation-id + - RequestId Cache-Control: - no-store, must-revalidate, no-cache Content-Encoding: - gzip Content-Length: - - '132' + - '567' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:46 GMT - Location: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/dbb74b3b-99c5-4c1c-ae10-91ad32a59afe/result + - Mon, 08 Sep 2025 17:20:24 GMT Pragma: - no-cache RequestId: - - 0cdbb703-7c55-4555-96bb-c5792ab6dd27 + - ffcc5b5c-c947-4400-89aa-cfd3926187a5 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: - nosniff X-Frame-Options: - deny - x-ms-operation-id: - - dbb74b3b-99c5-4c1c-ae10-91ad32a59afe + home-cluster-uri: + - https://wabi-west-europe-redirect.analysis.windows.net/ + request-redirected: + - 'true' status: code: 200 message: OK @@ -272,13 +262,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/dbb74b3b-99c5-4c1c-ae10-91ad32a59afe/result + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/items response: body: - string: '{"applicationId": "c7d3c782-72a2-47e1-ba87-c3039090f603", "servicePrincipalId": - "df83e5ef-fcd6-4dbf-b773-53ad2542cf15"}' + string: '{"value": []}' headers: Access-Control-Expose-Headers: - RequestId @@ -286,22 +275,75 @@ interactions: - no-store, must-revalidate, no-cache Content-Encoding: - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 08 Sep 2025 17:20:24 GMT + Pragma: + - no-cache + RequestId: + - 2ec46d3d-6330-425c-9459-3fadc8e9f74a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-west-europe-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive Content-Type: - application/json + User-Agent: + - ms-fabric-cli-test/1.1.0.rc2 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders?recursive=True + response: + body: + string: '{"value": [{"id": "8a745177-5b9e-432f-b37a-3194f6d29aac", "displayName": + "fabcli000001", "workspaceId": "a32f2c4b-828b-4897-8b4b-9225c45db8d6"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '142' + Content-Type: + - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:47 GMT + - Mon, 08 Sep 2025 17:20:24 GMT Pragma: - no-cache RequestId: - - a73cdc1f-3a31-4894-9a5e-e1f61c497247 + - de0b7934-27db-474b-a1d0-18a9f39d3074 Strict-Transport-Security: - max-age=31536000; includeSubDomains - Transfer-Encoding: - - chunked X-Content-Type-Options: - nosniff X-Frame-Options: - deny + home-cluster-uri: + - https://wabi-west-europe-redirect.analysis.windows.net/ + request-redirected: + - 'true' status: code: 200 message: OK @@ -317,13 +359,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "81065bd8-e334-4715-b170-dedb4cd514e6", + string: '{"value": [{"id": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "a32f2c4b-828b-4897-8b4b-9225c45db8d6", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: @@ -334,15 +376,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2091' + - '567' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:47 GMT + - Mon, 08 Sep 2025 17:20:25 GMT Pragma: - no-cache RequestId: - - cb3d6c4b-926f-4214-9727-025c0d3c9bfb + - 052492a8-6fe8-46a1-9114-00b9b47e859d Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -350,7 +392,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -368,17 +410,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6 + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/items response: body: - string: '{"id": "81065bd8-e334-4715-b170-dedb4cd514e6", "displayName": "fabriccli_WorkspacePerTestclass_000001", - "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", - "capacityRegion": "Central US", "oneLakeEndpoints": {"blobEndpoint": "https://centralus-onelake.blob.fabric.microsoft.com", - "dfsEndpoint": "https://centralus-onelake.dfs.fabric.microsoft.com"}, "capacityAssignmentProgress": - "Completed", "workspaceIdentity": {"applicationId": "c7d3c782-72a2-47e1-ba87-c3039090f603", - "servicePrincipalId": "df83e5ef-fcd6-4dbf-b773-53ad2542cf15"}}' + string: '{"value": []}' headers: Access-Control-Expose-Headers: - RequestId @@ -387,15 +424,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '382' + - '32' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:48 GMT + - Mon, 08 Sep 2025 17:20:24 GMT Pragma: - no-cache RequestId: - - 2454b4eb-c260-4e74-abb2-81538009b9d9 + - 006e956b-cbe1-445e-b75d-678e31895b67 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -403,7 +440,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -421,15 +458,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders?recursive=True response: body: - string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "81065bd8-e334-4715-b170-dedb4cd514e6", - "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created - by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + string: '{"value": [{"id": "8a745177-5b9e-432f-b37a-3194f6d29aac", "displayName": + "fabcli000001", "workspaceId": "a32f2c4b-828b-4897-8b4b-9225c45db8d6"}]}' headers: Access-Control-Expose-Headers: - RequestId @@ -438,15 +473,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2091' + - '142' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:49 GMT + - Mon, 08 Sep 2025 17:20:25 GMT Pragma: - no-cache RequestId: - - 0da50c39-6f2e-401f-a7c4-848adf1e1b0f + - 9ea02d8f-787c-42f3-96f6-2bdb221ffc4c Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -454,7 +489,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -472,17 +507,15 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 + - ms-fabric-cli-test/1.1.0.rc2 method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6 + uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"id": "81065bd8-e334-4715-b170-dedb4cd514e6", "displayName": "fabriccli_WorkspacePerTestclass_000001", - "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", - "capacityRegion": "Central US", "oneLakeEndpoints": {"blobEndpoint": "https://centralus-onelake.blob.fabric.microsoft.com", - "dfsEndpoint": "https://centralus-onelake.dfs.fabric.microsoft.com"}, "capacityAssignmentProgress": - "Completed", "workspaceIdentity": {"applicationId": "c7d3c782-72a2-47e1-ba87-c3039090f603", - "servicePrincipalId": "df83e5ef-fcd6-4dbf-b773-53ad2542cf15"}}' + string: '{"value": [{"id": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "a32f2c4b-828b-4897-8b4b-9225c45db8d6", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: Access-Control-Expose-Headers: - RequestId @@ -491,15 +524,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '382' + - '567' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:49 GMT + - Mon, 08 Sep 2025 17:20:24 GMT Pragma: - no-cache RequestId: - - 4a613646-d7df-4702-aebc-41eabae7ab35 + - 7b5d5c56-31cd-44a2-8eaa-3262dea00e61 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -507,7 +540,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -522,38 +555,33 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Length: - - '0' Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 - method: POST - uri: https://api.fabric.microsoft.com/v1/workspaces/81065bd8-e334-4715-b170-dedb4cd514e6/deprovisionIdentity + - ms-fabric-cli-test/1.1.0.rc2 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders?recursive=True response: body: - string: 'null' + string: '{"value": [{"id": "8a745177-5b9e-432f-b37a-3194f6d29aac", "displayName": + "fabcli000001", "workspaceId": "a32f2c4b-828b-4897-8b4b-9225c45db8d6"}]}' headers: Access-Control-Expose-Headers: - - RequestId,Location,Retry-After,x-ms-operation-id + - RequestId Cache-Control: - no-store, must-revalidate, no-cache Content-Encoding: - gzip Content-Length: - - '24' + - '142' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 31 Dec 2025 14:38:49 GMT - Location: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/7eb48be7-3e2c-4d09-8196-8ff0ca24ffee + - Mon, 08 Sep 2025 17:20:25 GMT Pragma: - no-cache RequestId: - - 32c27277-9881-4427-aacd-f12a8d67edf4 - Retry-After: - - '5' + - 16d824f5-8cf3-43d9-bace-837728fe671a Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -561,14 +589,12 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + - https://wabi-west-europe-redirect.analysis.windows.net/ request-redirected: - 'true' - x-ms-operation-id: - - 7eb48be7-3e2c-4d09-8196-8ff0ca24ffee status: - code: 202 - message: Accepted + code: 200 + message: OK - request: body: null headers: @@ -578,17 +604,17 @@ interactions: - gzip, deflate Connection: - keep-alive + Content-Length: + - '0' Content-Type: - application/json User-Agent: - - ms-fabric-cli-test/1.3.1 - method: GET - uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/7eb48be7-3e2c-4d09-8196-8ff0ca24ffee + - ms-fabric-cli-test/1.1.0.rc2 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/a32f2c4b-828b-4897-8b4b-9225c45db8d6/folders/8a745177-5b9e-432f-b37a-3194f6d29aac response: body: - string: '{"status": "Succeeded", "createdTimeUtc": "2025-12-31T14:38:49.5878458", - "lastUpdatedTimeUtc": "2025-12-31T14:38:50.5722903", "percentComplete": 100, - "error": null}' + string: '' headers: Access-Control-Expose-Headers: - RequestId @@ -597,21 +623,25 @@ interactions: Content-Encoding: - gzip Content-Length: - - '131' + - '0' Content-Type: - - application/json; charset=utf-8 + - application/octet-stream Date: - - Wed, 31 Dec 2025 14:38:54 GMT + - Mon, 08 Sep 2025 17:20:25 GMT Pragma: - no-cache RequestId: - - fc7e0ed7-709f-4541-82b8-82e23b281993 + - 62cc9b13-e04d-417f-a2d5-e256a53b6094 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: - nosniff X-Frame-Options: - deny + home-cluster-uri: + - https://wabi-west-europe-redirect.analysis.windows.net/ + request-redirected: + - 'true' status: code: 200 message: OK diff --git a/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml b/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml index 573ce31e..e35d12e1 100644 --- a/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml +++ b/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml @@ -26,15 +26,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2906' + - '3325' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:03:55 GMT + - Sun, 01 Mar 2026 14:13:31 GMT Pragma: - no-cache RequestId: - - 78a45eaa-df2e-42b9-a152-b016c949c59a + - ecd72f98-90e1-4591-ac13-2506ffa31f53 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -75,15 +75,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2906' + - '3325' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:03:55 GMT + - Sun, 01 Mar 2026 14:13:31 GMT Pragma: - no-cache RequestId: - - ebf784e9-a2f3-43d8-97e4-6642f6f3a893 + - cfbababf-e0d0-4c9c-b47a-e2d383858090 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -125,15 +125,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '424' + - '429' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:03:59 GMT + - Sun, 01 Mar 2026 14:13:37 GMT Pragma: - no-cache RequestId: - - 2c18461f-f08c-4b2f-85d7-5a701e9aa873 + - cb10dc80-9ade-4017-bc0c-bc11c5150755 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -167,7 +167,7 @@ interactions: uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"id": "ebc4005f-d298-4926-9fbf-3f99130d4b00", "displayName": "fabriccli_WorkspacePerTestclass_000001", + string: '{"id": "cc971f75-db59-4e10-8ca3-451e5d530493", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}' headers: Access-Control-Expose-Headers: @@ -177,17 +177,17 @@ interactions: Content-Encoding: - gzip Content-Length: - - '187' + - '188' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:04:07 GMT + - Sun, 01 Mar 2026 14:13:44 GMT Location: - - https://api.fabric.microsoft.com/v1/workspaces/ebc4005f-d298-4926-9fbf-3f99130d4b00 + - https://api.fabric.microsoft.com/v1/workspaces/cc971f75-db59-4e10-8ca3-451e5d530493 Pragma: - no-cache RequestId: - - 61609a16-c311-4a31-8fbd-90a178d2a0a5 + - a00ca072-3c53-4831-aa17-c69178a49be0 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -213,13 +213,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.3.1 (set; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: body: string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "ebc4005f-d298-4926-9fbf-3f99130d4b00", + "My workspace", "description": "", "type": "Personal"}, {"id": "cc971f75-db59-4e10-8ca3-451e5d530493", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' headers: @@ -230,15 +230,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2939' + - '3360' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:05:22 GMT + - Sun, 01 Mar 2026 14:14:28 GMT Pragma: - no-cache RequestId: - - fa60c476-11cc-453d-82c6-d7578c1e4125 + - 1421bed5-f8a4-4992-98c7-9ebdebf9b971 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -264,9 +264,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.3.1 (set; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/ebc4005f-d298-4926-9fbf-3f99130d4b00/items + uri: https://api.fabric.microsoft.com/v1/workspaces/cc971f75-db59-4e10-8ca3-451e5d530493/items response: body: string: '{"value": []}' @@ -282,11 +282,11 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Wed, 11 Feb 2026 08:05:23 GMT + - Sun, 01 Mar 2026 14:14:28 GMT Pragma: - no-cache RequestId: - - dc2e7fea-cb38-4449-b800-482ceefb365e + - 2b32e874-8afc-4b78-bb77-c7120bc27a41 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -314,9 +314,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.3.1 (set; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: DELETE - uri: https://api.fabric.microsoft.com/v1/workspaces/ebc4005f-d298-4926-9fbf-3f99130d4b00 + uri: https://api.fabric.microsoft.com/v1/workspaces/cc971f75-db59-4e10-8ca3-451e5d530493 response: body: string: '' @@ -332,11 +332,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 11 Feb 2026 08:05:24 GMT + - Sun, 01 Mar 2026 14:14:28 GMT Pragma: - no-cache RequestId: - - 0a5e091c-d126-4f21-b562-822331f90efe + - eb7a4525-2886-4bb6-8062-c1a49e32a41c Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: diff --git a/tests/test_commands/test_ls.py b/tests/test_commands/test_ls.py index 45cd22a3..a3bccac1 100644 --- a/tests/test_commands/test_ls.py +++ b/tests/test_commands/test_ls.py @@ -18,15 +18,15 @@ ) from fabric_cli.errors import ErrorMessages from tests.test_commands.commands_parser import CLIExecutor -from tests.test_commands.data.static_test_data import StaticTestData -from tests.test_commands.utils import cli_path_join from tests.test_commands.conftest import ( basic_item_parametrize, - item_type_paramerter, command_ls_parameters, + item_type_paramerter, + ls_folder_content_success_params, ls_item_folders_success_params, - ls_folder_content_success_params ) +from tests.test_commands.data.static_test_data import StaticTestData +from tests.test_commands.utils import cli_path_join class TestLS: @@ -218,7 +218,7 @@ def test_ls_query_filter_success( item3 = item_factory(item_type) # Test 1: Basic JMESPath syntax - cli_executor.exec_command(f'ls {workspace.full_path} -q [].name') + cli_executor.exec_command(f"ls {workspace.full_path} -q [].name") mock_questionary_print.assert_called() _assert_strings_in_mock_calls( [item1.display_name, item2.display_name, item3.display_name], @@ -243,13 +243,13 @@ def test_ls_query_filter_success( ["displayName", "itemID"], True, mock_questionary_print.mock_calls, - require_all_in_same_args=True + require_all_in_same_args=True, ) mock_questionary_print.reset_mock() # Test 3: JMESPath list syntax - here there are not keys so will be printed as list of arrays - cli_executor.exec_command(f'ls {workspace.full_path} -q [].[name]') + cli_executor.exec_command(f"ls {workspace.full_path} -q [].[name]") _assert_strings_in_mock_calls( [f"['{item1.name}']", f"['{item2.name}']", f"['{item3.name}']"], True, @@ -1115,6 +1115,32 @@ def test_ls_subfolder_success( require_all_in_same_args=True, ) + def test_ls_workspace_with_folders_and_items_divider( + self, + workspace, + folder_factory, + mock_questionary_print, + cli_executor: CLIExecutor, + ): + # Setup + folder = folder_factory() + + # Execute + cli_executor.exec_command(f"ls {workspace.full_path}") + + # Assert + mock_questionary_print.assert_called() + _assert_strings_in_mock_calls( + ["[Folders]", "[Items]"], + True, + mock_questionary_print.mock_calls, + ) + _assert_strings_in_mock_calls( + [folder.display_name], + True, + mock_questionary_print.mock_calls, + ) + @ls_folder_content_success_params def test_ls_folder_content_success( self,