Skip to content
40 changes: 27 additions & 13 deletions tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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 +293,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 +320,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 +351,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 +378,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 +432,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 +463,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 All @@ -473,7 +481,9 @@ 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,
):
# Keep track of all workspaces created during this test
created_virtual_workspace_items = []
Expand Down Expand Up @@ -565,7 +575,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 +684,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 +699,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 +714,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.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
Loading