Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@
(ItemType.GRAPH_QUERY_SET, ".txt", "No formats are supported")
])

cp_virtual_workspace_item_failure_params = pytest.mark.parametrize("virtual_workspace_type", [
VirtualWorkspaceType.DOMAIN,
VirtualWorkspaceType.CAPACITY,
VirtualWorkspaceType.GATEWAY,
])

cp_item_types_success_params = 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,
ItemType.COSMOS_DB_DATABASE, ItemType.USER_DATA_FUNCTION,
])

FILTER_HEADERS = [
"authorization",
"client-request-id",
Expand Down Expand Up @@ -533,7 +546,10 @@ def _create_workspace(special_character=None):

@pytest.fixture
def virtual_workspace_item_factory(
vcr_instance, cassette_name, test_data: StaticTestData
vcr_instance,
cassette_name,
test_data: StaticTestData,
vcr_mode,
):
# Keep track of all workspaces created during this test
created_virtual_workspace_items = []
Expand Down Expand Up @@ -566,13 +582,16 @@ def _create_virtual_workspace_item(type: VirtualWorkspaceType):
metadata = EntityMetadata(
generated_name, virtual_workspace_name, virtual_workspace_item_path
)
metadata.type = type
created_virtual_workspace_items.append(metadata)
return metadata

yield _create_virtual_workspace_item

# Teardown: remove everything we created during the test
for metadata in created_virtual_workspace_items:
if vcr_mode == "none" and metadata.type == VirtualWorkspaceType.CAPACITY:
continue
rm(metadata.full_path)


Expand Down
25 changes: 21 additions & 4 deletions tests/test_commands/data/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

from typing import Any


class User:
def __init__(self, user_data: dict[str, str]):
# Expecting keys: "id", "upn"
Expand Down Expand Up @@ -56,10 +59,13 @@ def name(self) -> str:


class EntityMetadata:
def __init__(self, display_name: str, name: str, full_path: str):
def __init__(
self, display_name: str, name: str, full_path: str, type: Any = None
):
self._display_name = display_name
self._name = name
self._full_path = full_path
self._type = type

@property
def display_name(self) -> str:
Expand All @@ -75,9 +81,18 @@ def full_path(self) -> str:

# This setter is required for the mv command
@full_path.setter
def full_path(self, new_path):
def full_path(self, new_path: str) -> None:
self._full_path = new_path

@property
def type(self) -> Any:
return self._type

# This setter is required for cleanup during test teardown
@type.setter
def type(self, value: Any) -> None:
self._type = value


class SQLServer:
def __init__(self, sql_server_data: dict[str, str]):
Expand Down Expand Up @@ -123,16 +138,18 @@ def username(self) -> str:
def password(self) -> str:
return self._password


class OnPremisesGatewayDetails:
def __init__(self, gateway_data: dict[str, str]):
# Expecting keys: "id", "encrypted_credentials"
self._id = gateway_data.get("id") or ""
self._encrypted_credentials = gateway_data.get("encrypted_credentials") or ""
self._encrypted_credentials = gateway_data.get(
"encrypted_credentials") or ""

@property
def id(self) -> str:
return self._id

@property
def encrypted_credentials(self) -> str:
return self._encrypted_credentials
return self._encrypted_credentials
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; 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:
Expand All @@ -26,15 +26,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '818'
- '2771'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:13:58 GMT
- Fri, 06 Feb 2026 07:06:19 GMT
Pragma:
- no-cache
RequestId:
- 2102248d-7c3d-48dc-b9d0-6c9a88056ae0
- 3aab06b8-f3d5-4db2-a228-3f01423767b3
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -60,7 +60,7 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; 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:
Expand All @@ -75,15 +75,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '818'
- '2771'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:14:00 GMT
- Fri, 06 Feb 2026 07:06:20 GMT
Pragma:
- no-cache
RequestId:
- 9b6586f5-b38c-4aa4-a620-eeb9e6b804a0
- 3285752a-c344-4be1-b840-f41c57a840e3
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -109,13 +109,13 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; 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": "F2", "region": "Central US", "state":
"mocked_fabriccli_capacity_name", "sku": "F16", "region": "Central US", "state":
"Active"}]}'
headers:
Access-Control-Expose-Headers:
Expand All @@ -125,15 +125,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '271'
- '424'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:14:05 GMT
- Fri, 06 Feb 2026 07:06:26 GMT
Pragma:
- no-cache
RequestId:
- a7eb91ea-ff9c-4274-94ad-7ba1fb12d12c
- fc025862-a234-452f-b8d0-8bda23984394
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -162,12 +162,12 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; 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": "08bfc868-2a78-49cd-a320-0ae9101a5ab1", "displayName": "fabriccli_WorkspacePerTestclass_000001",
string: '{"id": "e0c56f4e-e523-4a5a-84b3-0cc7285a0897", "displayName": "fabriccli_WorkspacePerTestclass_000001",
"description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}'
headers:
Access-Control-Expose-Headers:
Expand All @@ -177,17 +177,17 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '188'
- '186'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:14:12 GMT
- Fri, 06 Feb 2026 07:06:33 GMT
Location:
- https://api.fabric.microsoft.com/v1/workspaces/08bfc868-2a78-49cd-a320-0ae9101a5ab1
- https://api.fabric.microsoft.com/v1/workspaces/e0c56f4e-e523-4a5a-84b3-0cc7285a0897
Pragma:
- no-cache
RequestId:
- aca72272-d3d6-4707-9a11-eefc668666c6
- 7a758e47-2adf-48da-aebf-0043feb0485d
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -213,13 +213,13 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (cp; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (cp; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces
response:
body:
string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName":
"My workspace", "description": "", "type": "Personal"}, {"id": "08bfc868-2a78-49cd-a320-0ae9101a5ab1",
"My workspace", "description": "", "type": "Personal"}, {"id": "e0c56f4e-e523-4a5a-84b3-0cc7285a0897",
"displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "Created
by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}'
headers:
Expand All @@ -230,15 +230,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '853'
- '2805'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:15:53 GMT
- Fri, 06 Feb 2026 08:40:01 GMT
Pragma:
- no-cache
RequestId:
- 4bbc73b7-edb2-4065-aa56-3e41f4fd802e
- d99b7bb5-50ec-42bc-bef9-0a1ed567c414
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -264,9 +264,9 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (cp; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (cp; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces/08bfc868-2a78-49cd-a320-0ae9101a5ab1/items
uri: https://api.fabric.microsoft.com/v1/workspaces/e0c56f4e-e523-4a5a-84b3-0cc7285a0897/items
response:
body:
string: '{"value": []}'
Expand All @@ -282,11 +282,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Sep 2025 17:15:53 GMT
- Fri, 06 Feb 2026 08:40:01 GMT
Pragma:
- no-cache
RequestId:
- d6ce2c38-affb-42c8-8a00-806f57ecd641
- a09eadfa-11df-42d9-9aec-7e811e8c6a23
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -314,9 +314,9 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (cp; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (cp; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: DELETE
uri: https://api.fabric.microsoft.com/v1/workspaces/08bfc868-2a78-49cd-a320-0ae9101a5ab1
uri: https://api.fabric.microsoft.com/v1/workspaces/e0c56f4e-e523-4a5a-84b3-0cc7285a0897
response:
body:
string: ''
Expand All @@ -332,11 +332,11 @@ interactions:
Content-Type:
- application/octet-stream
Date:
- Mon, 29 Sep 2025 17:15:53 GMT
- Fri, 06 Feb 2026 08:40:02 GMT
Pragma:
- no-cache
RequestId:
- 99b1c9e4-0b03-4f94-881b-4f01dca557fd
- 3f0b7838-1987-449f-92f8-3bdab6296f6c
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down
Loading