diff --git a/tests/test_commands/conftest.py b/tests/test_commands/conftest.py index 806c221c..392f9e5f 100644 --- a/tests/test_commands/conftest.py +++ b/tests/test_commands/conftest.py @@ -41,6 +41,25 @@ ) from tests.test_commands.utils import cli_path_join, set_vcr_mode_env +custom_parametrize = pytest.mark.parametrize("item_type", [ + ItemType.DATA_PIPELINE, + ItemType.ENVIRONMENT, ItemType.EVENTHOUSE, ItemType.EVENTSTREAM, + ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + ItemType.LAKEHOUSE, ItemType.ML_EXPERIMENT, ItemType.ML_MODEL, + ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + ItemType.REFLEX, ItemType.REPORT, + ItemType.SQL_DATABASE, ItemType.SEMANTIC_MODEL, + ItemType.SPARK_JOB_DEFINITION, ItemType.WAREHOUSE, ItemType.COPYJOB, + ItemType.GRAPHQLAPI, ItemType.DATAFLOW, +]) + +basic_item_parametrize = pytest.mark.parametrize("item_type", [ + ItemType.DATA_PIPELINE, ItemType.ENVIRONMENT, ItemType.EVENTSTREAM, + ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, ItemType.ML_EXPERIMENT, + ItemType.ML_MODEL, ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, +]) + FILTER_HEADERS = [ "authorization", "client-request-id", diff --git a/tests/test_commands/recordings/test_commands/test_cd/class_setup.yaml b/tests/test_commands/recordings/test_commands/test_cd/class_setup.yaml index e8ce67f7..eb405374 100644 --- a/tests/test_commands/recordings/test_commands/test_cd/class_setup.yaml +++ b/tests/test_commands/recordings/test_commands/test_cd/class_setup.yaml @@ -11,12 +11,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (None; 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": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": "My workspace", "description": "", "type": "Personal"}]}' headers: Access-Control-Expose-Headers: @@ -26,15 +26,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '323' + - '2271' Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:08:23 GMT + - Wed, 28 Jan 2026 07:54:31 GMT Pragma: - no-cache RequestId: - - e5bfcae4-49fa-474f-8a54-cbc93765bb81 + - 77abc3e1-d0de-46fa-a502-5f7481fba1b4 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -42,7 +42,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -60,12 +60,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (None; 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": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": "My workspace", "description": "", "type": "Personal"}]}' headers: Access-Control-Expose-Headers: @@ -75,15 +75,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '323' + - '2271' Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:08:23 GMT + - Wed, 28 Jan 2026 07:54:32 GMT Pragma: - no-cache RequestId: - - 0d5c5e29-1383-47bb-be9c-bfc7e67f0b52 + - e4a5e1ab-b8f5-425f-9dd4-0466f46f58e5 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -91,7 +91,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -109,13 +109,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (None; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: GET uri: https://api.fabric.microsoft.com/v1/capacities response: body: string: '{"value": [{"id": "00000000-0000-0000-0000-000000000004", "displayName": - "mocked_fabriccli_capacity_name", "sku": "F16", "region": "West Europe", "state": + "mocked_fabriccli_capacity_name", "sku": "F32", "region": "Central US", "state": "Active"}]}' headers: Access-Control-Expose-Headers: @@ -125,15 +125,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '456' + - '425' Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:08:28 GMT + - Wed, 28 Jan 2026 07:54:36 GMT Pragma: - no-cache RequestId: - - 0baf4c77-8680-4f8e-a74a-bad86bf9361e + - eeeae5f9-f08e-4c4d-960f-5d2adf1692ff Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -141,7 +141,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -162,12 +162,12 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (None; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: POST uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"id": "24e77cc9-b249-414d-a402-05915759c048", "displayName": "fabriccli_WorkspacePerTestclass_000001", + string: '{"id": "293fae32-f430-4d4f-9929-4cd04fc6d245", "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: - - '189' + - '187' Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:08:34 GMT + - Wed, 28 Jan 2026 07:54:43 GMT Location: - - https://api.fabric.microsoft.com/v1/workspaces/24e77cc9-b249-414d-a402-05915759c048 + - https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245 Pragma: - no-cache RequestId: - - f7af61ad-d2b4-413f-9069-6ce658374380 + - 0372c498-09a2-49c8-90cb-87657d8a34be Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -195,7 +195,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -213,13 +213,13 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (cd; 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": "94da8ea5-0bd6-4a9e-b717-5fdb482f4c71", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "24e77cc9-b249-414d-a402-05915759c048", + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "293fae32-f430-4d4f-9929-4cd04fc6d245", "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: - - '355' + - '2305' Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:18:20 GMT + - Wed, 28 Jan 2026 07:57:48 GMT Pragma: - no-cache RequestId: - - e40b801b-9e34-4a1a-b177-e0e9f9d372a5 + - 5ae56619-f725-40b9-b6ed-96fd627c4e5a Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -246,7 +246,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -264,9 +264,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (cd; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/24e77cc9-b249-414d-a402-05915759c048/items + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items response: body: string: '{"value": []}' @@ -282,11 +282,11 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Tue, 02 Sep 2025 18:18:21 GMT + - Wed, 28 Jan 2026 07:57:49 GMT Pragma: - no-cache RequestId: - - 2703ca19-69b7-4f7e-bf50-fa05a75a3dd2 + - 582ae0d5-5b2b-43c7-a6a0-596de06a6bc5 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -294,7 +294,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: @@ -314,9 +314,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.0.0 (cd; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2) + - ms-fabric-cli/1.3.1 (cd; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2) method: DELETE - uri: https://api.fabric.microsoft.com/v1/workspaces/24e77cc9-b249-414d-a402-05915759c048 + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245 response: body: string: '' @@ -332,11 +332,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Tue, 02 Sep 2025 18:18:21 GMT + - Wed, 28 Jan 2026 07:57:49 GMT Pragma: - no-cache RequestId: - - 5c1c8141-9fdb-476a-aa16-562d08edcfeb + - 5481d436-c6e4-4acd-8c1f-560498a31da9 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -344,7 +344,7 @@ interactions: X-Frame-Options: - deny home-cluster-uri: - - https://wabi-west-europe-redirect.analysis.windows.net/ + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ request-redirected: - 'true' status: diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[DataPipeline].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[DataPipeline].yaml new file mode 100644 index 00000000..51947a27 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[DataPipeline].yaml @@ -0,0 +1,456 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:44 GMT + Pragma: + - no-cache + RequestId: + - 50b5c121-3cf5-439f-89ac-8074e61e8a0b + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:45 GMT + Pragma: + - no-cache + RequestId: + - e666144e-d328-48f6-923e-3ca98903e169 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:46 GMT + Pragma: + - no-cache + RequestId: + - 0214d75b-f3a3-4cb8-872e-6485dd0899ee + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "DataPipeline", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/dataPipelines + response: + body: + string: '{"id": "b858cf4c-229c-4d38-b2a5-b722bfb7d93f", "type": "DataPipeline", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '169' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:53 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - 9bb44f6a-22b5-4cac-af8c-89cffd59a243 + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:53 GMT + Pragma: + - no-cache + RequestId: + - 135e48a8-7fe6-47d7-a4a8-39e25be4b0b7 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "b858cf4c-229c-4d38-b2a5-b722bfb7d93f", "type": "DataPipeline", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '180' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:55 GMT + Pragma: + - no-cache + RequestId: + - c6da64a7-8d40-4f4a-a397-dd0549890a04 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:55 GMT + Pragma: + - no-cache + RequestId: + - b6a02241-3004-4103-8aee-92a3e62772af + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "b858cf4c-229c-4d38-b2a5-b722bfb7d93f", "type": "DataPipeline", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '180' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:57 GMT + Pragma: + - no-cache + RequestId: + - b6e856a3-867d-4d02-a8d7-8b362ecb5c92 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/b858cf4c-229c-4d38-b2a5-b722bfb7d93f + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:54:57 GMT + Pragma: + - no-cache + RequestId: + - f71a4a0c-6fbe-42d2-8f8b-1d41b2d34a56 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Environment].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Environment].yaml new file mode 100644 index 00000000..3d11a66c --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Environment].yaml @@ -0,0 +1,456 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:58 GMT + Pragma: + - no-cache + RequestId: + - 2ae70b3f-902f-4f95-b66f-b3fbf72c938e + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:54:59 GMT + Pragma: + - no-cache + RequestId: + - da5d42cc-9e86-4d82-8808-9b198d2f9c90 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:00 GMT + Pragma: + - no-cache + RequestId: + - 3fe61469-b8e8-45a0-94dc-f39d82e5991a + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "Environment", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '109' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/environments + response: + body: + string: '{"id": "d03b7d6c-c195-4e4e-9bad-47e56ca68569", "type": "Environment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '169' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:02 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - e80c024b-155e-4796-a518-6fd20104e018 + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:04 GMT + Pragma: + - no-cache + RequestId: + - 515bc40c-ca1d-45e8-ba2b-5bc06fbaf1b7 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "d03b7d6c-c195-4e4e-9bad-47e56ca68569", "type": "Environment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '181' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:05 GMT + Pragma: + - no-cache + RequestId: + - 12b32c32-da92-4903-8030-897288612f3c + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:05 GMT + Pragma: + - no-cache + RequestId: + - a781d042-01d3-4954-90d9-92f6faf4ad1f + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "d03b7d6c-c195-4e4e-9bad-47e56ca68569", "type": "Environment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '181' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:07 GMT + Pragma: + - no-cache + RequestId: + - 4c657673-6c75-43ba-a4cc-85b6d12d8635 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/d03b7d6c-c195-4e4e-9bad-47e56ca68569 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:55:07 GMT + Pragma: + - no-cache + RequestId: + - 688d9341-e710-4f80-b6bb-66ef0f50ef31 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Eventstream].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Eventstream].yaml new file mode 100644 index 00000000..31ffbae9 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Eventstream].yaml @@ -0,0 +1,556 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:08 GMT + Pragma: + - no-cache + RequestId: + - 9c749001-a28c-4620-b358-9fefc70f4807 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:09 GMT + Pragma: + - no-cache + RequestId: + - 1c787b00-6139-429e-bb44-de2c2f0dea7a + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:09 GMT + Pragma: + - no-cache + RequestId: + - 3697b861-fa1c-49e6-a561-49a20ed48faf + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "Eventstream", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '109' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/eventstreams + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:11 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/5637561a-32d0-4faf-9f1e-642dd8cd78bc + Pragma: + - no-cache + RequestId: + - 9272cf7c-708a-4023-ad3b-555aeb4d890a + Retry-After: + - '20' + 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' + x-ms-operation-id: + - 5637561a-32d0-4faf-9f1e-642dd8cd78bc + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + 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/5637561a-32d0-4faf-9f1e-642dd8cd78bc + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-01-28T07:55:11.0213304", + "lastUpdatedTimeUtc": "2026-01-28T07:55:13.9906874", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '131' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:32 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/5637561a-32d0-4faf-9f1e-642dd8cd78bc/result + Pragma: + - no-cache + RequestId: + - 7f18b6e1-1a97-4bc8-87f2-71b550f3d077 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 5637561a-32d0-4faf-9f1e-642dd8cd78bc + 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.3.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/5637561a-32d0-4faf-9f1e-642dd8cd78bc/result + response: + body: + string: '{"id": "b67b0811-0c4b-4d30-8dc7-217aed0f5e27", "type": "Eventstream", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 28 Jan 2026 07:55:33 GMT + Pragma: + - no-cache + RequestId: + - 2ab39827-360a-49f2-bff6-02a7ba28a677 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + 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.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:34 GMT + Pragma: + - no-cache + RequestId: + - 9e4eea6c-5fad-4f3e-b4c1-da37010762ef + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "b67b0811-0c4b-4d30-8dc7-217aed0f5e27", "type": "Eventstream", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '180' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:35 GMT + Pragma: + - no-cache + RequestId: + - 55ce9365-1ba5-4ee9-beb3-5d7429b6cdc0 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:36 GMT + Pragma: + - no-cache + RequestId: + - 79c20153-7145-458b-b3e1-a0915e6e0a22 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "b67b0811-0c4b-4d30-8dc7-217aed0f5e27", "type": "Eventstream", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '180' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:36 GMT + Pragma: + - no-cache + RequestId: + - 86e1bba5-cf34-4daa-b701-d7aced51de1f + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/b67b0811-0c4b-4d30-8dc7-217aed0f5e27 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:55:37 GMT + Pragma: + - no-cache + RequestId: + - 5dce35a3-b34e-421d-b868-3701be522c1d + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLDashboard].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLDashboard].yaml new file mode 100644 index 00000000..ba6fb058 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLDashboard].yaml @@ -0,0 +1,456 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:38 GMT + Pragma: + - no-cache + RequestId: + - 30cc875d-0329-474c-a0af-3263ead7dd3f + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:39 GMT + Pragma: + - no-cache + RequestId: + - 0558eddc-a4e4-482d-8056-ab0871a46d4a + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:39 GMT + Pragma: + - no-cache + RequestId: + - 622130b7-5f8b-4199-b773-63e4128b467d + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "KQLDashboard", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/kqlDashboards + response: + body: + string: '{"id": "af166615-3e19-4953-970f-6dc16e9d716c", "type": "KQLDashboard", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '172' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:42 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - 562a1e8c-7f0c-4072-a112-d80b7e49a59f + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:42 GMT + Pragma: + - no-cache + RequestId: + - 205993fc-5354-4e7d-bb02-041a5edb0049 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "af166615-3e19-4953-970f-6dc16e9d716c", "type": "KQLDashboard", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '183' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:44 GMT + Pragma: + - no-cache + RequestId: + - ff6ffabc-10d9-49ec-991d-1df08da82531 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:45 GMT + Pragma: + - no-cache + RequestId: + - 6728c099-77b2-479c-999d-2c1ae9b18056 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "af166615-3e19-4953-970f-6dc16e9d716c", "type": "KQLDashboard", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '183' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:45 GMT + Pragma: + - no-cache + RequestId: + - 77f614fe-a2b1-4de7-bb46-7fcf3a03be36 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/af166615-3e19-4953-970f-6dc16e9d716c + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:55:46 GMT + Pragma: + - no-cache + RequestId: + - 4ef45823-9689-4c0b-8b18-8db49c94f69f + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLQueryset].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLQueryset].yaml new file mode 100644 index 00000000..3db04e30 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[KQLQueryset].yaml @@ -0,0 +1,456 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:47 GMT + Pragma: + - no-cache + RequestId: + - 2727b098-232b-4f23-b50d-3fc484f86bdc + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:48 GMT + Pragma: + - no-cache + RequestId: + - b47cfcea-c552-4a4c-ae42-6941a5c28014 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:49 GMT + Pragma: + - no-cache + RequestId: + - 9fd4bf48-c977-4cfe-9a75-c370292f598c + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "KQLQueryset", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '109' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/kqlQuerysets + response: + body: + string: '{"id": "9b5dd4ff-85b8-4edd-a127-7d3918cdf426", "type": "KQLQueryset", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:50 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - ffdcd9b5-dbb1-4aad-9e10-06014e75ab73 + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:51 GMT + Pragma: + - no-cache + RequestId: + - 122b2f37-ca6d-48ba-908b-6c1ddcdcf930 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "9b5dd4ff-85b8-4edd-a127-7d3918cdf426", "type": "KQLQueryset", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '182' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:52 GMT + Pragma: + - no-cache + RequestId: + - a11d502c-76e2-4950-9ad9-3131e36ad6e3 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:52 GMT + Pragma: + - no-cache + RequestId: + - a83e6c0d-991f-45ba-a84b-989174b8faf5 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "9b5dd4ff-85b8-4edd-a127-7d3918cdf426", "type": "KQLQueryset", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '182' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:53 GMT + Pragma: + - no-cache + RequestId: + - 3a52c8d0-c99a-4baa-b78a-ccdeec817947 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/9b5dd4ff-85b8-4edd-a127-7d3918cdf426 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:55:53 GMT + Pragma: + - no-cache + RequestId: + - 050881c2-786c-40fa-996f-3c2c45a0e7cc + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLExperiment].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLExperiment].yaml new file mode 100644 index 00000000..942c84d2 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLExperiment].yaml @@ -0,0 +1,556 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:53 GMT + Pragma: + - no-cache + RequestId: + - 682fea49-96a2-45f6-8ba8-b023c3d0f38d + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:54 GMT + Pragma: + - no-cache + RequestId: + - 7ae9ba83-46ca-464c-b6b6-3958e0cf2e0a + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:55 GMT + Pragma: + - no-cache + RequestId: + - f00f0baa-a7bc-4230-93a8-526e61b26ea8 + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "MLExperiment", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/mlExperiments + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:55:56 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/9f48d8a6-cfb3-4501-96a9-87c22d5d79ce + Pragma: + - no-cache + RequestId: + - deacc5dc-b8d9-446d-8208-b2acce044590 + Retry-After: + - '20' + 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' + x-ms-operation-id: + - 9f48d8a6-cfb3-4501-96a9-87c22d5d79ce + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + 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/9f48d8a6-cfb3-4501-96a9-87c22d5d79ce + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-01-28T07:55:56.4368672", + "lastUpdatedTimeUtc": "2026-01-28T07:55:57.3274901", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '132' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:18 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/9f48d8a6-cfb3-4501-96a9-87c22d5d79ce/result + Pragma: + - no-cache + RequestId: + - bcd9da69-b52c-4141-bb18-eaefaee5ed3e + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 9f48d8a6-cfb3-4501-96a9-87c22d5d79ce + 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.3.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/9f48d8a6-cfb3-4501-96a9-87c22d5d79ce/result + response: + body: + string: '{"id": "7a1e4792-6dbb-4c2f-b186-849fb506e1cd", "type": "MLExperiment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 28 Jan 2026 07:56:18 GMT + Pragma: + - no-cache + RequestId: + - 91ba00e3-d4cd-482f-9ea7-1fc4f127928c + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + 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.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:19 GMT + Pragma: + - no-cache + RequestId: + - 5c3612f1-21e0-4b90-aef8-e4b621becc03 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "7a1e4792-6dbb-4c2f-b186-849fb506e1cd", "type": "MLExperiment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '183' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:20 GMT + Pragma: + - no-cache + RequestId: + - 0b373565-3ada-4825-b1da-9f8441792acb + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:21 GMT + Pragma: + - no-cache + RequestId: + - 2afc9aff-b7ea-43df-9f67-6db122094ba3 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "7a1e4792-6dbb-4c2f-b186-849fb506e1cd", "type": "MLExperiment", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '183' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:21 GMT + Pragma: + - no-cache + RequestId: + - cdb769fc-ae3d-480c-b394-f067ac911db3 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/7a1e4792-6dbb-4c2f-b186-849fb506e1cd + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:56:22 GMT + Pragma: + - no-cache + RequestId: + - f8a82008-9b64-48c0-8c82-4181dc2f6dd8 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLModel].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLModel].yaml new file mode 100644 index 00000000..b4589251 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MLModel].yaml @@ -0,0 +1,555 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:22 GMT + Pragma: + - no-cache + RequestId: + - 0e0248a6-7897-441b-970d-33eccb136c84 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:23 GMT + Pragma: + - no-cache + RequestId: + - 19adbd28-018d-4303-a39f-78f1d4b09e27 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:24 GMT + Pragma: + - no-cache + RequestId: + - 9f30c9d1-cc0c-40fd-9418-d9b6b6baeb6e + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "MLModel", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '105' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/mlModels + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:25 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e + Pragma: + - no-cache + RequestId: + - dd3b6231-c413-4b93-afd0-f48c3564a797 + Retry-After: + - '20' + 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' + x-ms-operation-id: + - 4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + 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/4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-01-28T07:56:25.460591", + "lastUpdatedTimeUtc": "2026-01-28T07:56:26.0699657", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '130' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:47 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e/result + Pragma: + - no-cache + RequestId: + - 454ca944-3f44-4d6a-ac56-3abe6304b3e9 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e + 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.3.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/4e230d23-8c8b-41b7-aa83-cf5dd42d1f4e/result + response: + body: + string: '{"id": "30fe39f4-e2e6-4a63-aa5d-0331f8861058", "type": "MLModel", "displayName": + "fabcli000001", "description": "Created by fab", "workspaceId": "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 28 Jan 2026 07:56:47 GMT + Pragma: + - no-cache + RequestId: + - b0f7a605-355c-4faf-af2a-e9c5c60bcc2c + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + 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.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:49 GMT + Pragma: + - no-cache + RequestId: + - 5d8af6b9-fb61-407b-8694-a8df0cdce6c7 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "30fe39f4-e2e6-4a63-aa5d-0331f8861058", "type": "MLModel", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:49 GMT + Pragma: + - no-cache + RequestId: + - 70c6ce10-50f9-4ec0-a527-8a38a6b3340f + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:50 GMT + Pragma: + - no-cache + RequestId: + - 19cd0eb1-96da-461c-990b-ed3126dd2754 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "30fe39f4-e2e6-4a63-aa5d-0331f8861058", "type": "MLModel", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:50 GMT + Pragma: + - no-cache + RequestId: + - fceee45c-5606-4347-bfa6-4cfc90cbdbc2 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/30fe39f4-e2e6-4a63-aa5d-0331f8861058 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:56:52 GMT + Pragma: + - no-cache + RequestId: + - 9b659099-4d60-4bbf-87be-b0951b944885 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MirroredDatabase].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MirroredDatabase].yaml new file mode 100644 index 00000000..4282b877 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[MirroredDatabase].yaml @@ -0,0 +1,458 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:52 GMT + Pragma: + - no-cache + RequestId: + - 61f26db1-18fa-474c-98b9-0d2caacadf61 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:53 GMT + Pragma: + - no-cache + RequestId: + - 8e2767ca-24a9-448c-98ef-d14a37314e94 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:54 GMT + Pragma: + - no-cache + RequestId: + - 0a1edcba-509f-4a90-a18e-4671a930f942 + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "MirroredDatabase", "folderId": null, "definition": {"parts": [{"path": "mirroring.json", + "payload": "ewogICAgInByb3BlcnRpZXMiOiB7CiAgICAgICAgInNvdXJjZSI6IHsKICAgICAgICAgICAgInR5cGUiOiAiR2VuZXJpY01pcnJvciIsCiAgICAgICAgICAgICJ0eXBlUHJvcGVydGllcyI6IHt9CiAgICAgICAgfSwKICAgICAgICAidGFyZ2V0IjogewogICAgICAgICAgICAidHlwZSI6ICJNb3VudGVkUmVsYXRpb25hbERhdGFiYXNlIiwKICAgICAgICAgICAgInR5cGVQcm9wZXJ0aWVzIjogewogICAgICAgICAgICAgICAgImZvcm1hdCI6ICJEZWx0YSIKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQ==", + "payloadType": "InlineBase64"}]}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '603' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/mirroredDatabases + response: + body: + string: '{"id": "124e1482-5b2e-4360-b59d-567d991ffa76", "type": "MirroredDatabase", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '170' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:57 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - 53feb2b7-f5e4-4337-9784-28ad6803f851 + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:58 GMT + Pragma: + - no-cache + RequestId: + - a3fba8f6-93eb-4756-840a-f9fe45707f41 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "124e1482-5b2e-4360-b59d-567d991ffa76", "type": "MirroredDatabase", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '185' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:58 GMT + Pragma: + - no-cache + RequestId: + - 87b13c32-26bd-4fa2-943c-fe6035b86dc8 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:56:59 GMT + Pragma: + - no-cache + RequestId: + - ab4a6ed8-d07a-48e5-bdae-7bae8085c448 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "124e1482-5b2e-4360-b59d-567d991ffa76", "type": "MirroredDatabase", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '185' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:00 GMT + Pragma: + - no-cache + RequestId: + - ab66b3d0-7d96-4dde-8f61-dad2246baaa0 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/124e1482-5b2e-4360-b59d-567d991ffa76 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:57:01 GMT + Pragma: + - no-cache + RequestId: + - 8de447e6-8fa1-4b4b-9ed4-c667d08b7027 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Notebook].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Notebook].yaml new file mode 100644 index 00000000..097f6441 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Notebook].yaml @@ -0,0 +1,558 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:02 GMT + Pragma: + - no-cache + RequestId: + - df7e001c-4f11-4acf-b33b-1f8cd79a9479 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:02 GMT + Pragma: + - no-cache + RequestId: + - fd9235a9-35ae-4ac1-a7ba-dffab538c53e + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:03 GMT + Pragma: + - no-cache + RequestId: + - 468fa066-e2df-4ea3-941c-65dc15a7435a + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "Notebook", "folderId": null, "definition": {"parts": [{"path": "notebook-content.py", + "payload": "IyBGYWJyaWMgbm90ZWJvb2sgc291cmNlCgojIE1FVEFEQVRBICoqKioqKioqKioqKioqKioqKioqCgojIE1FVEEgewojIE1FVEEgICAia2VybmVsX2luZm8iOiB7CiMgTUVUQSAgICAgIm5hbWUiOiAic3luYXBzZV9weXNwYXJrIgojIE1FVEEgICB9LAojIE1FVEEgICAiZGVwZW5kZW5jaWVzIjoge30KIyBNRVRBIH0KCiMgQ0VMTCAqKioqKioqKioqKioqKioqKioqKgoKIyBXZWxjb21lIHRvIHlvdXIgbmV3IG5vdGVib29rCiMgVHlwZSBoZXJlIGluIHRoZSBjZWxsIGVkaXRvciB0byBhZGQgY29kZSEKCgojIE1FVEFEQVRBICoqKioqKioqKioqKioqKioqKioqCgojIE1FVEEgewojIE1FVEEgICAibGFuZ3VhZ2UiOiAicHl0aG9uIiwKIyBNRVRBICAgImxhbmd1YWdlX2dyb3VwIjogInN5bmFwc2VfcHlzcGFyayIKIyBNRVRBIH0K", + "payloadType": "InlineBase64"}]}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '764' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/notebooks + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:05 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d47d1156-7dc5-4bc7-948e-8764225943e9 + Pragma: + - no-cache + RequestId: + - ab3079ef-ad31-4171-93ce-842a247dda37 + Retry-After: + - '20' + 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' + x-ms-operation-id: + - d47d1156-7dc5-4bc7-948e-8764225943e9 + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + 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/d47d1156-7dc5-4bc7-948e-8764225943e9 + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-01-28T07:57:05.1730548", + "lastUpdatedTimeUtc": "2026-01-28T07:57:06.4230613", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '131' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:26 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d47d1156-7dc5-4bc7-948e-8764225943e9/result + Pragma: + - no-cache + RequestId: + - 9606f60c-5827-4eb0-8909-e27c8b72da7a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - d47d1156-7dc5-4bc7-948e-8764225943e9 + 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.3.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d47d1156-7dc5-4bc7-948e-8764225943e9/result + response: + body: + string: '{"id": "5d890dc0-824b-471a-9a9e-57db182bb487", "type": "Notebook", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Wed, 28 Jan 2026 07:57:27 GMT + Pragma: + - no-cache + RequestId: + - 4ee90726-b2b4-4415-a28b-25492a92ac03 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + 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.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:28 GMT + Pragma: + - no-cache + RequestId: + - 1fb655a8-5e42-4a6f-97aa-1a797209c932 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "5d890dc0-824b-471a-9a9e-57db182bb487", "type": "Notebook", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:29 GMT + Pragma: + - no-cache + RequestId: + - 937cf278-fd9a-470e-bfe6-a1d8d96684b3 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:30 GMT + Pragma: + - no-cache + RequestId: + - 6d4fb77d-9edc-455e-9bec-214cb2dd2a00 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "5d890dc0-824b-471a-9a9e-57db182bb487", "type": "Notebook", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:31 GMT + Pragma: + - no-cache + RequestId: + - e1ab4e47-149e-4b91-a31e-988c62683fd9 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/5d890dc0-824b-471a-9a9e-57db182bb487 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:57:31 GMT + Pragma: + - no-cache + RequestId: + - 0dd04c1e-fef6-4313-8bf5-38df08c222a1 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Reflex].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Reflex].yaml new file mode 100644 index 00000000..1664022a --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[Reflex].yaml @@ -0,0 +1,455 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:31 GMT + Pragma: + - no-cache + RequestId: + - bacde33b-69d2-4014-81d7-36d1612fee7b + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:32 GMT + Pragma: + - no-cache + RequestId: + - ab664174-6f79-4e9f-98aa-2588ad2f8d6b + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:32 GMT + Pragma: + - no-cache + RequestId: + - 35ea08a4-b187-40a6-a82a-de10eb0b1f92 + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "Reflex", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '104' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/reflexes + response: + body: + string: '{"id": "92f5e445-1cad-479a-8b2a-6cf38709dcf9", "type": "Reflex", "displayName": + "fabcli000001", "description": "Created by fab", "workspaceId": "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '166' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:35 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - fc85e829-ce78-4e28-97da-5e7eefda4d99 + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:36 GMT + Pragma: + - no-cache + RequestId: + - ca8172c3-0112-4088-9cc0-c938c5bea4cb + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "92f5e445-1cad-479a-8b2a-6cf38709dcf9", "type": "Reflex", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:36 GMT + Pragma: + - no-cache + RequestId: + - 911146ed-3b0d-4f64-8cd2-10c01d4eb755 + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:37 GMT + Pragma: + - no-cache + RequestId: + - 38f2fbd3-d97f-4602-ad97-c6361152b0c5 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "92f5e445-1cad-479a-8b2a-6cf38709dcf9", "type": "Reflex", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '177' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:38 GMT + Pragma: + - no-cache + RequestId: + - b7113247-e423-46f9-ac3a-1f8c8e72cf45 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/92f5e445-1cad-479a-8b2a-6cf38709dcf9 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:57:39 GMT + Pragma: + - no-cache + RequestId: + - d6a8851c-183d-4d9e-9742-d3b30c4ea3be + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[SparkJobDefinition].yaml b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[SparkJobDefinition].yaml new file mode 100644 index 00000000..6b89c257 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_cd/test_cd_item_all_types_success[SparkJobDefinition].yaml @@ -0,0 +1,456 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:40 GMT + Pragma: + - no-cache + RequestId: + - b991d957-6c81-4fcb-bf23-7a6cc9e04b79 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:40 GMT + Pragma: + - no-cache + RequestId: + - 077c00d8-77a3-486a-85bf-bbe2d7eed974 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:42 GMT + Pragma: + - no-cache + RequestId: + - 4e6706f7-5041-44b0-b079-826c1468af77 + 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: '{"description": "Created by fab", "displayName": "fabcli000001", "type": + "SparkJobDefinition", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '116' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/sparkJobDefinitions + response: + body: + string: '{"id": "ceedc4c3-5401-43f6-a077-13e24fe86253", "type": "SparkJobDefinition", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}' + headers: + Access-Control-Expose-Headers: + - RequestId,ETag + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '173' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:43 GMT + ETag: + - '""' + Pragma: + - no-cache + RequestId: + - 113e0de4-0870-4f47-8704-46f2cf871eee + 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: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:43 GMT + Pragma: + - no-cache + RequestId: + - a2363aa0-5746-4075-800c-6f65b3941177 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "ceedc4c3-5401-43f6-a077-13e24fe86253", "type": "SparkJobDefinition", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '184' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:45 GMT + Pragma: + - no-cache + RequestId: + - 9af36f43-7f9d-4809-88c6-fc09027a249c + 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-test/1.3.1 + 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": "293fae32-f430-4d4f-9929-4cd04fc6d245", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created + by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '2305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:46 GMT + Pragma: + - no-cache + RequestId: + - 3fec00d5-8ea8-4a1d-93ca-2cf754c64517 + 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-test/1.3.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items + response: + body: + string: '{"value": [{"id": "ceedc4c3-5401-43f6-a077-13e24fe86253", "type": "SparkJobDefinition", + "displayName": "fabcli000001", "description": "Created by fab", "workspaceId": + "293fae32-f430-4d4f-9929-4cd04fc6d245"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '184' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 28 Jan 2026 07:57:47 GMT + Pragma: + - no-cache + RequestId: + - 6577cc90-61a9-408d-a7ee-63cca09b0b35 + 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-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.3.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/293fae32-f430-4d4f-9929-4cd04fc6d245/items/ceedc4c3-5401-43f6-a077-13e24fe86253 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Wed, 28 Jan 2026 07:57:47 GMT + Pragma: + - no-cache + RequestId: + - 0b2406ea-1cba-426f-8d8d-8799240ae598 + 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 +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_open/class_setup.yaml b/tests/test_commands/recordings/test_commands/test_open/class_setup.yaml index 176c6627..1a9c1fca 100644 --- a/tests/test_commands/recordings/test_commands/test_open/class_setup.yaml +++ b/tests/test_commands/recordings/test_commands/test_open/class_setup.yaml @@ -350,4 +350,4 @@ interactions: status: code: 200 message: OK -version: 1 +version: 1 \ No newline at end of file diff --git a/tests/test_commands/test_assign.py b/tests/test_commands/test_assign.py index 13bcea91..7ed00a87 100644 --- a/tests/test_commands/test_assign.py +++ b/tests/test_commands/test_assign.py @@ -4,6 +4,8 @@ import argparse from unittest.mock import patch +import pytest + import fabric_cli.commands.fs.fab_fs_unassign as fab_unassign from fabric_cli.commands.fs import fab_fs_get from fabric_cli.core import fab_constant as constant @@ -13,6 +15,65 @@ class TestAssign: + # region Parametrized Tests + # def test_assign_domain_workspace_success( + # self, + # workspace_factory, + # cli_executor, + # mock_questionary_print, + # virtual_workspace_item_factory, + # ): + # # Setup + # workspace = workspace_factory() + # domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) + # mock_questionary_print.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"assign {domain.full_path} --workspace {workspace.full_path} --force" + # ) + + # # Assert + # get(domain.full_path, query="domainWorkspaces") + # assert any( + # workspace.display_name in str(call.args[0]) + # for call in mock_questionary_print.mock_calls + # ) + + # @pytest.mark.parametrize("entity_type,factory_key,path_template", [ + # (VirtualWorkspaceType.CAPACITY, "test_data", "/.capacities/{}.Capacity"), + # (VirtualWorkspaceType.DOMAIN, "virtual_workspace_item_factory", "{}.full_path"), + # ]) + # def test_assign_entity_item_not_supported_failure( + # self, + # entity_type, + # factory_key, + # path_template, + # item_factory, + # cli_executor, + # assert_fabric_cli_error, + # test_data: StaticTestData, + # virtual_workspace_item_factory, + # ): + # # Setup + # lakehouse = item_factory(ItemType.LAKEHOUSE) + + # if factory_key == "test_data": + # entity_path = path_template.format(test_data.capacity.name) + # else: + # domain = virtual_workspace_item_factory(entity_type) + # entity_path = domain.full_path + + # # Execute command + # cli_executor.exec_command( + # f"assign {entity_path} --workspace {lakehouse.full_path} --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) + + # endregion + # region ASSIGN def test_assign_capacity_workspace_success( self, @@ -122,70 +183,6 @@ def test_assign_capacity_workspace_without_force_cancel_operation_success( for call in mock_questionary_print.mock_calls ) - def test_assign_capacity_item_not_supported_failure( - self, - item_factory, - cli_executor, - assert_fabric_cli_error, - test_data: StaticTestData, - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - capacity_full_path = f"/.capacities/{test_data.capacity.name}.Capacity" - - # Execute command - cli_executor.exec_command( - f"assign {capacity_full_path} --workspace {lakehouse.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) - - def test_assign_domain_workspace_success( - self, - virtual_workspace_item_factory, - workspace_factory, - mock_questionary_print, - cli_executor, - ): - # Setup - workspace = workspace_factory() - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - - # Reset mock - mock_questionary_print.reset_mock() - - # Execute command - cli_executor.exec_command( - f"assign {domain.full_path} --workspace {workspace.full_path} --force" - ) - - # Assert - get(domain.full_path, query="domainWorkspaces") - assert any( - workspace.display_name in call.args[0] - for call in mock_questionary_print.mock_calls - ) - - def test_assign_domain_item_not_supported_failure( - self, - virtual_workspace_item_factory, - item_factory, - cli_executor, - assert_fabric_cli_error, - ): - # Setup - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Execute command - cli_executor.exec_command( - f"assign {domain.full_path} --workspace {lakehouse.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) - # endregion diff --git a/tests/test_commands/test_cd.py b/tests/test_commands/test_cd.py index de9c0885..45ad4839 100644 --- a/tests/test_commands/test_cd.py +++ b/tests/test_commands/test_cd.py @@ -8,6 +8,7 @@ from fabric_cli.core.fab_types import ItemType from fabric_cli.core.hiearchy.fab_folder import Folder from fabric_cli.core.hiearchy.fab_hiearchy import Item, Tenant, Workspace +from tests.test_commands.conftest import basic_item_parametrize class TestCD: @@ -29,6 +30,20 @@ def test_cd_workspace_success(self, workspace, mock_print_done, cli_executor): assert isinstance(Context().context, Workspace) assert Context().context.name == workspace.name + @basic_item_parametrize + def test_cd_item_all_types_success(self, item_type, item_factory, mock_print_done, cli_executor): + # Setup + item = item_factory(item_type) + mock_print_done.reset_mock() + + # Execute command + cli_executor.exec_command(f"cd {item.full_path}") + + # Assert + mock_print_done.assert_called_once() + assert isinstance(Context().context, Item) + assert Context().context.name == item.name + @pytest.mark.parametrize( "special_character", [ @@ -82,19 +97,6 @@ def test_cd_workspace_with_special_characters_success( assert isinstance(Context().context, Workspace) assert Context().context.name == workspace.name - def test_cd_item_success(self, item_factory, mock_print_done, cli_executor): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command(f"cd {lakehouse.full_path}") - - # Assert - mock_print_done.assert_called_once() - assert isinstance(Context().context, Item) - assert Context().context.name == lakehouse.name - def test_cd_folder_success(self, folder_factory, mock_print_done, cli_executor): # Setup folder = folder_factory() diff --git a/tests/test_commands/test_cp.py b/tests/test_commands/test_cp.py index b29866dc..8bd4c3e1 100644 --- a/tests/test_commands/test_cp.py +++ b/tests/test_commands/test_cp.py @@ -5,6 +5,7 @@ import os import shutil import tempfile +import pytest from unittest.mock import patch import fabric_cli.commands.fs.fab_fs_cp as fab_cp @@ -37,7 +38,8 @@ def test_cp_workspace_to_workspace_non_recursive_success( ws1 = workspace_factory() ws2 = workspace_factory() notebook = item_factory(ItemType.NOTEBOOK, path=ws1.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, path=ws1.full_path) + data_pipeline = item_factory( + ItemType.DATA_PIPELINE, path=ws1.full_path) f1 = folder_factory(path=ws1.full_path) # Subfolder in f1 sjd = item_factory(ItemType.SPARK_JOB_DEFINITION, path=f1.full_path) @@ -57,7 +59,8 @@ def test_cp_workspace_to_workspace_non_recursive_success( mock_confirm.return_value.ask.return_value = True # Execute command - cli_executor.exec_command(f"cp {ws1.full_path} {ws2.full_path} --force") + cli_executor.exec_command( + f"cp {ws1.full_path} {ws2.full_path} --force") # Assert mock_print_done.assert_called() @@ -112,13 +115,15 @@ def test_cp_workspace_to_workspace_recursive_success( ws2 = workspace_factory() # Create 2 items in ws1 notebook = item_factory(ItemType.NOTEBOOK, path=ws1.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, path=ws1.full_path) + data_pipeline = item_factory( + ItemType.DATA_PIPELINE, path=ws1.full_path) f1 = folder_factory(path=ws1.full_path) # Subfolder in f1 sjd = item_factory(ItemType.SPARK_JOB_DEFINITION, path=f1.full_path) f2 = folder_factory(path=f1.full_path) # Subfolder in f2 notebook2 = item_factory(ItemType.NOTEBOOK, path=f2.full_path) f3 = folder_factory(path=f2.full_path) # Subfolder in f3 - data_pipeline2 = item_factory(ItemType.DATA_PIPELINE, path=f3.full_path) + data_pipeline2 = item_factory( + ItemType.DATA_PIPELINE, path=f3.full_path) # Reset mock mock_print_done.reset_mock() @@ -217,7 +222,8 @@ def test_cp_workspace_to_folder_success( f2 = folder_factory(path=ws2.full_path) # Create 2 items in ws1 notebook = item_factory(ItemType.NOTEBOOK, path=ws1.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, path=ws1.full_path) + data_pipeline = item_factory( + ItemType.DATA_PIPELINE, path=ws1.full_path) # Reset mock mock_print_done.reset_mock() @@ -235,7 +241,8 @@ def test_cp_workspace_to_folder_success( mock_confirm.return_value.ask.return_value = True # Execute command - cli_executor.exec_command(f"cp {ws1.full_path} {f2.full_path} --force") + cli_executor.exec_command( + f"cp {ws1.full_path} {f2.full_path} --force") copied_notebook = EntityMetadata( notebook.display_name, @@ -288,46 +295,52 @@ def test_cp_workspace_to_folder_success( rm(copied_notebook.full_path) rm(copied_eventhouse.full_path) - def test_cp_item_to_item_success( - self, - workspace_factory, - item_factory, - mock_print_done, - mock_questionary_print, - cli_executor: CLIExecutor, - ): - # Setup - ws1 = workspace_factory() - ws2 = workspace_factory() - notebook = item_factory(ItemType.NOTEBOOK, ws1.full_path) - - # Reset mock - mock_print_done.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - - mock_confirm.return_value.ask.return_value = True - - # Execute command - to_path = cli_path_join(ws2.full_path, notebook.display_name + ".Notebook") - cli_executor.exec_command(f"cp {notebook.full_path} {to_path}") - - # Assert - mock_print_done.assert_called() - - mock_questionary_print.reset_mock() - ls(ws1.full_path) - assert any( - notebook.display_name in call.args[0] - for call in mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - ls(ws2.full_path) - assert any( - notebook.display_name in call.args[0] - for call in mock_questionary_print.mock_calls - ) + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # def test_cp_item_to_item_success( + # self, + # workspace_factory, + # item_factory, + # mock_print_done, + # mock_questionary_print, + # cli_executor: CLIExecutor, + # item_type, + # ): + # # Setup + # ws1 = workspace_factory() + # ws2 = workspace_factory() + # item = item_factory(item_type, ws1.full_path) + + # # Reset mock + # mock_print_done.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + + # mock_confirm.return_value.ask.return_value = True + + # # Execute command + # to_path = cli_path_join(ws2.full_path, item.display_name + f".{item_type}") + # cli_executor.exec_command(f"cp {item.full_path} {to_path}") + + # # Assert + # mock_print_done.assert_called() + + # mock_questionary_print.reset_mock() + # ls(ws1.full_path) + # assert any( + # item.display_name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + # ls(ws2.full_path) + # assert any( + # item.display_name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) def test_cp_workspace_to_workspace_type_mismatch_failure( self, workspace, assert_fabric_cli_error, cli_executor: CLIExecutor @@ -336,7 +349,8 @@ def test_cp_workspace_to_workspace_type_mismatch_failure( to_path = "My workspace.Personal" # Execute command - cli_executor.exec_command(f"cp {workspace.full_path} {to_path} --force") + cli_executor.exec_command( + f"cp {workspace.full_path} {to_path} --force") # # Assert # assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) @@ -374,20 +388,27 @@ def test_cp_item_to_item_type_mismatch_failure( # Assert assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) - def test_cp_virtual_workspace_item_domain_not_supported_failure( - self, - virtual_workspace_item_factory, - assert_fabric_cli_error, - cli_executor: CLIExecutor, - ): - # Setup - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - - # Execute command - cli_executor.exec_command(f"cp {domain.full_path} {domain.full_path} --force") + # @pytest.mark.parametrize("virtual_workspace_type", [ + # VirtualWorkspaceType.DOMAIN, + # VirtualWorkspaceType.CAPACITY, + # VirtualWorkspaceType.GATEWAY, + # ]) + # def test_cp_virtual_workspace_item_not_supported_failure( + # self, + # virtual_workspace_item_factory, + # assert_fabric_cli_error, + # cli_executor: CLIExecutor, + # virtual_workspace_type, + # ): + # # Setup + # virtual_item = virtual_workspace_item_factory(virtual_workspace_type) + + # # Execute command + # cli_executor.exec_command( + # f"cp {virtual_item.full_path} {virtual_item.full_path} --force") - # Assert - assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) + # # Assert + # assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) def test_cp_onelake_to_onelake_success( self, @@ -409,7 +430,8 @@ def test_cp_onelake_to_onelake_success( lakehouse1_onelake_full_path = cli_path_join( lakehouse1.full_path, "Files", file_name ) - lakehouse2_onelake_full_path = cli_path_join(lakehouse2.full_path, "Files") + lakehouse2_onelake_full_path = cli_path_join( + lakehouse2.full_path, "Files") # Reset mock mock_print_done.reset_mock() @@ -419,7 +441,8 @@ def test_cp_onelake_to_onelake_success( mock_confirm.return_value.ask.return_value = True # Upload local file to lakehouse1 - _upload_local_file_to_onelake(file_path, lakehouse1_onelake_full_path) + _upload_local_file_to_onelake( + file_path, lakehouse1_onelake_full_path) # Delete the temporary file os.remove(file_path) @@ -464,8 +487,10 @@ def test_cp_from_onelake_recursive_unsupported( # Setup lakehouse1 = item_factory(ItemType.LAKEHOUSE) lakehouse2 = item_factory(ItemType.LAKEHOUSE) - lakehouse1_onelake_full_path = cli_path_join(lakehouse1.full_path, "Files") - lakehouse2_onelake_full_path = cli_path_join(lakehouse2.full_path, "Files") + lakehouse1_onelake_full_path = cli_path_join( + lakehouse1.full_path, "Files") + lakehouse2_onelake_full_path = cli_path_join( + lakehouse2.full_path, "Files") # Reset mock mock_print_done.reset_mock() @@ -491,7 +516,8 @@ def test_cp_local_to_onelake_success( ): # Setup lakehouse = item_factory(ItemType.LAKEHOUSE) - lakehouse_onelake_full_path = cli_path_join(lakehouse.full_path, "Files") + lakehouse_onelake_full_path = cli_path_join( + lakehouse.full_path, "Files") # Reset mock mock_print_done.reset_mock() @@ -541,6 +567,54 @@ def test_cp_local_to_onelake_success( # Delete the temporary file os.remove(file_path) + # def test_cp_onelake_operations_success( + # self, + # item_factory, + # mock_print_done, + # mock_questionary_print, + # cli_executor: CLIExecutor, + # ): + # # Setup - Create two lakehouse items that support OneLake + # lakehouse1 = item_factory(ItemType.LAKEHOUSE) + # lakehouse2 = item_factory(ItemType.LAKEHOUSE) + + # with tempfile.TemporaryDirectory() as tmp_dir: + # file_name = "test_cp_lakehouse.txt" + # file_path = cli_path_join(tmp_dir, file_name) + # with open(file_path, "wb") as fp: + # fp.write(b"Hello world!\n") + + # lakehouse1_onelake_full_path = cli_path_join( + # lakehouse1.full_path, "Files", file_name + # ) + # lakehouse2_onelake_full_path = cli_path_join( + # lakehouse2.full_path, "Files") + + # # Reset mock + # mock_print_done.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + # mock_confirm.return_value.ask.return_value = True + + # # Upload local file to lakehouse1 + # _upload_local_file_to_onelake( + # file_path, lakehouse1_onelake_full_path) + # # Delete the temporary file + # os.remove(file_path) + + # # Execute command - OneLake to OneLake copy + # cli_executor.exec_command( + # f"cp {lakehouse1_onelake_full_path} {lakehouse2_onelake_full_path}" + # ) + # # Assert + # mock_print_done.assert_called() + # mock_questionary_print.reset_mock() + # ls(lakehouse2_onelake_full_path) + # assert any( + # file_name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + def test_cp_from_local_recursive_unsupported( self, item_factory, @@ -551,7 +625,8 @@ def test_cp_from_local_recursive_unsupported( ): # Setup lakehouse = item_factory(ItemType.LAKEHOUSE) - lakehouse_onelake_full_path = cli_path_join(lakehouse.full_path, "Files") + lakehouse_onelake_full_path = cli_path_join( + lakehouse.full_path, "Files") td = tempfile.TemporaryDirectory() # Reset mock @@ -561,7 +636,8 @@ def test_cp_from_local_recursive_unsupported( mock_confirm.return_value.ask.return_value = True # Execute command - cli_executor.exec_command(f"cp {td.name} {lakehouse_onelake_full_path}") + cli_executor.exec_command( + f"cp {td.name} {lakehouse_onelake_full_path}") # Assert assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) @@ -577,7 +653,8 @@ def test_cp_onelake_to_local_success( ): # Setup lakehouse = item_factory(ItemType.LAKEHOUSE) - lakehouse_onelake_full_path = cli_path_join(lakehouse.full_path, "Files") + lakehouse_onelake_full_path = cli_path_join( + lakehouse.full_path, "Files") with tempfile.TemporaryDirectory() as td: file_name = "test_cp_ol2lo.txt" file_path = cli_path_join(td, file_name) @@ -585,12 +662,14 @@ def test_cp_onelake_to_local_success( fp.write(b"Hello world!\n") # Upload local file to lakehouse - _upload_local_file_to_onelake(file_path, lakehouse_onelake_full_path) + _upload_local_file_to_onelake( + file_path, lakehouse_onelake_full_path) with patch("questionary.confirm") as mock_confirm: mock_confirm.return_value.ask.return_value = True - source_file_path = cli_path_join(lakehouse_onelake_full_path, file_name) + source_file_path = cli_path_join( + lakehouse_onelake_full_path, file_name) # Reset mock mock_print_done.reset_mock() @@ -611,7 +690,8 @@ def test_cp_onelake_to_local_success( mock_print_done.reset_mock() # Execute command - cli_executor.exec_command(f"cp {source_file_path} {dest_file_path_rn}") + cli_executor.exec_command( + f"cp {source_file_path} {dest_file_path_rn}") # Assert mock_print_done.assert_called() @@ -626,7 +706,8 @@ def test_cp_onelake_to_local_parquet_binary_success( """Test copying a parquet file (binary format) from OneLake to local preserves binary content.""" # Setup lakehouse = item_factory(ItemType.LAKEHOUSE) - lakehouse_onelake_full_path = cli_path_join(lakehouse.full_path, "Files") + lakehouse_onelake_full_path = cli_path_join( + lakehouse.full_path, "Files") with tempfile.TemporaryDirectory() as td: # Generate parquet file on the fly instead of using hard-coded test data @@ -634,18 +715,21 @@ def test_cp_onelake_to_local_parquet_binary_success( file_path = cli_path_join(td, file_name) _generate_test_binary_file(file_path) - _upload_local_file_to_onelake(file_path, lakehouse_onelake_full_path) + _upload_local_file_to_onelake( + file_path, lakehouse_onelake_full_path) with patch("questionary.confirm") as mock_confirm: mock_confirm.return_value.ask.return_value = True - source_file_path = cli_path_join(lakehouse_onelake_full_path, file_name) + source_file_path = cli_path_join( + lakehouse_onelake_full_path, file_name) # Reset mock mock_print_done.reset_mock() # Execute command to download the parquet file - downloaded_file_path = cli_path_join(td, "downloaded_" + file_name) + downloaded_file_path = cli_path_join( + td, "downloaded_" + file_name) cli_executor.exec_command( f"cp {source_file_path} {downloaded_file_path}" ) @@ -1033,6 +1117,73 @@ def test_cp_item_existing_name_different_location_with_block_on_path_collision_f ErrorMessages.Cp.item_exists_different_path(), ) + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # def test_cp_folder_with_different_item_types_success( + # self, + # workspace_factory, + # folder_factory, + # item_factory, + # mock_print_done, + # mock_print_warning, + # mock_questionary_print, + # cli_executor: CLIExecutor, + # item_type, + # ): + # # Setup + # ws1 = workspace_factory() + # ws2 = workspace_factory() + # f1 = folder_factory(path=ws1.full_path) + + # # Create an item of the specified type in the folder + # item = item_factory(item_type, path=f1.full_path) + + # # Reset mock + # mock_print_done.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + # mock_confirm.return_value.ask.return_value = True + + # # Execute command + # cli_executor.exec_command( + # f"cp {f1.full_path} {ws2.full_path} --force --recursive" + # ) + + # f2 = EntityMetadata( + # f1.display_name, f1.name, cli_path_join(ws2.full_path, f1.name) + # ) + # copied_item = EntityMetadata( + # item.display_name, + # item.name, + # cli_path_join(f2.full_path, item.name), + # ) + + # # Assert + # mock_print_done.assert_called() + # mock_print_warning.assert_called_once() + # mock_questionary_print.reset_mock() + + # # Verify folder was copied + # ls(ws2.full_path) + # assert any( + # f1.name in call.args[0] for call in mock_questionary_print.mock_calls + # ) + + # # Verify item was copied + # mock_questionary_print.reset_mock() + # ls(f2.full_path) + # assert any( + # item.name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + + # # Cleanup + # rm(copied_item.full_path) + # rm(f2.full_path) + # region Helper Methods def ls(path, long=False, all=False, query=None): @@ -1052,7 +1203,8 @@ def _upload_local_file_to_onelake(local_file_path: str, onelake_path: str): local_file_path, supports_local_path=True ) assert isinstance(from_ctxt, LocalPath) - to_ctxt = handle_context.get_command_context(onelake_path, raise_error=False) + to_ctxt = handle_context.get_command_context( + onelake_path, raise_error=False) assert isinstance(to_ctxt, OneLakeItem) args = argparse.Namespace( diff --git a/tests/test_commands/test_exists.py b/tests/test_commands/test_exists.py index 98747fc5..07ee9f97 100644 --- a/tests/test_commands/test_exists.py +++ b/tests/test_commands/test_exists.py @@ -1,9 +1,12 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. +import pytest + from fabric_cli.core import fab_constant as constant from fabric_cli.core.fab_types import ItemType from tests.test_commands.data.static_test_data import StaticTestData +from tests.test_commands.conftest import custom_parametrize class TestExists: @@ -18,21 +21,22 @@ def test_exists_workspace_exists_success( mock_print_done.assert_called_once() assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] - def test_exists_item_exists_success( - self, item_factory, mock_print_done, cli_executor - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) + # @custom_parametrize + # def test_exists_item_exists_success( + # self, item_factory, mock_print_done, cli_executor, item_type + # ): + # # Setup + # item = item_factory(item_type) - # Reset mock - mock_print_done.reset_mock() + # # Reset mock + # mock_print_done.reset_mock() - # Execute command - cli_executor.exec_command(f"exists {lakehouse.full_path}") + # # Execute command + # cli_executor.exec_command(f"exists {item.full_path}") - # Assert - mock_print_done.assert_called_once() - assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] + # # Assert + # mock_print_done.assert_called_once() + # assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] def test_exists_virtual_workspace_item_capacity_exists_success( self, mock_print_done, cli_executor, test_data: StaticTestData @@ -46,56 +50,85 @@ def test_exists_virtual_workspace_item_capacity_exists_success( mock_print_done.assert_called_once() assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] - def test_exists_onelake_exists_success( - self, item_factory, mock_print_done, cli_executor - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command(f"exists {lakehouse.full_path}/Files") - - # Assert - mock_print_done.assert_called_once() - assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] - - def test_exists_item_doesnt_exist_success( - self, item_factory, mock_print_done, cli_executor - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - path = lakehouse.full_path.replace(".Lakehouse", "random.Lakehouse") - cli_executor.exec_command(f"exists {path}") - - # Assert - mock_print_done.assert_called_once() - assert constant.INFO_EXISTS_FALSE in mock_print_done.call_args[0][0] - - def test_exists_onelake_doesnt_exist_success( - self, item_factory, mock_print_done, cli_executor - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command( - f"exists {lakehouse.full_path}/Files/non_existent_file.txt" - ) - - # Assert - mock_print_done.assert_called_once() - assert constant.INFO_EXISTS_FALSE in mock_print_done.call_args[0][0] + # @pytest.mark.parametrize("item_type,folder_name", [ + # (ItemType.LAKEHOUSE, "Files"), + # (ItemType.LAKEHOUSE, "Tables"), + # (ItemType.WAREHOUSE, "Tables"), + # (ItemType.SPARK_JOB_DEFINITION, "Libs"), + # (ItemType.SPARK_JOB_DEFINITION, "Main"), + # (ItemType.KQL_DATABASE, "Tables"), + # (ItemType.SQL_DATABASE, "Tables"), + # (ItemType.SQL_DATABASE, "Files"), + # (ItemType.MIRRORED_DATABASE, "Tables"), + # (ItemType.MIRRORED_DATABASE, "Files"), + # ]) + # def test_exists_onelake_exists_success( + # self, item_factory, mock_print_done, cli_executor, item_type, folder_name + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command(f"exists {item.full_path}/{folder_name}") + + # # Assert + # mock_print_done.assert_called_once() + # assert constant.INFO_EXISTS_TRUE in mock_print_done.call_args[0][0] + + # @custom_parametrize + # def test_exists_item_doesnt_exist_success( + # self, item_factory, mock_print_done, cli_executor, item_type + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # item_extension = f".{item_type.value}" + # path = item.full_path.replace( + # item_extension, f"random{item_extension}") + # cli_executor.exec_command(f"exists {path}") + + # # Assert + # mock_print_done.assert_called_once() + # assert constant.INFO_EXISTS_FALSE in mock_print_done.call_args[0][0] + + # @pytest.mark.parametrize("item_type,folder_name", [ + # (ItemType.LAKEHOUSE, "Files"), + # (ItemType.LAKEHOUSE, "Tables"), + # (ItemType.WAREHOUSE, "Files"), + # (ItemType.WAREHOUSE, "Tables"), + # (ItemType.SEMANTIC_MODEL, "Tables"), + # (ItemType.SPARK_JOB_DEFINITION, "Libs"), + # (ItemType.SPARK_JOB_DEFINITION, "Main"), + # (ItemType.KQL_DATABASE, "Tables"), + # (ItemType.SQL_DATABASE, "Tables"), + # (ItemType.SQL_DATABASE, "Files"), + # (ItemType.MIRRORED_DATABASE, "Tables"), + # (ItemType.MIRRORED_DATABASE, "Files"), + # ]) + # def test_exists_onelake_doesnt_exist_success( + # self, item_factory, mock_print_done, cli_executor, item_type, folder_name + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"exists {item.full_path}/{folder_name}/non_existent_file.txt" + # ) + + # # Assert + # mock_print_done.assert_called_once() + # assert constant.INFO_EXISTS_FALSE in mock_print_done.call_args[0][0] def test_exists_folder_exists_success( self, folder_factory, mock_print_done, cli_executor @@ -139,7 +172,8 @@ def test_exists_folder_doesnt_exist_success( mock_print_done.reset_mock() # Execute command - cli_executor.exec_command(f"exists {workspace.full_path}/random_folder.Folder") + cli_executor.exec_command( + f"exists {workspace.full_path}/random_folder.Folder") # Assert mock_print_done.assert_called_once() diff --git a/tests/test_commands/test_export.py b/tests/test_commands/test_export.py index dea4e303..ad333092 100644 --- a/tests/test_commands/test_export.py +++ b/tests/test_commands/test_export.py @@ -4,95 +4,122 @@ import platform from unittest.mock import ANY, patch +import pytest + from fabric_cli.core import fab_constant as constant from fabric_cli.core.fab_types import ItemType class TestExport: # region EXPORT - def test_export_item_success( - self, - item_factory, - cli_executor, - mock_print_done, - tmp_path, - mock_print_warning, - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - - # Reset mock - mock_print_done.reset_mock() - mock_print_warning.reset_mock() - - # Execute command - cli_executor.exec_command( - f"export {notebook.full_path} --output {str(tmp_path)} --force" - ) - - # Assert - export_path = tmp_path / f"{notebook.display_name}.Notebook" - assert export_path.is_dir() - files = list(export_path.iterdir()) - assert len(files) == 2 - assert any(file.suffix == ".ipynb" for file in files) - assert any(file.name == ".platform" for file in files) - mock_print_done.assert_called_once() - mock_print_warning.assert_called_once() - - def test_export_item_home_directory_path_success( - self, - item_factory, - cli_executor, - mock_print_done, - tmp_path, - monkeypatch, - mock_print_warning, - ): - # Setup - home_dir = tmp_path / "home" - home_dir.mkdir() - home_dir_env = "USERPROFILE" if platform.system() == "Windows" else "HOME" - monkeypatch.setenv(home_dir_env, str(home_dir)) - notebook = item_factory(ItemType.NOTEBOOK) - output_dir = home_dir / "test_export" - output_dir.mkdir() - - # Reset mock - mock_print_done.reset_mock() - mock_print_warning.reset_mock() - - # Execute command using ~/path notation - cli_executor.exec_command( - f"export {notebook.full_path} --output ~/test_export --force" - ) - - # Assert - export_path = output_dir / f"{notebook.display_name}.Notebook" - assert export_path.is_dir() - files = list(export_path.iterdir()) - assert len(files) == 2 - assert any(file.suffix == ".ipynb" for file in files) - assert any(file.name == ".platform" for file in files) - mock_print_done.assert_called_once() - mock_print_warning.assert_called_once() - - def test_export_item_invalid_output_path_failure( - self, item_factory, cli_executor, mock_print_done, assert_fabric_cli_error - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command( - f"export {notebook.full_path} --output /invalid/path --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_INVALID_PATH) + # @pytest.mark.parametrize("item_type,expected_file_extension", [ + # (ItemType.NOTEBOOK, ".ipynb"), + # (ItemType.SPARK_JOB_DEFINITION, ".json"), + # (ItemType.DATA_PIPELINE, ".json"), + # (ItemType.MIRRORED_DATABASE, ".json") + # ]) + # def test_export_item_success( + # self, + # item_factory, + # cli_executor, + # mock_print_done, + # tmp_path, + # mock_print_warning, + # item_type, + # expected_file_extension, + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + # mock_print_warning.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"export {item.full_path} --output {str(tmp_path)} --force" + # ) + + # # Assert + # export_path = tmp_path / f"{item.display_name}.{item_type.value}" + # assert export_path.is_dir() + # files = list(export_path.iterdir()) + # assert len(files) == 2 + # assert any(file.suffix == expected_file_extension for file in files) + # assert any(file.name == ".platform" for file in files) + # mock_print_done.assert_called_once() + # mock_print_warning.assert_called_once() + + # @pytest.mark.parametrize("item_type,expected_file_extension", [ + # (ItemType.NOTEBOOK, ".ipynb"), + # (ItemType.SPARK_JOB_DEFINITION, ".json"), + # (ItemType.DATA_PIPELINE, ".json"), + # (ItemType.MIRRORED_DATABASE, ".json") + # ]) + # def test_export_item_home_directory_path_success( + # self, + # item_factory, + # cli_executor, + # mock_print_done, + # tmp_path, + # monkeypatch, + # mock_print_warning, + # item_type, + # expected_file_extension, + # ): + # # Setup + # home_dir = tmp_path / "home" + # home_dir.mkdir() + # home_dir_env = "USERPROFILE" if platform.system() == "Windows" else "HOME" + # monkeypatch.setenv(home_dir_env, str(home_dir)) + # item = item_factory(item_type) + # output_dir = home_dir / "test_export" + # output_dir.mkdir() + + # # Reset mock + # mock_print_done.reset_mock() + # mock_print_warning.reset_mock() + + # # Execute command using ~/path notation + # cli_executor.exec_command( + # f"export {item.full_path} --output ~/test_export --force" + # ) + + # # Assert + # export_path = output_dir / f"{item.display_name}.{item_type.value}" + # assert export_path.is_dir() + # files = list(export_path.iterdir()) + # assert len(files) == 2 + # assert any(file.suffix == expected_file_extension for file in files) + # assert any(file.name == ".platform" for file in files) + # mock_print_done.assert_called_once() + # mock_print_warning.assert_called_once() + + # @pytest.mark.parametrize("item_type", [ + # ItemType.NOTEBOOK, + # ItemType.SPARK_JOB_DEFINITION, + # ItemType.DATA_PIPELINE, + # ItemType.MIRRORED_DATABASE, + # ItemType.REPORT, + # ItemType.SEMANTIC_MODEL, + # ItemType.KQL_DATABASE + # ]) + # def test_export_item_invalid_output_path_failure( + # self, item_factory, cli_executor, mock_print_done, assert_fabric_cli_error, item_type + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"export {item.full_path} --output /invalid/path --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_INVALID_PATH) def test_export_workspace_success( self, @@ -141,7 +168,8 @@ def test_export_workspace_success( ) # Assert notebook - notebook_export_path = tmp_path / f"{notebook.display_name}.Notebook" + notebook_export_path = tmp_path / \ + f"{notebook.display_name}.Notebook" assert notebook_export_path.is_dir() files = list(notebook_export_path.iterdir()) assert len(files) == 2 @@ -150,7 +178,8 @@ def test_export_workspace_success( # Assert spark job definition sjd_export_path = ( - tmp_path / f"{spark_job_definition.display_name}.SparkJobDefinition" + tmp_path / + f"{spark_job_definition.display_name}.SparkJobDefinition" ) assert sjd_export_path.is_dir() files = list(sjd_export_path.iterdir()) @@ -183,93 +212,95 @@ def test_export_workspace_with_no_items_supporting_export_failure( # Assert assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) - def test_export_notebook_py_format_success( - self, item_factory, cli_executor, mock_print_done, tmp_path - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command( - f"export {notebook.full_path} --output {str(tmp_path)} --format .py --force" - ) - - # Assert - export_path = tmp_path / f"{notebook.display_name}.Notebook" - assert export_path.is_dir() - files = list(export_path.iterdir()) - assert len(files) == 2 - assert any(file.suffix == ".py" for file in files) - assert any(file.name == ".platform" for file in files) - mock_print_done.assert_called_once() - - def test_export_notebook_default_format_success( - self, item_factory, cli_executor, mock_print_done, tmp_path - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command without format (should use default format from definition_format_mapping) - cli_executor.exec_command( - f"export {notebook.full_path} --output {str(tmp_path)} --force" - ) - - # Assert - should use default format which is "?format=ipynb" resulting in .ipynb file - export_path = tmp_path / f"{notebook.display_name}.Notebook" - assert export_path.is_dir() - files = list(export_path.iterdir()) - assert len(files) == 2 - assert any(file.suffix == ".ipynb" for file in files) # Default format should be .ipynb - assert any(file.name == ".platform" for file in files) - mock_print_done.assert_called_once() - - def test_export_notebook_invalid_format_failure( - self, - item_factory, - cli_executor, - assert_fabric_cli_error, - mock_print_done, - tmp_path, - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command( - f"export {notebook.full_path} --output {str(tmp_path)} --format .txt --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_INVALID_INPUT, "Invalid format. Only the following formats are supported: .py, .ipynb") - - def test_export_report_no_format_support_failure( - self, - item_factory, - cli_executor, - assert_fabric_cli_error, - mock_print_done, - tmp_path, - ): - # Setup - report = item_factory(ItemType.REPORT) - - # Reset mock - mock_print_done.reset_mock() - - # Execute command - Report doesn't have any format support in definition_format_mapping - cli_executor.exec_command( - f"export {report.full_path} --output {str(tmp_path)} --format .txt --force" - ) - - # Assert - should fail with error indicating no formats are supported - assert_fabric_cli_error(constant.ERROR_INVALID_INPUT, "No formats are supported") - \ No newline at end of file + # @pytest.mark.parametrize("item_type,export_format,expected_file_extension", [ + # (ItemType.NOTEBOOK, ".py", ".py"), + # (ItemType.NOTEBOOK, ".ipynb", ".ipynb") + # ]) + # def test_export_item_format_success( + # self, item_factory, cli_executor, mock_print_done, tmp_path, + # item_type, export_format, expected_file_extension + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"export {item.full_path} --output {str(tmp_path)} --format {export_format} --force" + # ) + + # # Assert + # export_path = tmp_path / f"{item.display_name}.{item_type.value}" + # assert export_path.is_dir() + # files = list(export_path.iterdir()) + # assert len(files) == 2 + # assert any(file.suffix == expected_file_extension for file in files) + # assert any(file.name == ".platform" for file in files) + # mock_print_done.assert_called_once() + + # @pytest.mark.parametrize("item_type,expected_file_count", [ + # (ItemType.NOTEBOOK, 2), # Default format for notebook is ipynb + # (ItemType.SPARK_JOB_DEFINITION, 2), + # (ItemType.DATA_PIPELINE, 2), + # (ItemType.MIRRORED_DATABASE, 2), + # (ItemType.REPORT, 4), + # (ItemType.SEMANTIC_MODEL, 3), + # (ItemType.KQL_DATABASE, 3), + # ]) + # def test_export_item_default_format_success( + # self, item_factory, cli_executor, mock_print_done, tmp_path, + # item_type, expected_file_count + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command without format (should use default format from definition_format_mapping) + # cli_executor.exec_command( + # f"export {item.full_path} --output {str(tmp_path)} --force" + # ) + + # # Assert - should use default format for each item type + # export_path = tmp_path / f"{item.display_name}.{item_type.value}" + # assert export_path.is_dir() + # files = list(export_path.iterdir()) + # assert len(files) == expected_file_count + # assert any(file.name == ".platform" for file in files) + # mock_print_done.assert_called_once() + + # @pytest.mark.parametrize("item_type,invalid_format,expected_error_suffix", [ + # (ItemType.NOTEBOOK, ".txt", + # "Only the following formats are supported: .py, .ipynb"), + # (ItemType.SPARK_JOB_DEFINITION, ".txt", "No formats are supported"), + # (ItemType.DATA_PIPELINE, ".txt", "No formats are supported"), + # (ItemType.MIRRORED_DATABASE, ".txt", "No formats are supported") + # ]) + # def test_export_item_invalid_format_failure( + # self, + # item_factory, + # cli_executor, + # assert_fabric_cli_error, + # mock_print_done, + # tmp_path, + # item_type, + # invalid_format, + # expected_error_suffix, + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"export {item.full_path} --output {str(tmp_path)} --format {invalid_format} --force" + # ) + + # # Assert + # assert_fabric_cli_error( + # constant.ERROR_INVALID_INPUT, f"Invalid format. {expected_error_suffix}") diff --git a/tests/test_commands/test_get.py b/tests/test_commands/test_get.py index 16ed083c..09200cfb 100644 --- a/tests/test_commands/test_get.py +++ b/tests/test_commands/test_get.py @@ -5,6 +5,8 @@ import json import time +import pytest + import fabric_cli.commands.fs.fab_fs_get as fab_get import fabric_cli.commands.fs.fab_fs_ln as fab_ln from fabric_cli.core import fab_constant @@ -19,6 +21,7 @@ from tests.test_commands.conftest import assert_fabric_cli_error 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, custom_parametrize class TestGet: @@ -48,7 +51,8 @@ def test_get_workspace_with_query_failure( self, workspace, assert_fabric_cli_error, cli_executor: CLIExecutor ): # Execute command - cli_executor.exec_command(f"get {workspace.full_path} -q '.nonexistent'") + cli_executor.exec_command( + f"get {workspace.full_path} -q '.nonexistent'") # Assert assert_fabric_cli_error( @@ -63,7 +67,8 @@ def test_get_workspace_query_displayName_success( mock_print_warning.reset_mock() # Execute command - cli_executor.exec_command(f"get {workspace.full_path} --query displayName") + cli_executor.exec_command( + f"get {workspace.full_path} --query displayName") # Assert mock_questionary_print.assert_called_once() @@ -73,82 +78,88 @@ def test_get_workspace_query_displayName_success( # endregion # region Item - def test_get_item_lakehouse_query_all_success( - self, item_factory, cli_executor, mock_questionary_print, mock_print_warning - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Reset mock - mock_questionary_print.reset_mock() - mock_print_warning.reset_mock() - - # Execute command - cli_executor.exec_command(f"get {lakehouse.full_path} --query . --force") - - # Assert - mock_questionary_print.assert_called_once() - mock_print_warning.assert_not_called() # lakehouse item is called with get item and not get item with definition - assert lakehouse.display_name in mock_questionary_print.call_args[0][0] - - # Assert lakehouse extended properties are returned - assert "properties" in mock_questionary_print.call_args[0][0] - assert "oneLakeTablesPath" in mock_questionary_print.call_args[0][0] - assert "oneLakeFilesPath" in mock_questionary_print.call_args[0][0] - assert "sqlEndpointProperties" in mock_questionary_print.call_args[0][0] - - def test_get_item_environment_success( - self, item_factory, cli_executor, mock_questionary_print, mock_print_warning - ): - # Setup - environment = item_factory(ItemType.ENVIRONMENT) - - # Reset mock - mock_questionary_print.reset_mock() - mock_print_warning.reset_mock() - - # Execute command - cli_executor.exec_command(f"get {environment.full_path} --query . --force") - - # Assert - mock_questionary_print.assert_called_once() - mock_print_warning.assert_not_called() # enironment item is called with get item and not get item with definition - assert environment.display_name in mock_questionary_print.call_args[0][0] - - # Assert enviroment extended properties are returned - assert "properties" in mock_questionary_print.call_args[0][0] - assert "publishDetails" in mock_questionary_print.call_args[0][0] - - # Assert environment metadata is returned - assert "connections" in mock_questionary_print.call_args[0][0] - assert "published" in mock_questionary_print.call_args[0][0] - assert "staging" in mock_questionary_print.call_args[0][0] - - def test_get_item_mirroreddb_success( - self, item_factory, cli_executor, mock_questionary_print, mock_print_warning - ): - # Setup - mirroreddb = item_factory(ItemType.MIRRORED_DATABASE) - - # Reset mock - mock_questionary_print.reset_mock() - mock_print_warning.reset_mock() - - # Execute command - cli_executor.exec_command(f"get {mirroreddb.full_path} --query . --force") - - # Assert - mock_questionary_print.assert_called_once() - mock_print_warning.assert_called_once() # MIRRORED_DATABASE is called with get item with definition - assert mirroreddb.display_name in mock_questionary_print.call_args[0][0] - - # Assert mirroreddb definition is returned - assert "definition" in mock_questionary_print.call_args[0][0] - - # Assert mirroreddb metadata is returned - assert "connections" in mock_questionary_print.call_args[0][0] - assert "status" in mock_questionary_print.call_args[0][0] - assert "tablesStatus" in mock_questionary_print.call_args[0][0] + # @custom_parametrize + # def test_get_item_query_all_success( + # self, item_factory, cli_executor, mock_questionary_print, mock_print_warning, item_type + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_questionary_print.reset_mock() + # mock_print_warning.reset_mock() + + # # Execute command + # cli_executor.exec_command(f"get {item.full_path} --query . --force") + + # # Assert + # mock_questionary_print.assert_called_once() + # assert item.display_name in mock_questionary_print.call_args[0][0] + + # # Assert basic item properties are returned + # assert "id" in mock_questionary_print.call_args[0][0] + # assert "displayName" in mock_questionary_print.call_args[0][0] + # assert "type" in mock_questionary_print.call_args[0][0] + + # @pytest.mark.parametrize("item_type,expected_properties", [ + # (ItemType.ENVIRONMENT, ["properties", "publishDetails", "connections", "published", "staging"]), + # (ItemType.LAKEHOUSE, ["properties", "oneLakeTablesPath", "oneLakeFilesPath", "sqlEndpointProperties"]), + # (ItemType.WAREHOUSE, ["properties"]), + # (ItemType.KQL_DATABASE, ["properties"]), + # (ItemType.SQL_DATABASE, ["properties"]), + # (ItemType.MIRRORED_DATABASE, ["definition", "connections", "status", "tablesStatus"]), + # ]) + # def test_get_item_with_properties_success( + # self, item_factory, cli_executor, mock_questionary_print, mock_print_warning, item_type, expected_properties + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_questionary_print.reset_mock() + # mock_print_warning.reset_mock() + + # # Execute command + # cli_executor.exec_command(f"get {item.full_path} --query . --force") + + # # Assert + # mock_questionary_print.assert_called_once() + # assert item.display_name in mock_questionary_print.call_args[0][0] + + # # Assert specific properties for this item type + # for prop in expected_properties: + # assert prop in mock_questionary_print.call_args[0][0] + + # @pytest.mark.parametrize("item_type,expects_warning", [ + # (ItemType.MIRRORED_DATABASE, True), # Called with get item with definition + # (ItemType.NOTEBOOK, True), # Items with definition typically trigger warnings + # (ItemType.DATA_PIPELINE, True), # Items with definition typically trigger warnings + # (ItemType.LAKEHOUSE, False), # Called with get item, not get item with definition + # (ItemType.ENVIRONMENT, False), # Called with get item, not get item with definition + # (ItemType.WAREHOUSE, False), # Called with get item, not get item with definition + # ]) + # def test_get_item_warning_behavior_success( + # self, item_factory, cli_executor, mock_questionary_print, mock_print_warning, item_type, expects_warning + # ): + # # Setup + # item = item_factory(item_type) + + # # Reset mock + # mock_questionary_print.reset_mock() + # mock_print_warning.reset_mock() + + # # Execute command + # cli_executor.exec_command(f"get {item.full_path} --query . --force") + + # # Assert + # mock_questionary_print.assert_called_once() + # assert item.display_name in mock_questionary_print.call_args[0][0] + + # # Assert warning behavior based on item type + # if expects_warning: + # mock_print_warning.assert_called_once() # Items with definition trigger warnings + # else: + # mock_print_warning.assert_not_called() # Items without definition don't trigger warnings # endregion @@ -220,26 +231,34 @@ def test_get_virtual_workspace_capacity_query_all_success( for call in mock_questionary_print.mock_calls ) - def test_get_virtual_workspace_domain_success( - self, virtual_workspace_item_factory, cli_executor, mock_questionary_print - ): - # Setup - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) + # @pytest.mark.parametrize("virtual_workspace_type,expected_properties", [ + # (VirtualWorkspaceType.DOMAIN, ["contributorsScope", "domainWorkspaces"]), + # (VirtualWorkspaceType.GATEWAY, ["type", "capacityId", "numberOfMemberGateways"]), + # ]) + # def test_get_virtual_workspace_success( + # self, virtual_workspace_item_factory, cli_executor, mock_questionary_print, + # virtual_workspace_type, expected_properties + # ): + # # Setup + # virtual_workspace = virtual_workspace_item_factory(virtual_workspace_type) - # Reset mock - mock_questionary_print.reset_mock() + # # Reset mock + # mock_questionary_print.reset_mock() - # Execute command - cli_executor.exec_command(f"get {domain.full_path} --query .") + # # Execute command + # cli_executor.exec_command(f"get {virtual_workspace.full_path} --query .") - # Assert - mock_questionary_print.assert_called_once() - assert domain.display_name in mock_questionary_print.call_args[0][0] + # # Assert + # mock_questionary_print.assert_called_once() + # assert virtual_workspace.display_name in mock_questionary_print.call_args[0][0] - # Assert domain metadata is returned - assert "parentDomainId" not in mock_questionary_print.call_args[0][0] - assert "contributorsScope" in mock_questionary_print.call_args[0][0] - assert "domainWorkspaces" in mock_questionary_print.call_args[0][0] + # # Assert specific properties for this virtual workspace type + # for prop in expected_properties: + # assert prop in mock_questionary_print.call_args[0][0] + + # # Domain-specific assertion (parentDomainId should not be present) + # if virtual_workspace_type == VirtualWorkspaceType.DOMAIN: + # assert "parentDomainId" not in mock_questionary_print.call_args[0][0] # endregion @@ -272,7 +291,8 @@ def test_get_virtual_item_managed_private_endpoint( mock_questionary_print.reset_mock() # Execute command - cli_executor.exec_command(f"get {managed_private_endpoint.full_path} --query .") + cli_executor.exec_command( + f"get {managed_private_endpoint.full_path} --query .") # Assert mock_questionary_print.assert_called_once() @@ -301,7 +321,8 @@ def test_get_virtual_item_external_data_share( mock_fab_logger_log_warning.reset_mock() # Execute command - cli_executor.exec_command(f"get {external_data_share.full_path} --query .") + cli_executor.exec_command( + f"get {external_data_share.full_path} --query .") # Assert # Verify call to get was made @@ -364,12 +385,13 @@ def test_metadata_property_query_validation(self): assert is_metadata_property_query("id") is True assert is_metadata_property_query("displayName") is True assert is_metadata_property_query("description") is True - + # Test nested properties - the key enhancement - assert is_metadata_property_query("properties.connectionString") is True + assert is_metadata_property_query( + "properties.connectionString") is True assert is_metadata_property_query("properties.nested.value") is True assert is_metadata_property_query("displayName.localized") is True - + # Test invalid properties assert is_metadata_property_query("someField") is False assert is_metadata_property_query("definition") is False diff --git a/tests/test_commands/test_import.py b/tests/test_commands/test_import.py index 674a6ea4..c86f814e 100644 --- a/tests/test_commands/test_import.py +++ b/tests/test_commands/test_import.py @@ -14,489 +14,105 @@ from fabric_cli.core import fab_handle_context as handle_context from fabric_cli.core.fab_types import ItemType from tests.test_commands.commands_parser import CLIExecutor +from tests.test_commands.conftest import basic_item_parametrize from tests.test_commands.utils import cli_path_join new_name_index = 1 class TestImport: - # Update existing tests - def test_import_update_existing_notebook_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.NOTEBOOK, - cli_executor, - ) - - def test_import_update_existing_sjd_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.SPARK_JOB_DEFINITION, - cli_executor, - ) - - def test_import_update_existing_data_pipeline_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.DATA_PIPELINE, - cli_executor, - ) - - def test_import_update_existing_report_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.REPORT, - cli_executor, - ) - - def test_import_update_existing_semantic_model_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.SEMANTIC_MODEL, - cli_executor, - ) - - def test_import_update_existing_kql_db_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_DATABASE, - cli_executor, - ) - - def test_import_update_existing_kql_qs_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_QUERYSET, - cli_executor, - ) - - def test_import_update_existing_eventhouse_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.EVENTHOUSE, - cli_executor, - ) - - def test_import_update_existing_mirrored_db_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.MIRRORED_DATABASE, - cli_executor, - ) - - def test_import_update_existing_reflex_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.REFLEX, - cli_executor, - ) - - def test_import_update_existing_kql_dashboard_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - cli_executor: CLIExecutor, - ): - _import_update_existing_item_success( - item_factory, - mock_print_done, - tmp_path, - mock_print_warning, - spy_update_item_definition, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_DASHBOARD, - cli_executor, - ) - - # Create new tests - def test_import_home_directory_path_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - monkeypatch, - ): - # Setup mock home directory - home_dir = tmp_path / "home" - home_dir.mkdir() - home_dir_env = "USERPROFILE" if platform.system() == "Windows" else "HOME" - monkeypatch.setenv(home_dir_env, str(home_dir)) - - # Create test directory under mock home - input_dir = home_dir / "test_import" - input_dir.mkdir() - - _import_create_new_item_success( - item_factory, - mock_print_done, - f"~/test_import", - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.NOTEBOOK, - cli_executor, - ) - - def test_import_create_new_sqldb_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.SQL_DATABASE, - cli_executor, - ) - - def test_import_create_new_notebook_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.NOTEBOOK, - cli_executor, - ) - - def test_import_create_new_sjd_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.SPARK_JOB_DEFINITION, - cli_executor, - ) - - def test_import_create_new_data_pipeline_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.DATA_PIPELINE, - cli_executor, - ) - - def test_import_create_new_report_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.REPORT, - cli_executor, - ) - - def test_import_create_new_semantic_model_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.SEMANTIC_MODEL, - cli_executor, - ) - - def test_import_create_new_kql_db_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_DATABASE, - cli_executor, - ) - - def test_import_create_new_kql_qs_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_QUERYSET, - cli_executor, - ) - - def test_import_create_new_eventhouse_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.EVENTHOUSE, - cli_executor, - ) + # region Parametrized Tests + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.ENVIRONMENT, ItemType.EVENTSTREAM, + # ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # def test_import_update_existing_item_success( + # self, + # item_type, + # item_factory, + # mock_print_done, + # tmp_path, + # mock_print_warning, + # spy_update_item_definition, + # mock_print_grey, + # upsert_item_to_cache, + # cli_executor: CLIExecutor, + # ): + # _import_update_existing_item_success( + # item_factory, + # mock_print_done, + # tmp_path, + # mock_print_warning, + # spy_update_item_definition, + # mock_print_grey, + # upsert_item_to_cache, + # item_type, + # cli_executor, + # ) + + # @pytest.mark.parametrize("item_type", [ + # ItemType.NOTEBOOK, ItemType.SPARK_JOB_DEFINITION, ItemType.DATA_PIPELINE, + # ItemType.REPORT, ItemType.SEMANTIC_MODEL, ItemType.KQL_DATABASE, + # ItemType.KQL_QUERYSET, ItemType.EVENTHOUSE, ItemType.MIRRORED_DATABASE, + # ItemType.REFLEX, ItemType.KQL_DASHBOARD, ItemType.SQL_DATABASE, + # ]) + # def test_import_create_new_item_success( + # self, + # item_type, + # item_factory, + # mock_print_done, + # tmp_path, + # spy_create_item, + # mock_print_grey, + # upsert_item_to_cache, + # cli_executor, + # ): + # _import_create_new_item_success( + # item_factory, + # mock_print_done, + # tmp_path, + # spy_create_item, + # mock_print_grey, + # upsert_item_to_cache, + # item_type, + # cli_executor, + # ) + + # @pytest.mark.parametrize("item_type", [ + # ItemType.DASHBOARD, ItemType.DATAMART, ItemType.LAKEHOUSE, + # ItemType.MIRRORED_WAREHOUSE, ItemType.ML_EXPERIMENT, ItemType.ML_MODEL, + # ItemType.PAGINATED_REPORT, ItemType.SQL_ENDPOINT, ItemType.WAREHOUSE, + # ]) + # def test_import_create_new_item_fail( + # self, + # item_type, + # workspace, + # mock_print_done, + # tmp_path, + # spy_create_item, + # mock_print_grey, + # upsert_item_to_cache, + # cli_executor, + # assert_fabric_cli_error, + # ): + # _import_create_new_item_fail( + # workspace, + # mock_print_done, + # tmp_path, + # spy_create_item, + # mock_print_grey, + # upsert_item_to_cache, + # item_type, + # cli_executor, + # assert_fabric_cli_error, + # ) + + # endregion - def test_import_create_new_mirrored_db_item_success( + # Create new tests + def test_import_home_directory_path_success( self, item_factory, mock_print_done, @@ -505,266 +121,27 @@ def test_import_create_new_mirrored_db_item_success( mock_print_grey, upsert_item_to_cache, cli_executor, + monkeypatch, ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.MIRRORED_DATABASE, - cli_executor, - ) + # Setup mock home directory + home_dir = tmp_path / "home" + home_dir.mkdir() + home_dir_env = "USERPROFILE" if platform.system() == "Windows" else "HOME" + monkeypatch.setenv(home_dir_env, str(home_dir)) - def test_import_create_new_reflex_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): - _import_create_new_item_success( - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.REFLEX, - cli_executor, - ) + # Create test directory under mock home + input_dir = home_dir / "test_import" + input_dir.mkdir() - def test_import_create_new_kql_dashboard_item_success( - self, - item_factory, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - ): _import_create_new_item_success( item_factory, mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.KQL_DASHBOARD, - cli_executor, - ) - - # Non Supported items tests - def test_import_create_new_dashboard_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.DASHBOARD, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_datamart_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.DATAMART, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_lakehouse_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.LAKEHOUSE, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_mirrored_warehouse_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.MIRRORED_WAREHOUSE, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_ml_experiment_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.ML_EXPERIMENT, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_ml_model_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.ML_MODEL, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_paginated_report_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.PAGINATED_REPORT, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_sql_endpoint_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - ItemType.SQL_ENDPOINT, - cli_executor, - assert_fabric_cli_error, - ) - - def test_import_create_new_warehouse_item_fail( - self, - workspace, - mock_print_done, - tmp_path, - spy_create_item, - mock_print_grey, - upsert_item_to_cache, - cli_executor, - assert_fabric_cli_error, - ): - _import_create_new_item_fail( - workspace, - mock_print_done, - tmp_path, + f"~/test_import", spy_create_item, mock_print_grey, upsert_item_to_cache, - ItemType.WAREHOUSE, + ItemType.NOTEBOOK, cli_executor, - assert_fabric_cli_error, ) # Test with lakehouse path @@ -904,13 +281,15 @@ def _import_update_existing_item_success( f"import {item.full_path} --input {str(tmp_path)}/{item.name} --force" ) - # Assert - mock_print_warning.assert_called_once() - mock_print_grey.assert_called_once() - assert "Importing (update) " in mock_print_grey.call_args[0][0] - spy_update_item_definition.assert_called_once() - mock_print_done.assert_called_once() - upsert_item_to_cache.assert_called_once() + if item_type == ItemType.ENVIRONMENT: + mock_print_done.assert_called_once() + else: + mock_print_warning.assert_called_once() + mock_print_grey.assert_called_once() + assert "Importing (update) " in mock_print_grey.call_args[0][0] + spy_update_item_definition.assert_called_once() + mock_print_done.assert_called_once() + upsert_item_to_cache.assert_called_once() def _import_create_new_item_fail( @@ -929,7 +308,8 @@ def _import_create_new_item_fail( new_item_path = cli_path_join(workspace.full_path, item_name) # Execute command - cli_executor.exec_command(f"import {new_item_path} --input {str(tmp_path)} --force") + cli_executor.exec_command( + f"import {new_item_path} --input {str(tmp_path)} --force") # Assert assert_fabric_cli_error(fab_constant.ERROR_UNSUPPORTED_COMMAND) diff --git a/tests/test_commands/test_ls.py b/tests/test_commands/test_ls.py index dfef0bc5..448df787 100644 --- a/tests/test_commands/test_ls.py +++ b/tests/test_commands/test_ls.py @@ -20,10 +20,10 @@ 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, custom_parametrize class TestLS: - _workspace_long_columns = [ "name", "id", @@ -50,7 +50,8 @@ class TestLS: "tags", ] - _domain_long_columns = ["id", "contributorsScope", "description", "parentDomainId"] + _domain_long_columns = ["id", "contributorsScope", + "description", "parentDomainId"] _connection_long_columns = [ "name", @@ -79,7 +80,8 @@ class TestLS: "dynamicExecutorAllocation", ] - _managed_identities_long_columns = ["name", "servicePrincipalId", "applicationId"] + _managed_identities_long_columns = [ + "name", "servicePrincipalId", "applicationId"] _managed_private_endpoints_long_columns = [ "name", @@ -98,187 +100,194 @@ class TestLS: ] # region ITEM - @pytest.mark.parametrize("command", ["ls", "dir"]) - def test_ls_workspace_items_success( - self, - workspace, - item_factory, - mock_questionary_print, - command, - cli_executor: CLIExecutor, - ): - # Setup 3 items - notebook = item_factory(ItemType.NOTEBOOK) - lakehouse = item_factory(ItemType.LAKEHOUSE) - data_pipeline = item_factory(ItemType.DATA_PIPELINE) - - # Test 1: without args - cli_executor.exec_command(f"{command} {workspace.full_path}") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - self._virtual_workspace_items, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 2: with long - cli_executor.exec_command(f"{command} {workspace.full_path} --long") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, - True, - mock_questionary_print.mock_calls, - require_all_in_same_args=True, - ) - _assert_strings_in_mock_calls( - self._virtual_workspace_items, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 3: with all - cli_executor.exec_command(f"{command} {workspace.full_path} --all") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - self._virtual_workspace_items, True, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 4: with all and long - cli_executor.exec_command(f"{command} {workspace.full_path} --long --all") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, - True, - mock_questionary_print.mock_calls, - require_all_in_same_args=True, - ) - _assert_strings_in_mock_calls( - self._virtual_workspace_items, True, mock_questionary_print.mock_calls - ) - - def test_ls_query_filter_success( - self, - workspace, - item_factory, - mock_questionary_print, - assert_fabric_cli_error, - cli_executor: CLIExecutor, - ): - # Setup items with different names and types - notebook1 = item_factory(ItemType.NOTEBOOK) - notebook2 = item_factory(ItemType.NOTEBOOK) - notebook3 = item_factory(ItemType.NOTEBOOK) - - # Test 1: Basic JMESPath syntax - cli_executor.exec_command(f'ls {workspace.full_path} -q [].name') - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook1.display_name, notebook2.display_name, notebook3.display_name], - True, - mock_questionary_print.mock_calls, - ) - - mock_questionary_print.reset_mock() - - # Test 2: JMESPath object syntax - cli_executor.exec_command( - f"ls {workspace.full_path} -l -q '[].{{displayName: name, itemID: id}}'" - ) - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook1.display_name, notebook2.display_name, notebook3.display_name], - True, - mock_questionary_print.mock_calls, - ) - # Verify renamed fields - _assert_strings_in_mock_calls( - ["displayName", "itemID"], - True, - mock_questionary_print.mock_calls, - 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]') - _assert_strings_in_mock_calls( - [f"['{notebook1.name}']", f"['{notebook2.name}']", f"['{notebook3.name}']"], - True, - mock_questionary_print.mock_calls, - ) - - mock_questionary_print.reset_mock() - - # Test 4: JMESPath object syntax without -l should not have id in the result - cli_executor.exec_command(f'ls {workspace.full_path} -q "[].{{displayName: name, itemId: id}}"') - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [f'{notebook1.name} None', f'{notebook2.name} None', f'{notebook3.name} None'], - True, - mock_questionary_print.mock_calls, - ) - - mock_questionary_print.reset_mock() - - # Test 5: JMESPath query filters specific value - cli_executor.exec_command( - f"ls {workspace.full_path} -q \"[?name=='{notebook1.name}'].name\"" - ) - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [f'{notebook1.name}'], - True, - mock_questionary_print.mock_calls, - ) - - _assert_strings_in_mock_calls( - [f'{notebook2.name}', f'{notebook3.name}'], - False, - mock_questionary_print.mock_calls, - ) - - mock_questionary_print.reset_mock() - # Test 6: Invalid query format - cli_executor.exec_command(f'ls {workspace.full_path} -q "name type"') - assert_fabric_cli_error(fab_constant.ERROR_INVALID_INPUT, ErrorMessages.Common.invalid_jmespath_query()) + # @custom_parametrize + # @pytest.mark.parametrize("command", ["ls", "dir"]) + # def test_ls_workspace_items_success( + # self, + # workspace, + # item_factory, + # mock_questionary_print, + # command, + # item_type, + # cli_executor: CLIExecutor, + # ): + # # Setup item of parametrized type + # item = item_factory(item_type) + + # # Test 1: without args + # cli_executor.exec_command(f"{command} {workspace.full_path}") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # self._virtual_workspace_items, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 2: with long + # cli_executor.exec_command(f"{command} {workspace.full_path} --long") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, + # True, + # mock_questionary_print.mock_calls, + # require_all_in_same_args=True, + # ) + # _assert_strings_in_mock_calls( + # self._virtual_workspace_items, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 3: with all + # cli_executor.exec_command(f"{command} {workspace.full_path} --all") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # self._virtual_workspace_items, True, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 4: with all and long + # cli_executor.exec_command( + # f"{command} {workspace.full_path} --long --all") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, + # True, + # mock_questionary_print.mock_calls, + # require_all_in_same_args=True, + # ) + # _assert_strings_in_mock_calls( + # self._virtual_workspace_items, True, mock_questionary_print.mock_calls + # ) + + # @basic_item_parametrize + # def test_ls_query_filter_success( + # self, + # workspace, + # item_factory, + # mock_questionary_print, + # assert_fabric_cli_error, + # item_type, + # cli_executor: CLIExecutor, + # ): + # # Setup items with different names and same parametrized type + # item1 = item_factory(item_type) + # item2 = item_factory(item_type) + # item3 = item_factory(item_type) + + # # Test 1: Basic JMESPath syntax + # 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], + # True, + # mock_questionary_print.mock_calls, + # ) + + # mock_questionary_print.reset_mock() + + # # Test 2: JMESPath object syntax + # cli_executor.exec_command( + # f"ls {workspace.full_path} -l -q '[].{{displayName: name, itemID: id}}'" + # ) + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item1.display_name, item2.display_name, item3.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # # Verify renamed fields + # _assert_strings_in_mock_calls( + # ["displayName", "itemID"], + # True, + # mock_questionary_print.mock_calls, + # 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]') + # _assert_strings_in_mock_calls( + # [f"['{item1.name}']", f"['{item2.name}']", f"['{item3.name}']"], + # True, + # mock_questionary_print.mock_calls, + # ) + + # mock_questionary_print.reset_mock() + + # # Test 4: JMESPath object syntax without -l should not have id in the result + # cli_executor.exec_command( + # f'ls {workspace.full_path} -q "[].{{displayName: name, itemId: id}}"') + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # ["displayName", "itemId"], + # True, + # mock_questionary_print.mock_calls, + # require_all_in_same_args=True + # ) + + # mock_questionary_print.reset_mock() + + # # Test 5: JMESPath query filters specific value + # cli_executor.exec_command( + # f"ls {workspace.full_path} -q \"[?name=='{item1.name}'].name\"" + # ) + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [f'{item1.name}'], + # True, + # mock_questionary_print.mock_calls, + # ) + + # _assert_strings_in_mock_calls( + # [f'{item2.name}', f'{item3.name}'], + # False, + # mock_questionary_print.mock_calls, + # ) + + # mock_questionary_print.reset_mock() + + # # Test 6: Invalid query format + # cli_executor.exec_command(f'ls {workspace.full_path} -q "name type"') + # assert_fabric_cli_error( + # fab_constant.ERROR_INVALID_INPUT, ErrorMessages.Common.invalid_jmespath_query()) def test_ls_item_show_hidden_from_config_success( self, @@ -303,7 +312,8 @@ def test_ls_item_show_hidden_from_config_success( # Check hidden_data is present despite no --all flag assert actual_json["result"]["hidden_data"] is not None - expected_hidden_data_keys = [vws.value for vws in VirtualItemContainerType] + expected_hidden_data_keys = [ + vws.value for vws in VirtualItemContainerType] for key in expected_hidden_data_keys: assert any(key in k for k in actual_json["result"]["hidden_data"]) @@ -340,7 +350,8 @@ def test_ls_item_json_format_success( actual_json = json.loads(mock_questionary_print.mock_calls[0].args[0]) # check --all flag assert actual_json["result"]["hidden_data"] is not None - expected_hidden_data_keys = [vws.value for vws in VirtualItemContainerType] + expected_hidden_data_keys = [ + vws.value for vws in VirtualItemContainerType] for key in expected_hidden_data_keys: assert any(key in k for k in actual_json["result"]["hidden_data"]) @@ -547,38 +558,44 @@ def test_ls_workspaces_json_format_success( # endregion # region ITEM FOLDERS - def test_ls_item_folders_success( - self, item_factory, mock_questionary_print, cli_executor: CLIExecutor - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - expected_output = ["Files", "Tables", "TableMaintenance"] - - # Test 1: without args - cli_executor.exec_command(f"ls {lakehouse.full_path}") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - expected_output, True, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - self._item_folders_long_columns, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 2: with long - cli_executor.exec_command(f"ls {lakehouse.full_path} --long") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - expected_output, True, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - self._item_folders_long_columns, True, mock_questionary_print.mock_calls - ) + # @pytest.mark.parametrize("item_type,expected_folders", [ + # (ItemType.LAKEHOUSE, ["Files", "Tables", "TableMaintenance"]), + # (ItemType.WAREHOUSE, ["Files", "Tables"]), + # (ItemType.SPARK_JOB_DEFINITION, ["Libs", "Main", "Snapshots"]), + # (ItemType.KQL_DATABASE, ["Tables", "Shortcut"]), + # (ItemType.SQL_DATABASE, ["Tables", "Files", "Code"]), + # ]) + # def test_ls_item_folders_success( + # self, item_factory, mock_questionary_print, item_type, expected_folders, cli_executor: CLIExecutor + # ): + # # Setup + # item = item_factory(item_type) + + # # Test 1: without args + # cli_executor.exec_command(f"ls {item.full_path}") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # expected_folders, True, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # self._item_folders_long_columns, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 2: with long + # cli_executor.exec_command(f"ls {item.full_path} --long") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # expected_folders, True, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # self._item_folders_long_columns, True, mock_questionary_print.mock_calls + # ) # endregion @@ -690,11 +707,12 @@ def test_ls_managed_private_endpoints_success( VirtualItemContainerType.MANAGED_PRIVATE_ENDPOINT ) managed_private_endpoints_path = cli_path_join( - workspace.full_path, str(VirtualItemContainerType.MANAGED_PRIVATE_ENDPOINT) + workspace.full_path, str( + VirtualItemContainerType.MANAGED_PRIVATE_ENDPOINT) ) mock_questionary_print.reset_mock() - + # Test 1: without args cli_executor.exec_command(f"ls {managed_private_endpoints_path}") @@ -714,7 +732,8 @@ def test_ls_managed_private_endpoints_success( mock_questionary_print.reset_mock() # Test 2: with long - cli_executor.exec_command(f"ls {managed_private_endpoints_path} --long") + cli_executor.exec_command( + f"ls {managed_private_endpoints_path} --long") # Assert mock_questionary_print.assert_called() _assert_strings_in_mock_calls( @@ -746,7 +765,8 @@ def test_ls_external_data_shares_success( VirtualItemContainerType.EXTERNAL_DATA_SHARE ) external_data_shares_path = cli_path_join( - workspace.full_path, str(VirtualItemContainerType.EXTERNAL_DATA_SHARE) + workspace.full_path, str( + VirtualItemContainerType.EXTERNAL_DATA_SHARE) ) # Test 1: without args cli_executor.exec_command(f"ls {external_data_shares_path}") @@ -794,7 +814,8 @@ def test_ls_external_data_shares_use_cache_success( VirtualItemContainerType.EXTERNAL_DATA_SHARE ) external_data_shares_path = cli_path_join( - workspace.full_path, str(VirtualItemContainerType.EXTERNAL_DATA_SHARE) + workspace.full_path, str( + VirtualItemContainerType.EXTERNAL_DATA_SHARE) ) mock_fab_set_state_config(fab_constant.FAB_CACHE_ENABLED, "true") @@ -828,7 +849,8 @@ def test_ls_capacity_success( test_data: StaticTestData, ): # Setup - capacity = virtual_workspace_item_factory(VirtualWorkspaceType.CAPACITY) + capacity = virtual_workspace_item_factory( + VirtualWorkspaceType.CAPACITY) # Test 1: without args cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.CAPACITY)}") @@ -845,7 +867,8 @@ def test_ls_capacity_success( mock_questionary_print.reset_mock() # Test 2: with long - cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.CAPACITY)} --long") + cli_executor.exec_command( + f"ls {str(VirtualWorkspaceType.CAPACITY)} --long") # Assert mock_questionary_print.assert_called() @@ -893,7 +916,8 @@ def test_ls_domain_success( mock_questionary_print.reset_mock() # Test 2: with long - cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.DOMAIN)} --long") + cli_executor.exec_command( + f"ls {str(VirtualWorkspaceType.DOMAIN)} --long") # Assert mock_questionary_print.assert_called() @@ -920,7 +944,8 @@ def test_ls_connection_success( mock_questionary_print, ): # Setup - connection = virtual_workspace_item_factory(VirtualWorkspaceType.CONNECTION) + connection = virtual_workspace_item_factory( + VirtualWorkspaceType.CONNECTION) # Test 1: without args cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.CONNECTION)}") @@ -936,7 +961,8 @@ def test_ls_connection_success( mock_questionary_print.reset_mock() # Test 2: with long - cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.CONNECTION)} --long") + cli_executor.exec_command( + f"ls {str(VirtualWorkspaceType.CONNECTION)} --long") # Assert mock_questionary_print.assert_called() @@ -984,7 +1010,8 @@ def test_ls_gateways_success( mock_questionary_print.reset_mock() # Test 2: with long - cli_executor.exec_command(f"ls {str(VirtualWorkspaceType.GATEWAY)} --long") + cli_executor.exec_command( + f"ls {str(VirtualWorkspaceType.GATEWAY)} --long") # Assert mock_questionary_print.assert_called() @@ -1088,157 +1115,177 @@ def test_ls_subfolder_success( require_all_in_same_args=True, ) - def test_ls_folder_content_success( - self, - workspace, - folder_factory, - item_factory, - mock_questionary_print, - cli_executor: CLIExecutor, - ): - # Setup - folder = folder_factory() - - # Setup 3 items - notebook = item_factory(ItemType.NOTEBOOK, path=folder.full_path) - lakehouse = item_factory(ItemType.LAKEHOUSE, path=folder.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, path=folder.full_path) - - # Test 1: without args - cli_executor.exec_command(f"ls {folder.full_path}") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 2: with long - cli_executor.exec_command(f"ls {folder.full_path} --long") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, - True, - mock_questionary_print.mock_calls, - require_all_in_same_args=True, - ) - - mock_questionary_print.reset_mock() - - # Test 3: with all - cli_executor.exec_command(f"ls {folder.full_path} --all") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 4: with all and long - cli_executor.exec_command(f"ls {folder.full_path} --long --all") - - # Assert - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, - True, - mock_questionary_print.mock_calls, - require_all_in_same_args=True, - ) - - def test_ls_workspace_items_no_list_folders_support_success( - self, - workspace, - folder_factory, - item_factory, - mock_questionary_print, - cli_executor: CLIExecutor, - ): - # Setup - folder = folder_factory() - - # Setup 3 items - notebook = item_factory(ItemType.NOTEBOOK) - lakehouse = item_factory(ItemType.LAKEHOUSE, path=folder.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, path=folder.full_path) - - # Test 1: workspace ls - cli_executor.exec_command(f"ls {workspace.full_path}") - - # Assert that only the notebook and folder are listed - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, folder.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Test 2: Folder ls - cli_executor.exec_command(f"ls {folder.full_path}") - - # Assert that only the lakehouse and data pipeline are listed - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - - # Disable folder support - state_config.set_config(fab_constant.FAB_FOLDER_LISTING_ENABLED, "false") - - # Test 3: workspace ls - cli_executor.exec_command(f"ls {workspace.full_path}") - - # Assert that only the items are listed - mock_questionary_print.assert_called() - _assert_strings_in_mock_calls( - [notebook.display_name, lakehouse.display_name, data_pipeline.display_name], - True, - mock_questionary_print.mock_calls, - ) - _assert_strings_in_mock_calls( - self._workspace_items_long_columns, False, mock_questionary_print.mock_calls - ) - - # Enable folder support for cleanup - state_config.set_config(fab_constant.FAB_FOLDER_LISTING_ENABLED, "true") + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, + # ItemType.ENVIRONMENT, ItemType.EVENTHOUSE, ItemType.EVENTSTREAM, + # ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.LAKEHOUSE, ItemType.ML_EXPERIMENT, ItemType.ML_MODEL, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.GRAPHQLAPI, + # ItemType.SQL_DATABASE, ItemType.SEMANTIC_MODEL, + # ItemType.SPARK_JOB_DEFINITION, ItemType.WAREHOUSE, ItemType.COPYJOB, + # ]) + # def test_ls_folder_content_success( + # self, + # folder_factory, + # item_factory, + # mock_questionary_print, + # item_type, + # cli_executor: CLIExecutor, + # ): + # # Setup + # folder = folder_factory() + + # # Setup item of parametrized type + # item = item_factory(item_type, path=folder.full_path) + + # # Test 1: without args + # cli_executor.exec_command(f"ls {folder.full_path}") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 2: with long + # cli_executor.exec_command(f"ls {folder.full_path} --long") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, + # True, + # mock_questionary_print.mock_calls, + # require_all_in_same_args=True, + # ) + + # mock_questionary_print.reset_mock() + + # # Test 3: with all + # cli_executor.exec_command(f"ls {folder.full_path} --all") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 4: with all and long + # cli_executor.exec_command(f"ls {folder.full_path} --long --all") + + # # Assert + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, + # True, + # mock_questionary_print.mock_calls, + # require_all_in_same_args=True, + # ) + + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, + # ItemType.ENVIRONMENT, ItemType.EVENTHOUSE, ItemType.EVENTSTREAM, + # ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.LAKEHOUSE, ItemType.ML_EXPERIMENT, ItemType.ML_MODEL, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.GRAPHQLAPI, + # ItemType.SQL_DATABASE, ItemType.SEMANTIC_MODEL, + # ItemType.SPARK_JOB_DEFINITION, ItemType.WAREHOUSE, ItemType.COPYJOB, + # ]) + # def test_ls_workspace_items_no_list_folders_support_success( + # self, + # workspace, + # folder_factory, + # item_factory, + # mock_questionary_print, + # item_type, + # cli_executor: CLIExecutor, + # ): + # # Setup + # folder = folder_factory() + + # # Setup 2 items of the same parametrized type - one in workspace, one in folder + # workspace_item = item_factory(item_type) + # folder_item = item_factory(item_type, path=folder.full_path) + + # # Test 1: workspace ls + # cli_executor.exec_command(f"ls {workspace.full_path}") + + # # Assert that only the workspace item and folder are listed + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [workspace_item.display_name, folder.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Test 2: Folder ls + # cli_executor.exec_command(f"ls {folder.full_path}") + + # # Assert that only the folder item is listed + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [folder_item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + + # # Disable folder support + # state_config.set_config( + # fab_constant.FAB_FOLDER_LISTING_ENABLED, "false") + + # # Test 3: workspace ls + # cli_executor.exec_command(f"ls {workspace.full_path}") + + # # Assert that both items are listed (folder and its contents flattened) + # mock_questionary_print.assert_called() + # _assert_strings_in_mock_calls( + # [workspace_item.display_name, folder_item.display_name], + # True, + # mock_questionary_print.mock_calls, + # ) + # _assert_strings_in_mock_calls( + # self._workspace_items_long_columns, False, mock_questionary_print.mock_calls + # ) + + # # Enable folder support for cleanup + # state_config.set_config( + # fab_constant.FAB_FOLDER_LISTING_ENABLED, "true") # endregion diff --git a/tests/test_commands/test_mkdir.py b/tests/test_commands/test_mkdir.py index e7f1de8e..203050bc 100644 --- a/tests/test_commands/test_mkdir.py +++ b/tests/test_commands/test_mkdir.py @@ -29,7 +29,7 @@ VirtualWorkspaceType, ) from fabric_cli.errors import ErrorMessages -from tests.test_commands.conftest import mock_print_done +from tests.test_commands.conftest import custom_parametrize from tests.test_commands.data.models import EntityMetadata from tests.test_commands.data.static_test_data import StaticTestData from tests.test_commands.processors import generate_random_string @@ -38,49 +38,87 @@ class TestMkdir: # region ITEM - def test_mkdir_item_name_already_exists_failure( - self, item_factory, cli_executor, assert_fabric_cli_error - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - - # Execute command - cli_executor.exec_command(f"mkdir {lakehouse.full_path}") - # Assert - assert_fabric_cli_error(constant.ERROR_ALREADY_EXISTS) - - def test_mkdir_unsupported_item_failure( - self, - workspace_factory, - cli_executor, - assert_fabric_cli_error, - vcr_instance, - cassette_name, - ): - workspace = workspace_factory() - - # Create paginatedReport - paginatedReport_display_name = generate_random_string( - vcr_instance, cassette_name - ) - paginatedReport_name = ( - f"{paginatedReport_display_name}.{ItemType.PAGINATED_REPORT}" - ) - paginatedReport_full_path = cli_path_join( - workspace.full_path, paginatedReport_name - ) - paginatedReport = EntityMetadata( - paginatedReport_display_name, - paginatedReport_name, - paginatedReport_full_path, - ) - - # Execute command - cli_executor.exec_command(f"mkdir {paginatedReport.full_path}") - - # Assert - assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) + # @custom_parametrize + # def test_mkdir_item_name_already_exists_failure( + # self, item_type, item_factory, cli_executor, assert_fabric_cli_error + # ): + # # Setup + # created_factory = item_factory(item_type) + + # # Execute command + # cli_executor.exec_command(f"mkdir {created_factory.full_path}") + + # # Assert + # assert_fabric_cli_error(constant.ERROR_ALREADY_EXISTS) + + # @custom_parametrize + # def test_mkdir_item_success( + # self, + # item_type, + # workspace, + # cli_executor, + # mock_print_done, + # mock_questionary_print, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item_display_name = generate_random_string(vcr_instance, cassette_name) + # item_full_path = cli_path_join( + # workspace.full_path, f"{item_display_name}.{item_type}" + # ) + + # # Execute command + # cli_executor.exec_command(f"mkdir {item_full_path}") + + # # Assert + # mock_print_done.assert_called_once() + # assert item_display_name in mock_print_done.call_args[0][0] + # mock_questionary_print.reset_mock() + # get(item_full_path, query=".") + # mock_questionary_print.assert_called_once() + # assert item_display_name in mock_questionary_print.call_args[0][0] + + # # Cleanup + # rm(item_full_path) + + # @pytest.mark.parametrize("unsupported_item_type", [ + # ItemType.DASHBOARD, + # ItemType.DATAMART, + # ItemType.MIRRORED_WAREHOUSE, + # ItemType.PAGINATED_REPORT, + # ItemType.SQL_ENDPOINT, + # ]) + # def test_mkdir_unsupported_item_failure( + # self, + # unsupported_item_type, + # workspace_factory, + # cli_executor, + # assert_fabric_cli_error, + # vcr_instance, + # cassette_name, + # ): + # workspace = workspace_factory() + + # # Create unsupported item + # item_display_name = generate_random_string( + # vcr_instance, cassette_name + # ) + # item_name = f"{item_display_name}.{unsupported_item_type}" + # item_full_path = cli_path_join(workspace.full_path, item_name) + + # unsupported_item = EntityMetadata( + # item_display_name, + # item_name, + # item_full_path, + # ) + + # # Execute command + # cli_executor.exec_command(f"mkdir {unsupported_item.full_path}") + + # # Assert + # assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) def test_mkdir_lakehouse_with_creation_payload_success( self, @@ -92,13 +130,15 @@ def test_mkdir_lakehouse_with_creation_payload_success( cassette_name, upsert_item_to_cache, ): - lakehouse_display_name = generate_random_string(vcr_instance, cassette_name) + lakehouse_display_name = generate_random_string( + vcr_instance, cassette_name) lakehouse_full_path = cli_path_join( workspace.full_path, f"{lakehouse_display_name}.{ItemType.LAKEHOUSE}" ) # Execute command - cli_executor.exec_command(f"mkdir {lakehouse_full_path} -P enableSchemas=true") + cli_executor.exec_command( + f"mkdir {lakehouse_full_path} -P enableSchemas=true") # Assert upsert_item_to_cache.assert_called_once() @@ -132,7 +172,8 @@ def test_mkdir_kqldatabase_with_creation_payload_success( eventhouse_id = mock_questionary_print.call_args[0][0] mock_print_done.reset_mock() upsert_item_to_cache.reset_mock() - kqldatabase_display_name = generate_random_string(vcr_instance, cassette_name) + kqldatabase_display_name = generate_random_string( + vcr_instance, cassette_name) kqldatabase_full_path = cli_path_join( workspace.full_path, f"{kqldatabase_display_name}.{ItemType.KQL_DATABASE}" ) @@ -167,7 +208,8 @@ def test_mkdir_kqldatabase_without_creation_payload_success( upsert_item_to_cache, ): # Setup - kqldatabase_display_name = generate_random_string(vcr_instance, cassette_name) + kqldatabase_display_name = generate_random_string( + vcr_instance, cassette_name) kqldatabase_full_path = cli_path_join( workspace.full_path, f"{kqldatabase_display_name}.{ItemType.KQL_DATABASE}" ) @@ -187,7 +229,8 @@ def test_mkdir_kqldatabase_without_creation_payload_success( mock_questionary_print.reset_mock() eventhouse_full_path = ( - kqldatabase_full_path.removesuffix(".KQLDatabase") + "_auto.Eventhouse" + kqldatabase_full_path.removesuffix( + ".KQLDatabase") + "_auto.Eventhouse" ) get(eventhouse_full_path, query="id") eventhouse_id = mock_questionary_print.call_args[0][0] @@ -201,6 +244,110 @@ def test_mkdir_kqldatabase_without_creation_payload_success( # Cleanup - removing parent eventhouse removes the kqldatabase as well rm(eventhouse_full_path) + # @pytest.mark.parametrize("item_type,params,expected_assertions", [ + # (ItemType.LAKEHOUSE, "enableSchemas=true", ["defaultSchema"]), + # (ItemType.WAREHOUSE, "enableCaseInsensitive=true", + # ["Latin1_General_100_CI_AS_KS_WS_SC_UTF8"]), + # (ItemType.WAREHOUSE, "", ["Latin1_General_100_BIN2_UTF8"]), + # (ItemType.REPORT, "", ["_auto"]), + # ]) + # def test_mkdir_item_with_creation_payload_success( + # self, + # item_type, + # params, + # expected_assertions, + # workspace, + # cli_executor, + # mock_print_done, + # mock_questionary_print, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item_display_name = generate_random_string(vcr_instance, cassette_name) + # item_full_path = cli_path_join( + # workspace.full_path, f"{item_display_name}.{item_type}" + # ) + + # # Execute command + # if params: + # cli_executor.exec_command(f"mkdir {item_full_path} -P {params}") + # else: + # cli_executor.exec_command(f"mkdir {item_full_path}") + + # # Assert creation success + # mock_print_done.assert_called() + # assert item_display_name in mock_print_done.call_args[0][0] + + # # Verify item was created with expected configuration + # mock_questionary_print.reset_mock() + # get(item_full_path, query=".") + # mock_questionary_print.assert_called_once() + + # result_output = mock_questionary_print.call_args[0][0] + # assert item_display_name in result_output + + # # Check type-specific assertions + # for assertion in expected_assertions: + # assert assertion in result_output + + # # Cleanup + # rm(item_full_path) + + # def test_mkdir_mounted_data_factory_with_required_params_success( + # self, + # workspace, + # cli_executor, + # mock_print_done, + # mock_questionary_print, + # vcr_instance, + # cassette_name, + # test_data: StaticTestData, + # ): + # # Setup + # mdf_display_name = generate_random_string(vcr_instance, cassette_name) + # mdf_full_path = cli_path_join( + # workspace.full_path, f"{mdf_display_name}.{ItemType.MOUNTED_DATA_FACTORY}" + # ) + + # # Execute command with required params + # cli_executor.exec_command( + # f"mkdir {mdf_full_path} -P subscriptionId={test_data.azure_subscription_id},resourceGroup={test_data.azure_resource_group},factoryName=test-factory-name" + # ) + + # # Assert creation success + # mock_print_done.assert_called() + # assert mdf_display_name in mock_print_done.call_args[0][0] + + # # Verify item was created + # mock_questionary_print.reset_mock() + # get(mdf_full_path, query=".") + # mock_questionary_print.assert_called_once() + # assert mdf_display_name in mock_questionary_print.call_args[0][0] + + # # Cleanup + # rm(mdf_full_path) + + # def test_mkdir_mounted_data_factory_missing_required_params_failure( + # self, + # workspace, + # cli_executor, + # assert_fabric_cli_error, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # mdf_display_name = generate_random_string(vcr_instance, cassette_name) + # mdf_full_path = cli_path_join( + # workspace.full_path, f"{mdf_display_name}.{ItemType.MOUNTED_DATA_FACTORY}" + # ) + + # # Execute command without required params + # cli_executor.exec_command(f"mkdir {mdf_full_path}") + + # # Assert failure due to missing required params + # assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) + # endregion # region WORKSPACE @@ -217,14 +364,16 @@ def test_mkdir_workspace_with_default_capacity_not_set_failure( self, cli_executor, assert_fabric_cli_error, vcr_instance, cassette_name ): # Setup - fab_default_capacity = state_config.get_config(constant.FAB_DEFAULT_CAPACITY) + fab_default_capacity = state_config.get_config( + constant.FAB_DEFAULT_CAPACITY) fab_default_capacity_id = state_config.get_config( constant.FAB_DEFAULT_CAPACITY_ID ) state_config.set_config(constant.FAB_DEFAULT_CAPACITY, "") state_config.set_config(constant.FAB_DEFAULT_CAPACITY_ID, "") - workspace_display_name = generate_random_string(vcr_instance, cassette_name) + workspace_display_name = generate_random_string( + vcr_instance, cassette_name) workspace_full_path = f"/{workspace_display_name}.Workspace" # Execute command @@ -237,7 +386,8 @@ def test_mkdir_workspace_with_default_capacity_not_set_failure( ) # Cleanup - state_config.set_config(constant.FAB_DEFAULT_CAPACITY, fab_default_capacity) + state_config.set_config( + constant.FAB_DEFAULT_CAPACITY, fab_default_capacity) state_config.set_config( constant.FAB_DEFAULT_CAPACITY_ID, fab_default_capacity_id ) @@ -317,11 +467,14 @@ def _mkdir_workspace_success( ): # Setup - workspace_display_name = generate_random_string(vcr_instance, cassette_name) + workspace_display_name = generate_random_string( + vcr_instance, cassette_name) workspace_full_path = f"/{workspace_display_name}.Workspace" - fab_capacity_name = state_config.get_config(constant.FAB_DEFAULT_CAPACITY) - fab_capacity_name_id = state_config.get_config(constant.FAB_DEFAULT_CAPACITY_ID) + fab_capacity_name = state_config.get_config( + constant.FAB_DEFAULT_CAPACITY) + fab_capacity_name_id = state_config.get_config( + constant.FAB_DEFAULT_CAPACITY_ID) # Execute command if capacity_name: @@ -347,8 +500,10 @@ def _mkdir_workspace_success( assert workspace_display_name in mock_questionary_print.call_args[0][0] # Cleanup - state_config.set_config(constant.FAB_DEFAULT_CAPACITY, fab_capacity_name) - state_config.set_config(constant.FAB_DEFAULT_CAPACITY_ID, fab_capacity_name_id) + state_config.set_config( + constant.FAB_DEFAULT_CAPACITY, fab_capacity_name) + state_config.set_config( + constant.FAB_DEFAULT_CAPACITY_ID, fab_capacity_name_id) rm(workspace_full_path) # endregion @@ -360,7 +515,8 @@ def test_mkdir_onelake_success( # Setup lakehouse = item_factory(ItemType.LAKEHOUSE) mock_print_done.reset_mock() - onelake_display_name = generate_random_string(vcr_instance, cassette_name) + onelake_display_name = generate_random_string( + vcr_instance, cassette_name) onelake_full_path = cli_path_join( lakehouse.full_path, "Files", f"{onelake_display_name}" ) @@ -454,7 +610,8 @@ def test_mkdir_sparkpool_with_params_success( upsert_spark_pool_to_cache, ): # Setup - sparkpool_display_name = generate_random_string(vcr_instance, cassette_name) + sparkpool_display_name = generate_random_string( + vcr_instance, cassette_name) sparkpool_full_path = cli_path_join( workspace.full_path, ".sparkpools", sparkpool_display_name + ".SparkPool" ) @@ -493,7 +650,8 @@ def test_mkdir_sparkpool_without_params_success( upsert_spark_pool_to_cache, ): # Setup - sparkpool_display_name = generate_random_string(vcr_instance, cassette_name) + sparkpool_display_name = generate_random_string( + vcr_instance, cassette_name) sparkpool_full_path = cli_path_join( workspace.full_path, ".sparkpools", sparkpool_display_name + ".SparkPool" ) @@ -530,7 +688,8 @@ def test_mkdir_sparkpool_with_params_without_maxNodeCount_success( upsert_spark_pool_to_cache, ): # Setup - sparkpool_display_name = generate_random_string(vcr_instance, cassette_name) + sparkpool_display_name = generate_random_string( + vcr_instance, cassette_name) sparkpool_full_path = cli_path_join( workspace.full_path, ".sparkpools", sparkpool_display_name + ".SparkPool" ) @@ -571,7 +730,8 @@ def test_mkdir_sparkpool_with_params_without_minNodeCount_success( upsert_spark_pool_to_cache, ): # Setup - sparkpool_display_name = generate_random_string(vcr_instance, cassette_name) + sparkpool_display_name = generate_random_string( + vcr_instance, cassette_name) sparkpool_full_path = cli_path_join( workspace.full_path, ".sparkpools", sparkpool_display_name + ".SparkPool" ) @@ -664,7 +824,8 @@ def test_mkdir_capacity_missing_resource_group_failure( fab_default_az_resource_group = state_config.get_config( constant.FAB_DEFAULT_AZ_RESOURCE_GROUP ) - state_config.set_config(constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") + state_config.set_config( + constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") state_config.set_config(constant.FAB_DEFAULT_AZ_RESOURCE_GROUP, "") capacity_display_name = "invalidcapacity" capacity_full_path = cli_path_join( @@ -698,8 +859,10 @@ def test_mkdir_capacity_missing_location_failure( fab_default_az_location = state_config.get_config( constant.FAB_DEFAULT_AZ_LOCATION ) - state_config.set_config(constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") - state_config.set_config(constant.FAB_DEFAULT_AZ_RESOURCE_GROUP, "placeholder") + state_config.set_config( + constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") + state_config.set_config( + constant.FAB_DEFAULT_AZ_RESOURCE_GROUP, "placeholder") state_config.set_config(constant.FAB_DEFAULT_AZ_LOCATION, "") capacity_display_name = "invalidcapacity" capacity_full_path = cli_path_join( @@ -736,10 +899,14 @@ def test_mkdir_capacity_missing_admin_failure( fab_default_az_location = state_config.get_config( constant.FAB_DEFAULT_AZ_LOCATION ) - fab_default_az_admin = state_config.get_config(constant.FAB_DEFAULT_AZ_ADMIN) - state_config.set_config(constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") - state_config.set_config(constant.FAB_DEFAULT_AZ_RESOURCE_GROUP, "placeholder") - state_config.set_config(constant.FAB_DEFAULT_AZ_LOCATION, "placeholder") + fab_default_az_admin = state_config.get_config( + constant.FAB_DEFAULT_AZ_ADMIN) + state_config.set_config( + constant.FAB_DEFAULT_AZ_SUBSCRIPTION_ID, "placeholder") + state_config.set_config( + constant.FAB_DEFAULT_AZ_RESOURCE_GROUP, "placeholder") + state_config.set_config( + constant.FAB_DEFAULT_AZ_LOCATION, "placeholder") state_config.set_config(constant.FAB_DEFAULT_AZ_ADMIN, "") capacity_display_name = "invalidcapacity" capacity_full_path = cli_path_join( @@ -762,7 +929,8 @@ def test_mkdir_capacity_missing_admin_failure( state_config.set_config( constant.FAB_DEFAULT_AZ_LOCATION, fab_default_az_location ) - state_config.set_config(constant.FAB_DEFAULT_AZ_ADMIN, fab_default_az_admin) + state_config.set_config( + constant.FAB_DEFAULT_AZ_ADMIN, fab_default_az_admin) def test_mkdir_capacity_with_params_success( self, @@ -775,7 +943,8 @@ def test_mkdir_capacity_with_params_success( test_data: StaticTestData, ): # Setup - capacity_display_name = generate_random_string(vcr_instance, cassette_name) + capacity_display_name = generate_random_string( + vcr_instance, cassette_name) capacity_full_path = cli_path_join( ".capacities", capacity_display_name + ".Capacity" ) @@ -812,7 +981,8 @@ def test_mkdir_capacity_success( test_data: StaticTestData, ): # Setup - capacity_display_name = generate_random_string(vcr_instance, cassette_name) + capacity_display_name = generate_random_string( + vcr_instance, cassette_name) capacity_full_path = cli_path_join( ".capacities", capacity_display_name + ".Capacity" ) @@ -905,8 +1075,10 @@ def test_mkdir_domain_without_params_success( upsert_domain_to_cache, ): # Setup - domain_display_name = generate_random_string(vcr_instance, cassette_name) - domain_full_path = cli_path_join(".domains", domain_display_name + ".Domain") + domain_display_name = generate_random_string( + vcr_instance, cassette_name) + domain_full_path = cli_path_join( + ".domains", domain_display_name + ".Domain") # Execute command cli_executor.exec_command(f"mkdir {domain_full_path}") @@ -934,13 +1106,16 @@ def test_mkdir_domain_with_params_success( upsert_domain_to_cache, ): # Setup - parent_domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) + parent_domain = virtual_workspace_item_factory( + VirtualWorkspaceType.DOMAIN) get(parent_domain.full_path, query="id") parent_domain_id = mock_questionary_print.call_args[0][0] mock_print_done.reset_mock() upsert_domain_to_cache.reset_mock() - domain_display_name = generate_random_string(vcr_instance, cassette_name) - domain_full_path = cli_path_join(".domains", domain_display_name + ".Domain") + domain_display_name = generate_random_string( + vcr_instance, cassette_name) + domain_full_path = cli_path_join( + ".domains", domain_display_name + ".Domain") # Execute command cli_executor.exec_command( @@ -971,7 +1146,8 @@ def test_mkdir_domain_without_params_failure( ): domain_display_name = "domainNoParams" - domain_full_path = cli_path_join(".domains", domain_display_name + ".Domain") + domain_full_path = cli_path_join( + ".domains", domain_display_name + ".Domain") # with params=[] we simulate -P without args cli_executor.exec_command(f"mkdir {domain_full_path} -P") @@ -1162,7 +1338,8 @@ def test_mkdir_managed_private_endpoint_without_params_fail( ) # Execute command - cli_executor.exec_command(f"mkdir {managed_private_endpoint_full_path}") + cli_executor.exec_command( + f"mkdir {managed_private_endpoint_full_path}") # Assert assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) @@ -1244,7 +1421,8 @@ def test_mkdir_external_data_share_with_params_success( eds_display_name = generate_random_string(vcr_instance, cassette_name) type = VirtualItemContainerType.EXTERNAL_DATA_SHARE eds_full_path = cli_path_join( - workspace.full_path, str(type), f"{eds_display_name}.{str(VICMap[type])}" + workspace.full_path, str( + type), f"{eds_display_name}.{str(VICMap[type])}" ) # Execute command @@ -1270,7 +1448,8 @@ def test_mkdir_external_data_share_with_params_success( generated_name = ".".join(parts[:2]) eds_full_path = cli_path_join( - workspace.full_path, str(type), f"{generated_name}.{str(VICMap[type])}" + workspace.full_path, str( + type), f"{generated_name}.{str(VICMap[type])}" ) # Cleanup @@ -1292,7 +1471,8 @@ def test_mkdir_external_data_share_without_params_fail( eds_display_name = generate_random_string(vcr_instance, cassette_name) type = VirtualItemContainerType.EXTERNAL_DATA_SHARE eds_full_path = cli_path_join( - workspace.full_path, str(type), f"{eds_display_name}.{str(VICMap[type])}" + workspace.full_path, str( + type), f"{eds_display_name}.{str(VICMap[type])}" ) # Execute command @@ -1317,7 +1497,8 @@ def test_mkdir_connection_with_params_success( cassette_name, ): # Setup - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1358,7 +1539,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_success( cassette_name, ): # Setup - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1389,9 +1571,10 @@ def test_mkdir_connection_with_onpremises_gateway_params_ignore_params_success( vcr_instance, test_data: StaticTestData, cassette_name, - ): + ): # Setup - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1424,7 +1607,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( cassette_name, ): # Setup - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1437,7 +1621,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( # Assert mock_fab_ui_print_error.assert_called() assert mock_fab_ui_print_error.call_count == 1 - assert mock_fab_ui_print_error.call_args[0][0].message == "Missing parameters for credential type Basic: ['values']" + assert mock_fab_ui_print_error.call_args[0][ + 0].message == "Missing parameters for credential type Basic: ['values']" assert mock_fab_ui_print_error.call_args[0][0].status_code == "InvalidInput" mock_fab_ui_print_error.reset_mock() @@ -1450,7 +1635,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( # Assert mock_fab_ui_print_error.assert_called() assert mock_fab_ui_print_error.call_count == 1 - assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.missing_onpremises_gateway_parameters(['encryptedCredentials']) + assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.missing_onpremises_gateway_parameters([ + 'encryptedCredentials']) assert mock_fab_ui_print_error.call_args[0][0].status_code == "InvalidInput" mock_fab_ui_print_error.reset_mock() @@ -1463,7 +1649,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( # Assert mock_fab_ui_print_error.assert_called() assert mock_fab_ui_print_error.call_count == 1 - assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.missing_onpremises_gateway_parameters(['gatewayId']) + assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.missing_onpremises_gateway_parameters([ + 'gatewayId']) assert mock_fab_ui_print_error.call_args[0][0].status_code == "InvalidInput" mock_fab_ui_print_error.reset_mock() @@ -1476,7 +1663,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( # Assert mock_fab_ui_print_error.assert_called() assert mock_fab_ui_print_error.call_count == 1 - assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.invalid_onpremises_gateway_values() + assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.invalid_onpremises_gateway_values( + ) assert mock_fab_ui_print_error.call_args[0][0].status_code == "InvalidInput" mock_fab_ui_print_error.reset_mock() @@ -1489,7 +1677,8 @@ def test_mkdir_connection_with_onpremises_gateway_params_failure( # Assert mock_fab_ui_print_error.assert_called() assert mock_fab_ui_print_error.call_count == 1 - assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.invalid_onpremises_gateway_values() + assert mock_fab_ui_print_error.call_args[0][0].message == ErrorMessages.Common.invalid_onpremises_gateway_values( + ) assert mock_fab_ui_print_error.call_args[0][0].status_code == "InvalidInput" def test_mkdir_connection_with_gateway_params_success( @@ -1502,7 +1691,8 @@ def test_mkdir_connection_with_gateway_params_success( cassette_name, ): # Setup - gateway_display_name = generate_random_string(vcr_instance, cassette_name) + gateway_display_name = generate_random_string( + vcr_instance, cassette_name) gateway_full_path = cli_path_join( ".gateways", gateway_display_name + ".Gateway" ) @@ -1512,7 +1702,8 @@ def test_mkdir_connection_with_gateway_params_success( f"capacity={test_data.capacity.name},virtualNetworkName={test_data.vnet.name},subnetName={test_data.vnet.subnet}" ], ) - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1572,7 +1763,8 @@ def test_mkdir_connection_case_sensitivity_scenario_success( cassette_name, test_data: StaticTestData, ): - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1599,7 +1791,8 @@ def test_mkdir_connection_case_insensitive_parameter_matching_success( test_data: StaticTestData, ): """Test that parameter name matching is case-insensitive for creation method inference.""" - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1646,7 +1839,8 @@ def test_mkdir_connection_parameter_name_none_safety_success( test_data: StaticTestData, ): """Test that parameter name None safety doesn't break normal operation.""" - connection_display_name = generate_random_string(vcr_instance, cassette_name) + connection_display_name = generate_random_string( + vcr_instance, cassette_name) connection_full_path = cli_path_join( ".connections", connection_display_name + ".Connection" ) @@ -1676,7 +1870,8 @@ def test_mkdir_gateway_with_params_success( cassette_name, ): # Setup - gateway_display_name = generate_random_string(vcr_instance, cassette_name) + gateway_display_name = generate_random_string( + vcr_instance, cassette_name) gateway_full_path = cli_path_join( ".gateways", gateway_display_name + ".Gateway" ) @@ -1767,7 +1962,8 @@ def test_mkdir_workspace_verify_stderr_stdout_messages_text_format_success( cassette_name, test_data: StaticTestData, ): - workspace_display_name = generate_random_string(vcr_instance, cassette_name) + workspace_display_name = generate_random_string( + vcr_instance, cassette_name) captured, workspace_full_path = self._verify_mkdir_workspace_output( cli_executor, workspace_display_name, @@ -1793,7 +1989,8 @@ def test_mkdir_workspace_verify_stderr_stdout_messages_json_format_success( ): # Set output format to json mock_fab_set_state_config(constant.FAB_OUTPUT_FORMAT, "json") - workspace_display_name = generate_random_string(vcr_instance, cassette_name) + workspace_display_name = generate_random_string( + vcr_instance, cassette_name) captured, workspace_full_path = self._verify_mkdir_workspace_output( cli_executor, workspace_display_name, @@ -1850,7 +2047,8 @@ def test_mkdir_item_in_folder_listing_success( def test_mkdir_folder_success(self, workspace, cli_executor, mock_print_done): # Setup folder_display_name = "folder" - folder_full_path = cli_path_join(workspace.full_path, folder_display_name) + folder_full_path = cli_path_join( + workspace.full_path, folder_display_name) # Execute command cli_executor.exec_command(f"mkdir {folder_full_path}") @@ -1910,7 +2108,8 @@ def test_mkdir_single_item_creation_batch_output_structure_success( ): """Test that single item creation uses batched output structure.""" # Setup - lakehouse_display_name = generate_random_string(vcr_instance, cassette_name) + lakehouse_display_name = generate_random_string( + vcr_instance, cassette_name) lakehouse_full_path = cli_path_join( workspace.full_path, f"{lakehouse_display_name}.{ItemType.LAKEHOUSE}" ) @@ -1926,7 +2125,8 @@ def test_mkdir_single_item_creation_batch_output_structure_success( # Verify headers and values in mock_questionary_print.mock_calls # Look for the table output with headers - output_calls = [str(call) for call in mock_questionary_print.mock_calls] + output_calls = [str(call) + for call in mock_questionary_print.mock_calls] table_output = "\n".join(output_calls) # Check for standard table headers @@ -1953,7 +2153,8 @@ def test_mkdir_dependency_creation_batched_output_kql_database_success( ): """Test that KQL Database creation with EventHouse dependency produces batched output.""" # Setup - kqldatabase_display_name = generate_random_string(vcr_instance, cassette_name) + kqldatabase_display_name = generate_random_string( + vcr_instance, cassette_name) kqldatabase_full_path = cli_path_join( workspace.full_path, f"{kqldatabase_display_name}.{ItemType.KQL_DATABASE}" ) @@ -1974,7 +2175,8 @@ def test_mkdir_dependency_creation_batched_output_kql_database_success( ) # Verify headers and values in mock_questionary_print.mock_calls for batched output - output_calls = [str(call) for call in mock_questionary_print.mock_calls] + output_calls = [str(call) + for call in mock_questionary_print.mock_calls] table_output = "\n".join(output_calls) # Check for standard table headers (should appear once for consolidated table) @@ -1993,7 +2195,8 @@ def test_mkdir_dependency_creation_batched_output_kql_database_success( # Cleanup - removing parent eventhouse removes the kqldatabase as well eventhouse_full_path = ( - kqldatabase_full_path.removesuffix(".KQLDatabase") + "_auto.Eventhouse" + kqldatabase_full_path.removesuffix( + ".KQLDatabase") + "_auto.Eventhouse" ) rm(eventhouse_full_path) diff --git a/tests/test_commands/test_mv.py b/tests/test_commands/test_mv.py index 5563ff6b..41111726 100644 --- a/tests/test_commands/test_mv.py +++ b/tests/test_commands/test_mv.py @@ -3,6 +3,7 @@ import argparse from unittest.mock import patch +import pytest import fabric_cli.commands.fs.fab_fs_ln as fab_ln import fabric_cli.commands.fs.fab_fs_ls as fab_ls @@ -11,7 +12,7 @@ from fabric_cli.core.fab_types import ItemType, VirtualWorkspaceType, VirtualItemContainerType from fabric_cli.core.hiearchy.fab_onelake_element import OneLakeItem from tests.test_commands.commands_parser import CLIExecutor -from tests.test_commands.conftest import mkdir +from tests.test_commands.conftest import basic_item_parametrize, mkdir from tests.test_commands.data.models import EntityMetadata from tests.test_commands.utils import cli_path_join @@ -51,11 +52,13 @@ def test_mv_workspace_to_workspace_non_recursive_success( mock_confirm.return_value.ask.return_value = True # Execute command - cli_executor.exec_command(f"mv {ws1.full_path} {ws2.full_path} --force") + cli_executor.exec_command( + f"mv {ws1.full_path} {ws2.full_path} --force") # Clean up - update the full path of the moved items so the factory can clean them up notebook.full_path = cli_path_join(ws2.full_path, notebook.name) - data_pipeline.full_path = cli_path_join(ws2.full_path, data_pipeline.name) + data_pipeline.full_path = cli_path_join( + ws2.full_path, data_pipeline.name) # Assert mock_print_done.assert_called() @@ -141,7 +144,8 @@ def test_mv_workspace_to_workspace_recursive_success( # Clean up - update the full path of the moved items so the factory can clean them up notebook.full_path = cli_path_join(ws2.full_path, notebook.name) - data_pipeline.full_path = cli_path_join(ws2.full_path, data_pipeline.name) + data_pipeline.full_path = cli_path_join( + ws2.full_path, data_pipeline.name) f1.full_path = cli_path_join(ws2.full_path, f1.name) sjd.full_path = cli_path_join(ws2.full_path, f1.name, sjd.name) @@ -187,105 +191,94 @@ def test_mv_workspace_to_workspace_recursive_success( sjd.name in call.args[0] for call in mock_questionary_print.mock_calls ) - def test_mv_item_to_item_success( - self, - workspace_factory, - item_factory, - mock_print_done, - mock_questionary_print, - cli_executor: CLIExecutor, - mock_print_warning, - ): - # Setup - ws1 = workspace_factory() - ws2 = workspace_factory() - notebook = item_factory(ItemType.NOTEBOOK, ws1.full_path) - - # Reset mock - mock_print_done.reset_mock() - mock_print_warning.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - - mock_confirm.return_value.ask.return_value = True - - # Execute command - target_path = cli_path_join(ws2.full_path, notebook.name) - cli_executor.exec_command(f"mv {notebook.full_path} {target_path} --force") - - # Clean up - update the full path of the moved items so the factory can clean them up - notebook.full_path = cli_path_join(ws2.full_path, notebook.name) - - # Assert - mock_print_done.assert_called() - mock_print_warning.assert_called_once() - - mock_questionary_print.reset_mock() - ls(ws1.full_path) - assert all( - notebook.display_name not in call.args[0] - for call in mock_questionary_print.mock_calls - ) - - mock_questionary_print.reset_mock() - ls(ws2.full_path) - assert any( - notebook.display_name in call.args[0] - for call in mock_questionary_print.mock_calls - ) - - def test_mv_item_to_item_unsupported_failure( - self, - workspace_factory, - item_factory, - mock_print_done, - assert_fabric_cli_error, - mock_fab_ui_print_error, - cli_executor: CLIExecutor, - mock_print_warning, - ): - # Setup - ws1 = workspace_factory() - ws2 = workspace_factory() - eventhouse = item_factory(ItemType.EVENTHOUSE, ws1.full_path) - kql_db = item_factory(ItemType.KQL_DATABASE, ws1.full_path) - eventstream = item_factory(ItemType.EVENTSTREAM, ws1.full_path) - - # Reset mock - mock_print_done.reset_mock() - mock_print_warning.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - - mock_confirm.return_value.ask.return_value = True - - # Execute command - # EventHouse - target_path = cli_path_join(ws2.full_path, eventhouse.name) - cli_executor.exec_command( - f"mv {eventhouse.full_path} {target_path} --force" - ) - - assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) - - mock_fab_ui_print_error.reset_mock() + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # def test_mv_item_to_item_success( + # self, + # workspace_factory, + # item_factory, + # mock_print_done, + # mock_questionary_print, + # cli_executor: CLIExecutor, + # mock_print_warning, + # item_type, + # ): + # # Setup + # ws1 = workspace_factory() + # ws2 = workspace_factory() + # item = item_factory(item_type, ws1.full_path) + + # # Reset mock + # mock_print_done.reset_mock() + # mock_print_warning.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + + # mock_confirm.return_value.ask.return_value = True + + # # Execute command + # target_path = cli_path_join(ws2.full_path, item.name) + # cli_executor.exec_command(f"mv {item.full_path} {target_path} --force") + + # # Clean up - update the full path of the moved items so the factory can clean them up + # item.full_path = cli_path_join(ws2.full_path, item.name) + + # # Assert + # mock_print_done.assert_called() + # mock_print_warning.assert_called_once() + + # mock_questionary_print.reset_mock() + # ls(ws1.full_path) + # assert all( + # item.display_name not in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + + # mock_questionary_print.reset_mock() + # ls(ws2.full_path) + # assert any( + # item.display_name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + + # @pytest.mark.parametrize("unsupported_item_type", [ + # ItemType.EVENTHOUSE, + # ItemType.KQL_DATABASE, + # ItemType.EVENTSTREAM, + # ]) + # def test_mv_item_to_item_unsupported_failure( + # self, + # workspace_factory, + # item_factory, + # mock_print_done, + # assert_fabric_cli_error, + # mock_fab_ui_print_error, + # cli_executor: CLIExecutor, + # mock_print_warning, + # unsupported_item_type, + # ): + # # Setup + # ws1 = workspace_factory() + # ws2 = workspace_factory() + # item = item_factory(unsupported_item_type, ws1.full_path) + + # # Reset mock + # mock_print_done.reset_mock() + # mock_print_warning.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + + # mock_confirm.return_value.ask.return_value = True + + # # Execute command + # target_path = cli_path_join(ws2.full_path, item.name) + # cli_executor.exec_command(f"mv {item.full_path} {target_path} --force") + + # assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) - # KqlDB - target_path = cli_path_join(ws2.full_path, kql_db.name) - cli_executor.exec_command(f"mv {kql_db.full_path} {target_path} --force") - - assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) - - mock_fab_ui_print_error.reset_mock() - - # EventStream - target_path = cli_path_join(ws2.full_path, eventstream.name) - cli_executor.exec_command( - f"mv {eventstream.full_path} {target_path} --force" - ) - - assert_fabric_cli_error(constant.ERROR_UNSUPPORTED_COMMAND) - def test_mv_type_mismatch_error( self, workspace_factory, @@ -294,13 +287,14 @@ def test_mv_type_mismatch_error( assert_fabric_cli_error, ): ws = workspace_factory() - virtual_item = virtual_workspace_item_factory(VirtualWorkspaceType.CONNECTION) + virtual_item = virtual_workspace_item_factory( + VirtualWorkspaceType.CONNECTION) - cli_executor.exec_command(f"mv {ws.full_path} {virtual_item.full_path} --force") + cli_executor.exec_command( + f"mv {ws.full_path} {virtual_item.full_path} --force") assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) - def test_mv_workspace_to_workspace_item_already_exists_success( self, workspace_factory, @@ -332,7 +326,8 @@ def test_mv_workspace_to_workspace_item_already_exists_success( mock_checkbox.return_value.ask.return_value = [notebook1.name] mock_confirm.return_value.ask.return_value = True - cli_executor.exec_command(f"mv {ws1.full_path} {ws2.full_path} --force") + cli_executor.exec_command( + f"mv {ws1.full_path} {ws2.full_path} --force") # Clean up - update the full path of the moved items so the factory can clean them up notebook1.full_path = cli_path_join(ws2.full_path, notebook1.name) @@ -387,7 +382,8 @@ def test_mv_item_from_workspace_to_workspace_when_item_already_exists( mock_confirm.return_value.ask.return_value = True # Execute command target_path = cli_path_join(ws2.full_path, notebook1.name) - cli_executor.exec_command(f"mv {notebook1.full_path} {target_path} --force") + cli_executor.exec_command( + f"mv {notebook1.full_path} {target_path} --force") # Clean up - update the full path of the moved items so the factory can clean them up notebook1.full_path = cli_path_join(ws2.full_path, notebook1.name) @@ -463,7 +459,8 @@ def test_mv_item_workspace_to_workspace_no_confirmation_failure( target_path = cli_path_join(ws2.full_path, notebook1.name) # Execute command - cli_executor.exec_command(f"mv {notebook1.full_path} {target_path}") + cli_executor.exec_command( + f"mv {notebook1.full_path} {target_path}") # assert assert mock_questionary_print.call_count == 0 @@ -476,7 +473,8 @@ def test_mv_workspace_to_workspace_empty_failure( target_path = "My workspace.Personal" # Execute command - cli_executor.exec_command(f"mv {workspace.full_path} {target_path} --force") + cli_executor.exec_command( + f"mv {workspace.full_path} {target_path} --force") # Assert assert_fabric_cli_error(constant.ERROR_INVALID_OPERATION) @@ -499,65 +497,81 @@ def test_mv_workspace_to_item_type_mismatch_failure( # Assert assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) - def test_mv_item_to_item_type_mismatch_failure( - self, item_factory, cli_executor: CLIExecutor, assert_fabric_cli_error - ): - # Setup - notebook = item_factory(ItemType.NOTEBOOK) - data_pipeline = item_factory(ItemType.DATA_PIPELINE) - - cli_executor.exec_command( - f"mv {data_pipeline.full_path} {notebook.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) - - def test_mv_item_within_workspace_rename_success( - self, - workspace_factory, - item_factory, - mock_print_done, - mock_questionary_print, - cli_executor: CLIExecutor, - ): - # Setup - ws1 = workspace_factory() - # Create item in ws1 - notebook = item_factory(ItemType.NOTEBOOK, ws1.full_path) - - # Reset mock - mock_print_done.reset_mock() - mock_questionary_print.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - mock_confirm.return_value.ask.return_value = True - - renamed_notebook_name = f"{notebook.display_name} Renamed.Notebook" - - # Execute command - target_path = cli_path_join(ws1.full_path, renamed_notebook_name) - cli_executor.exec_command(f"mv {notebook.full_path} {target_path} --force") - - # Clean up - update the full path of the moved items so the factory can clean them up - notebook.full_path = target_path - - # Assert - mock_print_done.assert_called() - assert any( - call.args[0] == "Move completed\n" for call in mock_print_done.mock_calls - ) - - mock_questionary_print.reset_mock() - ls(ws1.full_path) - assert all( - notebook.name not in call.args[0] - for call in mock_questionary_print.mock_calls - ) - assert any( - renamed_notebook_name in call.args[0] - for call in mock_questionary_print.mock_calls - ) + # @pytest.mark.parametrize("source_type,target_type", [ + # (ItemType.NOTEBOOK, ItemType.DATA_PIPELINE), + # (ItemType.REPORT, ItemType.LAKEHOUSE), + # (ItemType.SEMANTIC_MODEL, ItemType.WAREHOUSE) + # ]) + # def test_mv_item_to_item_type_mismatch_failure( + # self, + # item_factory, + # cli_executor: CLIExecutor, + # assert_fabric_cli_error, + # source_type, + # target_type, + # ): + # # Setup + # source_item = item_factory(source_type) + # target_item = item_factory(target_type) + + # cli_executor.exec_command( + # f"mv {source_item.full_path} {target_item.full_path} --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) + + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # def test_mv_item_within_workspace_rename_success( + # self, + # workspace_factory, + # item_factory, + # mock_print_done, + # mock_questionary_print, + # cli_executor: CLIExecutor, + # item_type, + # ): + # # Setup + # ws1 = workspace_factory() + # # Create item in ws1 + # item = item_factory(item_type, ws1.full_path) + + # # Reset mock + # mock_print_done.reset_mock() + # mock_questionary_print.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + # mock_confirm.return_value.ask.return_value = True + + # renamed_item_name = f"{item.display_name} Renamed.{item_type}" + + # # Execute command + # target_path = cli_path_join(ws1.full_path, renamed_item_name) + # cli_executor.exec_command(f"mv {item.full_path} {target_path} --force") + + # # Clean up - update the full path of the moved items so the factory can clean them up + # item.full_path = target_path + + # # Assert + # mock_print_done.assert_called() + # assert any( + # call.args[0] == "Move completed\n" for call in mock_print_done.mock_calls + # ) + + # mock_questionary_print.reset_mock() + # ls(ws1.full_path) + # assert all( + # item.name not in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) + # assert any( + # renamed_item_name in call.args[0] + # for call in mock_questionary_print.mock_calls + # ) def test_mv_item_within_workspace_failure( self, @@ -585,7 +599,8 @@ def test_mv_item_within_workspace_failure( # Execute command target_path = cli_path_join(folder.full_path, notebook.name) - cli_executor.exec_command(f"mv {notebook.full_path} {target_path} --force") + cli_executor.exec_command( + f"mv {notebook.full_path} {target_path} --force") # Assert assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) @@ -620,7 +635,8 @@ def test_mv_folder_to_workspace_success( # Clean up - update the full path of the moved items so the factory can clean them up notebook.full_path = cli_path_join(ws2.full_path, notebook.name) - data_pipeline.full_path = cli_path_join(ws2.full_path, data_pipeline.name) + data_pipeline.full_path = cli_path_join( + ws2.full_path, data_pipeline.name) f1.full_path = cli_path_join(ws2.full_path, f1.name) # Assert @@ -673,7 +689,8 @@ def test_mv_folder_inside_workspace_success( # Create items in the source folder notebook = item_factory(ItemType.NOTEBOOK, source_folder.full_path) - data_pipeline = item_factory(ItemType.DATA_PIPELINE, source_folder.full_path) + data_pipeline = item_factory( + ItemType.DATA_PIPELINE, source_folder.full_path) # Create a nested folder inside source folder nested_folder = folder_factory(path=source_folder.full_path) @@ -697,7 +714,8 @@ def test_mv_folder_inside_workspace_success( moved_source_folder_path = cli_path_join( dest_folder.full_path, source_folder.name ) - notebook.full_path = cli_path_join(moved_source_folder_path, notebook.name) + notebook.full_path = cli_path_join( + moved_source_folder_path, notebook.name) data_pipeline.full_path = cli_path_join( moved_source_folder_path, data_pipeline.name ) @@ -792,4 +810,4 @@ def _build_ln_args(path, type, target, input, force): input=[input] if input else None, type=type, force=force, - ) \ No newline at end of file + ) diff --git a/tests/test_commands/test_rm.py b/tests/test_commands/test_rm.py index d68f82e7..e3e171b6 100644 --- a/tests/test_commands/test_rm.py +++ b/tests/test_commands/test_rm.py @@ -25,110 +25,156 @@ from tests.test_commands.data.static_test_data import StaticTestData from tests.test_commands.processors import generate_random_string from tests.test_commands.utils import cli_path_join +from tests.test_commands.conftest import basic_item_parametrize, custom_parametrize class TestRM: # region ITEM - def test_rm_item_success( - self, - workspace, - cli_executor, - mock_questionary_print, - mock_print_warning, - mock_print_done, - vcr_instance, - cassette_name, - ): - # Setup - notebook = set_entity_metadata( - vcr_instance, cassette_name, "Notebook", workspace.full_path - ) - mkdir(notebook.full_path) - mock_print_done.reset_mock() - - # Execute command - cli_executor.exec_command(f"rm {notebook.full_path} --force") - - # Assert - mock_print_warning.assert_called() - mock_questionary_print.assert_called() - mock_print_done.assert_called_once() - _assert_strings_in_mock_calls( - [notebook.display_name], True, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - [notebook.display_name], True, mock_print_done.mock_calls - ) - - _assert_not_found(notebook.full_path) - - def test_rm_item_without_force_success( - self, - workspace, - cli_executor, - mock_questionary_print, - mock_print_done, - vcr_instance, - cassette_name, - ): - # Setup - notebook = set_entity_metadata( - vcr_instance, cassette_name, "Notebook", workspace.full_path - ) - mkdir(notebook.full_path) - # Reset mocks - mock_print_done.reset_mock() - mock_questionary_print.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - mock_confirm.return_value.ask.return_value = True - - # Execute command - cli_executor.exec_command(f"rm {notebook.full_path}") - - # Assert - mock_confirm.assert_called_once() - mock_questionary_print.assert_called_once() - mock_print_done.assert_called_once() - _assert_strings_in_mock_calls( - [notebook.display_name], True, mock_questionary_print.mock_calls - ) - _assert_strings_in_mock_calls( - [notebook.display_name], True, mock_print_done.mock_calls - ) - - _assert_not_found(notebook.full_path) - - def test_rm_item_without_force_cancel_operation_success( - self, - workspace, - cli_executor, - mock_questionary_print, - mock_print_done, - mock_print_warning, - vcr_instance, - cassette_name, - ): - # Setup - notebook = set_entity_metadata( - vcr_instance, cassette_name, "Notebook", workspace.full_path - ) - mkdir(notebook.full_path) - # Reset mocks - mock_print_done.reset_mock() - mock_questionary_print.reset_mock() - - with patch("questionary.confirm") as mock_confirm: - mock_confirm.return_value.ask.return_value = False - # Execute command - cli_executor.exec_command(f"rm {notebook.full_path}") - - # Assert - mock_print_warning.assert_called_once() - mock_confirm.assert_called_once() - mock_questionary_print.assert_not_called() - mock_print_done.assert_not_called() + # @custom_parametrize + # def test_rm_item_success( + # self, + # workspace, + # item_type, + # cli_executor, + # mock_questionary_print, + # mock_print_warning, + # mock_print_done, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item = set_entity_metadata( + # vcr_instance, cassette_name, item_type, workspace.full_path + # ) + # mkdir(item.full_path) + # mock_print_done.reset_mock() + + # # Execute command + # cli_executor.exec_command(f"rm {item.full_path} --force") + + # # Assert + # mock_print_warning.assert_called() + # mock_questionary_print.assert_called() + # mock_print_done.assert_called_once() + # _assert_strings_in_mock_calls( + # [item.display_name], True, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # [item.display_name], True, mock_print_done.mock_calls + # ) + + # _assert_not_found(item.full_path) + + # @custom_parametrize + # def test_rm_item_without_force_success( + # self, + # workspace, + # item_type, + # cli_executor, + # mock_questionary_print, + # mock_print_done, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item = set_entity_metadata( + # vcr_instance, cassette_name, item_type, workspace.full_path + # ) + # mkdir(item.full_path) + # # Reset mocks + # mock_print_done.reset_mock() + # mock_questionary_print.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + # mock_confirm.return_value.ask.return_value = True + + # # Execute command + # cli_executor.exec_command(f"rm {item.full_path}") + + # # Assert + # mock_confirm.assert_called_once() + # mock_questionary_print.assert_called_once() + # mock_print_done.assert_called_once() + # _assert_strings_in_mock_calls( + # [item.display_name], True, mock_questionary_print.mock_calls + # ) + # _assert_strings_in_mock_calls( + # [item.display_name], True, mock_print_done.mock_calls + # ) + + # _assert_not_found(item.full_path) + + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, + # ItemType.ENVIRONMENT, ItemType.EVENTHOUSE, ItemType.EVENTSTREAM, + # ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, + # ItemType.LAKEHOUSE, ItemType.ML_EXPERIMENT, ItemType.ML_MODEL, + # ItemType.MIRRORED_DATABASE, ItemType.NOTEBOOK, + # ItemType.REFLEX, ItemType.SQL_DATABASE, ItemType.SEMANTIC_MODEL, + # ItemType.SPARK_JOB_DEFINITION, ItemType.WAREHOUSE, ItemType.COPYJOB, + # ItemType.GRAPHQLAPI, ItemType.DATAFLOW, + # ]) + # def test_rm_item_without_force_cancel_operation_success( + # self, + # workspace, + # item_type, + # cli_executor, + # mock_questionary_print, + # mock_print_done, + # mock_print_warning, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item = set_entity_metadata( + # vcr_instance, cassette_name, item_type, workspace.full_path + # ) + # mkdir(item.full_path) + # # Reset mocks + # mock_print_done.reset_mock() + # mock_questionary_print.reset_mock() + + # with patch("questionary.confirm") as mock_confirm: + # mock_confirm.return_value.ask.return_value = False + + # # Execute command + # cli_executor.exec_command(f"rm {item.full_path}") + + # # Assert + # mock_print_warning.assert_called_once() + # mock_confirm.assert_called_once() + # mock_questionary_print.assert_not_called() + # mock_print_done.assert_not_called() + + # @pytest.mark.parametrize("unsupported_item_type", [ + # ItemType.DASHBOARD, + # ItemType.DATAMART, + # ItemType.MIRRORED_WAREHOUSE, + # ItemType.PAGINATED_REPORT, + # ItemType.SQL_ENDPOINT, + # ]) + # def test_rm_unsupported_item_failure( + # self, + # unsupported_item_type, + # workspace_factory, + # cli_executor, + # assert_fabric_cli_error, + # vcr_instance, + # cassette_name, + # ): + # workspace = workspace_factory() + + # # Create unsupported item metadata + # item_display_name = generate_random_string(vcr_instance, cassette_name) + # item_name = f"{item_display_name}.{unsupported_item_type}" + # item_full_path = cli_path_join(workspace.full_path, item_name) + + # # Execute command + # cli_executor.exec_command(f"rm {item_full_path} --force") + + # # Assert + # assert_fabric_cli_error(constant.ERROR_NOT_FOUND) # endregion @@ -144,7 +190,8 @@ def test_rm_workspace_force_success( test_data: StaticTestData, ): # Setup - workspace = set_entity_metadata(vcr_instance, cassette_name, "Workspace", "/") + workspace = set_entity_metadata( + vcr_instance, cassette_name, "Workspace", "/") mkdir( workspace.full_path, params=[f"capacityName={test_data.capacity.name}"], @@ -191,7 +238,8 @@ def test_rm_workspace_tenant_level_success( test_data: StaticTestData, ): # Setup - workspace = set_entity_metadata(vcr_instance, cassette_name, "Workspace", "/") + workspace = set_entity_metadata( + vcr_instance, cassette_name, "Workspace", "/") mkdir( workspace.full_path, params=[f"capacityName={test_data.capacity.name}"], @@ -253,7 +301,7 @@ def test_rm_workspace_without_force_success( mkdir(notebook.full_path) mock_print_done.reset_mock() mock_questionary_print.reset_mock() - + with ( patch("questionary.checkbox") as mock_checkbox, patch("questionary.confirm") as mock_confirm, @@ -295,7 +343,8 @@ def test_rm_empty_workspace_without_force_failure( test_data: StaticTestData, ): # Setup - workspace = set_entity_metadata(vcr_instance, cassette_name, "Workspace", "/") + workspace = set_entity_metadata( + vcr_instance, cassette_name, "Workspace", "/") mkdir( workspace.full_path, params=[f"capacityName={test_data.capacity.name}"], @@ -329,7 +378,8 @@ def test_rm_spark_pool_success( cassette_name, ): # Setup - sparkpool_display_name = generate_random_string(vcr_instance, cassette_name) + sparkpool_display_name = generate_random_string( + vcr_instance, cassette_name) sparkpool_name = f"{sparkpool_display_name}.SparkPool" sparkpool_full_path = cli_path_join( workspace.full_path, ".sparkpools", sparkpool_name @@ -417,7 +467,8 @@ def test_rm_managed_private_endpoint_success( mock_print_done.reset_mock() # Execute command - cli_executor.exec_command(f"rm {managed_private_endpoint.full_path} --force") + cli_executor.exec_command( + f"rm {managed_private_endpoint.full_path} --force") # Assert mock_print_warning.assert_called() @@ -457,7 +508,8 @@ def test_rm_external_data_share_success( mock_print_done.reset_mock() # Execute command - cli_executor.exec_command(f"rm {external_data_share.full_path} --force") + cli_executor.exec_command( + f"rm {external_data_share.full_path} --force") # Assert mock_print_warning.assert_called() @@ -523,7 +575,8 @@ def test_rm_domain_success( cassette_name, ): # Setup - domain = set_entity_metadata(vcr_instance, cassette_name, "Domain", ".domains") + domain = set_entity_metadata( + vcr_instance, cassette_name, "Domain", ".domains") mkdir(domain.full_path) mock_print_done.reset_mock() @@ -685,7 +738,8 @@ def test_rm_non_empty_folder_failure( cli_executor.exec_command(f"rm {folder.full_path} --force") # Assert - assert_fabric_cli_error("FolderNotEmpty", "The requested folder was not empty") + assert_fabric_cli_error( + "FolderNotEmpty", "The requested folder was not empty") # Cleanup rm(lakehouse.full_path, force=True) diff --git a/tests/test_commands/test_set.py b/tests/test_commands/test_set.py index f0362891..38376baf 100644 --- a/tests/test_commands/test_set.py +++ b/tests/test_commands/test_set.py @@ -20,6 +20,7 @@ VirtualWorkspaceType, ) from fabric_cli.core.hiearchy.fab_onelake_element import OneLakeItem +from tests.test_commands.conftest import basic_item_parametrize from tests.test_commands.data.models import EntityMetadata from tests.test_commands.processors import generate_random_string from tests.test_commands.utils import cli_path_join @@ -27,6 +28,55 @@ class TestSET: # region Item + # @pytest.mark.parametrize("entity_type,factory_method,entity_setup,should_cache", [ + # ("item", "item_factory", ItemType.LAKEHOUSE, False), + # ("workspace", "workspace_factory", None, False), + # ("sparkpool", "virtual_item_factory", VirtualItemContainerType.SPARK_POOL, False), + # ("domain", "virtual_workspace_item_factory", VirtualWorkspaceType.DOMAIN, False), + # ]) + # def test_set_entity_invalid_query_failure( + # self, + # entity_type, + # factory_method, + # entity_setup, + # should_cache, + # item_factory, + # workspace_factory, + # virtual_item_factory, + # virtual_workspace_item_factory, + # cli_executor, + # assert_fabric_cli_error, + # mock_questionary_print, + # mock_print_done, + # upsert_item_to_cache, + # setup_config_values_for_capacity, + # ): + # # Setup based on entity type + # if entity_type == "item": + # entity = item_factory(entity_setup) + # elif entity_type == "workspace": + # entity = workspace_factory() + # elif entity_type == "sparkpool": + # entity = virtual_item_factory(entity_setup) + # elif entity_type == "domain": + # entity = virtual_workspace_item_factory(entity_setup) + + # # Reset mocks + # mock_questionary_print.reset_mock() + # mock_print_done.reset_mock() + # if should_cache: + # upsert_item_to_cache.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"set {entity.full_path} --query non_existent_query --input new_value --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_INVALID_QUERY) + # if should_cache: + # upsert_item_to_cache.assert_not_called() + def test_set_item_invalid_query_failure( self, item_factory, @@ -84,6 +134,40 @@ def test_set_item_metadata_success( should_upsert_to_cache, ) + # @pytest.mark.parametrize("item_type", [ + # ItemType.DATA_PIPELINE, ItemType.ENVIRONMENT, ItemType.EVENTSTREAM, + # ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET, ItemType.ML_EXPERIMENT, + # ItemType.NOTEBOOK, ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, + # ]) + # @pytest.mark.parametrize("metadata_to_set", ["description", "displayName"]) + # def test_set_item_metadata_for_all_types_success( + # self, + # item_factory, + # cli_executor, + # mock_questionary_print, + # mock_print_done, + # upsert_item_to_cache, + # metadata_to_set, + # item_type, + # vcr_instance, + # cassette_name, + # ): + # # Setup + # item = item_factory(item_type) + # should_upsert_to_cache = metadata_to_set == "displayName" + # + # self._test_set_metadata_success( + # item, + # mock_questionary_print, + # mock_print_done, + # upsert_item_to_cache, + # metadata_to_set, + # cli_executor, + # vcr_instance, + # cassette_name, + # should_upsert_to_cache, + # ) + def test_set_item_report_definition_semantic_model_id_success( self, item_factory, @@ -122,7 +206,8 @@ def test_set_item_report_definition_semantic_model_id_success( mock_print_done.assert_called_once() mock_upsert_item_to_cache.assert_not_called() get(report.full_path, query=property_path) - assert new_semantic_model_id in str(mock_questionary_print.call_args[0][0]) + assert new_semantic_model_id in str( + mock_questionary_print.call_args[0][0]) def test_set_item_variable_library_properties_success( self, @@ -152,10 +237,42 @@ def test_set_item_variable_library_properties_success( # Verify the property was set correctly get(variable_library.full_path, query="properties.activeValueSetName") - assert "Default value set" in str(mock_questionary_print.call_args[0][0]) + assert "Default value set" in str( + mock_questionary_print.call_args[0][0]) # endregion + # def test_set_domain_contributors_scope_success( + # self, + # virtual_workspace_item_factory, + # cli_executor, + # mock_questionary_print, + # mock_print_done, + # setup_config_values_for_capacity, + # upsert_domain_to_cache, + # ): + # # Setup + # domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) + + # # Reset mocks + # mock_questionary_print.reset_mock() + # mock_print_done.reset_mock() + # if upsert_domain_to_cache: + # upsert_domain_to_cache.reset_mock() + + # # Execute command + # cli_executor.exec_command( + # f"set {domain.full_path} --query contributorsScope --input AdminsOnly --force" + # ) + + # # Assert + # mock_print_done.assert_called_once() + # if upsert_domain_to_cache: + # upsert_domain_to_cache.assert_not_called() + + # get(domain.full_path, query="contributorsScope") + # assert mock_questionary_print.call_args[0][0].lower() == "adminsonly" + # region Workspace def test_set_workspace_invalid_query_failure( self, @@ -232,7 +349,8 @@ def test_set_workspace_success( mock_print_done.assert_called_once() get(workspace.full_path, query=metadata_to_set) - assert mock_questionary_print.call_args[0][0].lower() == input_value.lower() + assert mock_questionary_print.call_args[0][0].lower( + ) == input_value.lower() # endregion @@ -289,7 +407,8 @@ def test_set_sparkpool_success( ): # Setting maxNodeCount to 3 to be able to set minNodeCount to 2/3 since minNodeCount should be less than or equal to maxNodeCount sparkpool = virtual_item_factory( - VirtualItemContainerType.SPARK_POOL, params=["autoScale.maxNodeCount=3"] + VirtualItemContainerType.SPARK_POOL, params=[ + "autoScale.maxNodeCount=3"] ) self._test_set_metadata_success( @@ -318,7 +437,8 @@ def test_set_capacity_invalid_query_failure( setup_config_values_for_capacity, ): # Setup - capacity = virtual_workspace_item_factory(VirtualWorkspaceType.CAPACITY) + capacity = virtual_workspace_item_factory( + VirtualWorkspaceType.CAPACITY) # Reset mocks mock_questionary_print.reset_mock() @@ -346,7 +466,8 @@ def test_set_capacity_success( setup_config_values_for_capacity, ): # Setup - capacity = virtual_workspace_item_factory(VirtualWorkspaceType.CAPACITY) + capacity = virtual_workspace_item_factory( + VirtualWorkspaceType.CAPACITY) # Reset mocks mock_questionary_print.reset_mock() @@ -489,7 +610,8 @@ def test_set_connection_displayName_success( cassette_name, ): # Setup - connection = virtual_workspace_item_factory(VirtualWorkspaceType.CONNECTION) + connection = virtual_workspace_item_factory( + VirtualWorkspaceType.CONNECTION) # Reset mocks mock_questionary_print.reset_mock() @@ -503,7 +625,8 @@ def test_set_connection_displayName_success( f"set {connection.full_path} --query {query} --input {input} --force" ) - full_path_new = connection.full_path.replace(connection.display_name, input) + full_path_new = connection.full_path.replace( + connection.display_name, input) # Assert mock_print_done.assert_called_once() @@ -800,7 +923,8 @@ def test_virtual_item_not_supported_failure( mock_print_done, ): # Setup - virtual_item = virtual_item_factory(VirtualItemContainerType.MANAGED_IDENTITY) + virtual_item = virtual_item_factory( + VirtualItemContainerType.MANAGED_IDENTITY) # Reset mocks mock_questionary_print.reset_mock() @@ -863,7 +987,8 @@ def _test_set_metadata_success( if metadata_to_set == "displayName" or metadata_to_set == "name": new_entity = EntityMetadata( display_name=new_metadata_value, - name=entity.name.replace(entity.display_name, new_metadata_value), + name=entity.name.replace( + entity.display_name, new_metadata_value), full_path=entity.full_path.replace( entity.display_name, new_metadata_value ), @@ -871,14 +996,16 @@ def _test_set_metadata_success( with pytest.raises(FabricCLIError) as ex: get(entity.full_path) - assert ex.value.status_code in (constant.ERROR_NOT_FOUND, "EntityNotFound") + assert ex.value.status_code in ( + constant.ERROR_NOT_FOUND, "EntityNotFound") get(new_entity.full_path, query=metadata_to_set) assert mock_questionary_print.call_args[0][0] == new_metadata_value # Clean up - update the full path of the renamed entities so the factory can clean them up if metadata_to_set == "displayName": - set(new_entity.full_path, query="displayName", input=entity.display_name) + set(new_entity.full_path, query="displayName", + input=entity.display_name) elif metadata_to_set == "name": set(new_entity.full_path, query="name", input=entity.display_name) diff --git a/tests/test_commands/test_unassign.py b/tests/test_commands/test_unassign.py index 23deeafe..eceb4ea9 100644 --- a/tests/test_commands/test_unassign.py +++ b/tests/test_commands/test_unassign.py @@ -4,6 +4,8 @@ import argparse from unittest.mock import patch +import pytest + import fabric_cli.commands.fs.fab_fs_assign as fab_assign import fabric_cli.commands.fs.fab_fs_unassign as fab_unassign from fabric_cli.commands.fs import fab_fs_get @@ -14,6 +16,123 @@ class TestUnassign: + # region Parametrized Tests + # @pytest.mark.parametrize("entity_type,factory_key,path_template,assertion_key", [ + # (VirtualWorkspaceType.CAPACITY, "test_data", "/.capacities/{}.Capacity", "id"), + # (VirtualWorkspaceType.DOMAIN, "virtual_workspace_item_factory", "{}.full_path", "display_name"), + # ]) + # def test_unassign_entity_workspace_success( + # self, + # entity_type, + # factory_key, + # path_template, + # assertion_key, + # workspace_factory, + # cli_executor, + # mock_questionary_print, + # test_data: StaticTestData, + # virtual_workspace_item_factory, + # ): + # # Setup + # workspace = workspace_factory() + # mock_questionary_print.reset_mock() + + # if factory_key == "test_data": + # # Capacity scenario + # entity_path = path_template.format(test_data.capacity.name) + # assertion_value = getattr(test_data.capacity, assertion_key) + # else: + # # Domain scenario + # domain = virtual_workspace_item_factory(entity_type) + # assign(domain.full_path, workspace.full_path) + # entity_path = domain.full_path + # assertion_value = getattr(domain, assertion_key) + + # # Execute command + # cli_executor.exec_command( + # f"unassign {entity_path} --workspace {workspace.full_path} --force" + # ) + + # # Assert + # if entity_type == VirtualWorkspaceType.CAPACITY: + # get(workspace.full_path, query=".") + # else: + # get(entity_path, query="domainWorkspaces") + # + # assert any( + # str(assertion_value) not in str(call.args[0]) + # for call in mock_questionary_print.mock_calls + # ) + + # @pytest.mark.parametrize("entity_type,factory_key,path_template", [ + # (VirtualWorkspaceType.CAPACITY, "test_data", "/.capacities/{}.Capacity"), + # (VirtualWorkspaceType.DOMAIN, "virtual_workspace_item_factory", "{}.full_path"), + # ]) + # def test_unassign_entity_workspace_not_assigned_failure( + # self, + # entity_type, + # factory_key, + # path_template, + # workspace_factory, + # cli_executor, + # assert_fabric_cli_error, + # test_data: StaticTestData, + # virtual_workspace_item_factory, + # ): + # # Setup + # workspace = workspace_factory() + # + # if factory_key == "test_data": + # # Capacity scenario - ensure it's unassigned first + # entity_path = path_template.format(test_data.capacity.name) + # unassign(entity_path, workspace.full_path) + # else: + # # Domain scenario - just create domain without assigning + # domain = virtual_workspace_item_factory(entity_type) + # entity_path = domain.full_path + + # # Execute command + # cli_executor.exec_command( + # f"unassign {entity_path} --workspace {workspace.full_path} --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) + + # @pytest.mark.parametrize("entity_type,factory_key,path_template", [ + # (VirtualWorkspaceType.CAPACITY, "test_data", "/.capacities/{}.Capacity"), + # (VirtualWorkspaceType.DOMAIN, "virtual_workspace_item_factory", "{}.full_path"), + # ]) + # def test_unassign_entity_item_not_supported_failure( + # self, + # entity_type, + # factory_key, + # path_template, + # item_factory, + # cli_executor, + # assert_fabric_cli_error, + # test_data: StaticTestData, + # virtual_workspace_item_factory, + # ): + # # Setup + # lakehouse = item_factory(ItemType.LAKEHOUSE) + # + # if factory_key == "test_data": + # entity_path = path_template.format(test_data.capacity.name) + # else: + # domain = virtual_workspace_item_factory(entity_type) + # entity_path = domain.full_path + + # # Execute command + # cli_executor.exec_command( + # f"unassign {entity_path} --workspace {lakehouse.full_path} --force" + # ) + + # # Assert + # assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) + + # endregion + # region CAPACITY TESTS def test_unassign_capacity_workspace_success( self, @@ -107,113 +226,6 @@ def test_unassign_capacity_workspace_without_force_cancel_operation_success( for call in mock_questionary_print.mock_calls ) - def test_unassign_capacity_workspace_not_assigned_failure( - self, - workspace_factory, - cli_executor, - assert_fabric_cli_error, - test_data: StaticTestData, - ): - # Setup - workspace = workspace_factory() - capacity_full_path = f"/.capacities/{test_data.capacity.name}.Capacity" - unassign(capacity_full_path, workspace.full_path) - - # Execute command - cli_executor.exec_command( - f"unassign {capacity_full_path} --workspace {workspace.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) - - def test_unassign_capacity_item_not_supported_failure( - self, - item_factory, - cli_executor, - assert_fabric_cli_error, - test_data: StaticTestData, - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - capacity_full_path = f"/.capacities/{test_data.capacity.name}.Capacity" - - # Execute command - cli_executor.exec_command( - f"unassign {capacity_full_path} --workspace {lakehouse.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) - - # endregion - - # region DOMAIN TESTS - def test_unassign_domain_workspace_success( - self, - workspace_factory, - cli_executor, - virtual_workspace_item_factory, - mock_questionary_print, - ): - # Setup - workspace = workspace_factory() - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - assign(domain.full_path, workspace.full_path) - mock_questionary_print.reset_mock() - - # Execute command - cli_executor.exec_command( - f"unassign {domain.full_path} --workspace {workspace.full_path} --force" - ) - - # Assert - get(domain.full_path, query="domainWorkspaces") - assert any( - workspace.display_name not in call.args[0] - for call in mock_questionary_print.mock_calls - ) - - def test_unassign_domain_workspace_not_assigned_failure( - self, - workspace_factory, - cli_executor, - virtual_workspace_item_factory, - mock_questionary_print, - assert_fabric_cli_error, - ): - # Setup - workspace = workspace_factory() - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - mock_questionary_print.reset_mock() - - # Execute command - cli_executor.exec_command( - f"unassign {domain.full_path} --workspace {workspace.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_INVALID_INPUT) - - def test_unassign_domain_item_not_supported_failure( - self, - item_factory, - cli_executor, - virtual_workspace_item_factory, - assert_fabric_cli_error, - ): - # Setup - lakehouse = item_factory(ItemType.LAKEHOUSE) - domain = virtual_workspace_item_factory(VirtualWorkspaceType.DOMAIN) - - # Execute command - cli_executor.exec_command( - f"unassign {domain.full_path} --workspace {lakehouse.full_path} --force" - ) - - # Assert - assert_fabric_cli_error(constant.ERROR_NOT_SUPPORTED) - # endregion