Skip to content
Draft
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
39 changes: 26 additions & 13 deletions tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
ItemType.REFLEX, ItemType.REPORT,
ItemType.SQL_DATABASE, ItemType.SEMANTIC_MODEL,
ItemType.SPARK_JOB_DEFINITION, ItemType.WAREHOUSE, ItemType.COPYJOB,
ItemType.GRAPHQLAPI, ItemType.DATAFLOW,
ItemType.GRAPHQLAPI, ItemType.DATAFLOW, ItemType.COSMOS_DB_DATABASE,
ItemType.USER_DATA_FUNCTION, ItemType.GRAPH_QUERY_SET, ItemType.DIGITAL_TWIN_BUILDER
])

basic_item_parametrize = pytest.mark.parametrize("item_type", [
Expand Down Expand Up @@ -267,7 +268,8 @@ def workspace(vcr_instance, test_data):
workspace_name = f"{display_name}.Workspace"
workspace_path = f"/{workspace_name}"

mkdir(workspace_path, params=[f"capacityName={test_data.capacity.name}"])
mkdir(workspace_path, params=[
f"capacityName={test_data.capacity.name}"])
yield EntityMetadata(display_name, workspace_name, workspace_path)
rm(workspace_path)

Expand All @@ -292,7 +294,8 @@ def _create_item(
generated_name = custom_name
else:
# Use the test's specific recording file
generated_name = generate_random_string(vcr_instance, cassette_name)
generated_name = generate_random_string(
vcr_instance, cassette_name)

item_name = f"{generated_name}.{type}"
item_path = cli_path_join(path, item_name)
Expand All @@ -318,7 +321,8 @@ def _create_item(
@pytest.fixture
def folder_factory(vcr_instance, cassette_name, workspace):
# Keep track of all folders created during this test
current_config = state_config.get_config(fab_constant.FAB_FOLDER_LISTING_ENABLED)
current_config = state_config.get_config(
fab_constant.FAB_FOLDER_LISTING_ENABLED)
state_config.set_config(fab_constant.FAB_FOLDER_LISTING_ENABLED, "true")
created_folders = []

Expand Down Expand Up @@ -348,7 +352,8 @@ def _create_folder(
for metadata in reversed(created_folders):
rm(metadata.full_path)

state_config.set_config(fab_constant.FAB_FOLDER_LISTING_ENABLED, current_config)
state_config.set_config(
fab_constant.FAB_FOLDER_LISTING_ENABLED, current_config)


@pytest.fixture
Expand All @@ -374,7 +379,8 @@ def _create_virtual_item(
"""
generated_name = generate_random_string(vcr_instance, cassette_name)
virtual_item_name = f"{generated_name}.{str(VICMap[type])}"
virtual_item_path = cli_path_join(workspace_path, str(type), virtual_item_name)
virtual_item_path = cli_path_join(
workspace_path, str(type), virtual_item_name)

match type:

Expand Down Expand Up @@ -427,7 +433,8 @@ def _create_virtual_item(
mkdir(virtual_item_path, params)

# Build the metadata for the created resource
metadata = EntityMetadata(generated_name, virtual_item_name, virtual_item_path)
metadata = EntityMetadata(
generated_name, virtual_item_name, virtual_item_path)
if should_clean:
created_virtual_items.append(metadata)
return metadata
Expand Down Expand Up @@ -457,10 +464,12 @@ def _create_workspace(special_character=None):
workspace_name = f"{generated_name}.Workspace"
workspace_path = f"/{workspace_name}"

mkdir(workspace_path, params=[f"capacityName={test_data.capacity.name}"])
mkdir(workspace_path, params=[
f"capacityName={test_data.capacity.name}"])

# Build the metadata for the created resource
metadata = EntityMetadata(generated_name, workspace_name, workspace_path)
metadata = EntityMetadata(
generated_name, workspace_name, workspace_path)
created_workspaces.append(metadata)
return metadata

Expand Down Expand Up @@ -565,7 +574,8 @@ def delete_cassette_if_record_mode_all(vcr_instance, cassette_name):
:param cassette_name: The name of the cassette file.
"""
if vcr_instance.record_mode == "all":
cassette_path = os.path.join(vcr_instance.cassette_library_dir, cassette_name)
cassette_path = os.path.join(
vcr_instance.cassette_library_dir, cassette_name)
if os.path.exists(cassette_path):
os.remove(cassette_path)

Expand Down Expand Up @@ -673,7 +683,8 @@ def setup_config_values_for_capacity(test_data: StaticTestData):
fab_default_az_location = state_config.get_config(
fab_constant.FAB_DEFAULT_AZ_LOCATION
)
fab_default_az_admin = state_config.get_config(fab_constant.FAB_DEFAULT_AZ_ADMIN)
fab_default_az_admin = state_config.get_config(
fab_constant.FAB_DEFAULT_AZ_ADMIN)

# Setup new values
state_config.set_config(
Expand All @@ -687,7 +698,8 @@ def setup_config_values_for_capacity(test_data: StaticTestData):
state_config.set_config(
fab_constant.FAB_DEFAULT_AZ_LOCATION, test_data.azure_location
)
state_config.set_config(fab_constant.FAB_DEFAULT_AZ_ADMIN, test_data.admin.upn)
state_config.set_config(
fab_constant.FAB_DEFAULT_AZ_ADMIN, test_data.admin.upn)

yield

Expand All @@ -701,7 +713,8 @@ def setup_config_values_for_capacity(test_data: StaticTestData):
state_config.set_config(
fab_constant.FAB_DEFAULT_AZ_LOCATION, fab_default_az_location
)
state_config.set_config(fab_constant.FAB_DEFAULT_AZ_ADMIN, fab_default_az_admin)
state_config.set_config(
fab_constant.FAB_DEFAULT_AZ_ADMIN, fab_default_az_admin)


# endregion
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.3.1 (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:
- '2271'
- '2706'
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:25:59 GMT
- Wed, 04 Feb 2026 07:21:13 GMT
Pragma:
- no-cache
RequestId:
- 9a1d433a-9ac2-4f88-a9fa-8e3002bee303
- f9774573-0719-4ec8-9930-c1450c6e00b2
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.3.1 (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:
- '2271'
- '2706'
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:26:01 GMT
- Wed, 04 Feb 2026 07:21:14 GMT
Pragma:
- no-cache
RequestId:
- c1128cf5-1b4b-4bdf-b8a4-0e1322816fcf
- 2161396c-a1c4-4170-b54d-ec4554b43d12
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.3.1 (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": "F32", "region": "Central US", "state":
"mocked_fabriccli_capacity_name", "sku": "F16", "region": "Central US", "state":
"Active"}]}'
headers:
Access-Control-Expose-Headers:
Expand All @@ -129,11 +129,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:26:07 GMT
- Wed, 04 Feb 2026 07:21:18 GMT
Pragma:
- no-cache
RequestId:
- ae3db333-4428-4f82-91ef-2ca7417189a3
- 5aac4f35-60c5-404d-aa18-d80dc8b91373
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.3.1 (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": "7d331fef-1f2a-406b-8eb9-b4776069f5f6", "displayName": "fabriccli_WorkspacePerTestclass_000001",
string: '{"id": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e", "displayName": "fabriccli_WorkspacePerTestclass_000001",
"description": "Created by fab", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}'
headers:
Access-Control-Expose-Headers:
Expand All @@ -181,13 +181,13 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:26:15 GMT
- Wed, 04 Feb 2026 07:21:26 GMT
Location:
- https://api.fabric.microsoft.com/v1/workspaces/7d331fef-1f2a-406b-8eb9-b4776069f5f6
- https://api.fabric.microsoft.com/v1/workspaces/2624caf6-b51d-4b9b-a0d7-9da2c6385d0e
Pragma:
- no-cache
RequestId:
- 2fb5aada-3e56-469e-81ea-7cfd11f6c8ca
- 735449eb-267e-48bd-98b8-8253eb2ed014
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.3.1 (set; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (set; 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": "7d331fef-1f2a-406b-8eb9-b4776069f5f6",
"My workspace", "description": "", "type": "Personal"}, {"id": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e",
"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:
- '2304'
- '2738'
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:26:45 GMT
- Wed, 04 Feb 2026 07:24:39 GMT
Pragma:
- no-cache
RequestId:
- 3fc2ca69-e937-45bb-a655-6a15c51801f9
- d77390fc-d9f6-4858-b6fa-80856e1163aa
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -264,12 +264,19 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.3.1 (set; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (set; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces/7d331fef-1f2a-406b-8eb9-b4776069f5f6/items
uri: https://api.fabric.microsoft.com/v1/workspaces/2624caf6-b51d-4b9b-a0d7-9da2c6385d0e/items
response:
body:
string: '{"value": []}'
string: '{"value": [{"id": "5fbb6826-d43e-4818-8c9a-4d421da80c58", "type": "SQLEndpoint",
"displayName": "fabcli000001dtdm", "description": "", "workspaceId": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e"},
{"id": "35558427-c7f1-44d9-bb4a-6c4dc57b9626", "type": "SQLEndpoint", "displayName":
"fabcli000001dtdm", "description": "", "workspaceId": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e"},
{"id": "35433380-c3a1-43f9-bd79-4460e9ebab3c", "type": "Lakehouse", "displayName":
"fabcli000001dtdm", "description": "", "workspaceId": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e"},
{"id": "ac4fcde4-68f2-4ab1-8506-6335e3bef15f", "type": "Lakehouse", "displayName":
"fabcli000001dtdm", "description": "", "workspaceId": "2624caf6-b51d-4b9b-a0d7-9da2c6385d0e"}]}'
headers:
Access-Control-Expose-Headers:
- RequestId
Expand All @@ -278,15 +285,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '32'
- '280'
Content-Type:
- application/json; charset=utf-8
Date:
- Thu, 29 Jan 2026 13:26:44 GMT
- Wed, 04 Feb 2026 07:24:40 GMT
Pragma:
- no-cache
RequestId:
- 63b6aef6-c204-4ff9-8d24-600d0ff3c16b
- b93e1745-52c5-4664-8e41-8636aaa28f98
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -314,9 +321,9 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.3.1 (set; Linux; x86_64; 5.15.167.4-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (set; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: DELETE
uri: https://api.fabric.microsoft.com/v1/workspaces/7d331fef-1f2a-406b-8eb9-b4776069f5f6
uri: https://api.fabric.microsoft.com/v1/workspaces/2624caf6-b51d-4b9b-a0d7-9da2c6385d0e
response:
body:
string: ''
Expand All @@ -332,11 +339,11 @@ interactions:
Content-Type:
- application/octet-stream
Date:
- Thu, 29 Jan 2026 13:26:45 GMT
- Wed, 04 Feb 2026 07:24:41 GMT
Pragma:
- no-cache
RequestId:
- 9af3be0d-fe6f-4148-a2fa-0ce178a1a3fc
- a982696d-bb52-4be4-8d26-8675b696085b
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down
Loading
Loading