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
42 changes: 28 additions & 14 deletions tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@
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.DIGITAL_TWIN_BUILDER, ItemType.GRAPH_QUERY_SET,
])

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,
ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION, ItemType.COSMOS_DB_DATABASE,
ItemType.USER_DATA_FUNCTION, ItemType.DIGITAL_TWIN_BUILDER, ItemType.GRAPH_QUERY_SET,
])

FILTER_HEADERS = [
Expand Down Expand Up @@ -267,7 +269,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 +295,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 +322,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 +353,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 +380,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 +434,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 +465,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 +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; 6.6.87.2-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:
- '1517'
- '2804'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:28:59 GMT
- Thu, 05 Feb 2026 13:47:43 GMT
Pragma:
- no-cache
RequestId:
- a1ca655d-adf4-4a7a-8d2c-2dc3ab03e53b
- f0052e9a-2035-4c48-9c4a-0d3d62e599bc
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; 6.6.87.2-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:
- '1517'
- '2804'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:29:00 GMT
- Thu, 05 Feb 2026 13:47:44 GMT
Pragma:
- no-cache
RequestId:
- 4fb405d9-466a-4e9d-81f3-a61091331c8a
- 756493bd-ef07-4d0c-9c65-89853d68f65d
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; 6.6.87.2-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'
- '425'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:29:05 GMT
- Thu, 05 Feb 2026 13:47:48 GMT
Pragma:
- no-cache
RequestId:
- 9a962d92-07ed-4680-97dc-c07909f25e22
- 62f562de-f200-4dc4-bf3f-03c560a8af30
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; 6.6.87.2-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": "7b82ecee-ed54-4d87-84dd-07511c5f5ad2", "displayName": "fabriccli_WorkspacePerTestclass_000001",
string: '{"id": "375e6fae-c43c-47f5-8deb-55ee3c76aa27", "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:
- '189'
- '188'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:29:14 GMT
- Thu, 05 Feb 2026 13:47:57 GMT
Location:
- https://api.fabric.microsoft.com/v1/workspaces/7b82ecee-ed54-4d87-84dd-07511c5f5ad2
- https://api.fabric.microsoft.com/v1/workspaces/375e6fae-c43c-47f5-8deb-55ee3c76aa27
Pragma:
- no-cache
RequestId:
- a9920ffb-8339-43a8-8f5b-ab313cafb507
- ed0c7c7d-6957-4fe5-b794-961027e6ea12
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 (None; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces
response:
body:
string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName":
"My workspace", "description": "", "type": "Personal"}, {"id": "7b82ecee-ed54-4d87-84dd-07511c5f5ad2",
"My workspace", "description": "", "type": "Personal"}, {"id": "375e6fae-c43c-47f5-8deb-55ee3c76aa27",
"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:
- '1551'
- '2834'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:29:43 GMT
- Thu, 05 Feb 2026 13:49:13 GMT
Pragma:
- no-cache
RequestId:
- 760e6315-8597-44fc-807f-62840e999e08
- d70b259c-e51b-4ef7-950f-789c6e75bff9
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand All @@ -264,14 +264,12 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces/7b82ecee-ed54-4d87-84dd-07511c5f5ad2/items
uri: https://api.fabric.microsoft.com/v1/workspaces/375e6fae-c43c-47f5-8deb-55ee3c76aa27/items
response:
body:
string: '{"value": [{"id": "2d69f214-7721-41c3-a595-1ac4960a7215", "type": "Notebook",
"displayName": "fabcli000001", "description": "Created by fab", "workspaceId":
"7b82ecee-ed54-4d87-84dd-07511c5f5ad2"}]}'
string: '{"value": []}'
headers:
Access-Control-Expose-Headers:
- RequestId
Expand All @@ -280,15 +278,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '176'
- '32'
Content-Type:
- application/json; charset=utf-8
Date:
- Sun, 16 Nov 2025 13:29:44 GMT
- Thu, 05 Feb 2026 13:49:13 GMT
Pragma:
- no-cache
RequestId:
- 8f711d74-2ab1-4d92-9c00-f90f31843fe1
- 25b1390a-92be-4f5b-83f7-e231565e031d
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -316,9 +314,9 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ms-fabric-cli/1.1.0 (None; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
- ms-fabric-cli/1.3.1 (ls; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: DELETE
uri: https://api.fabric.microsoft.com/v1/workspaces/7b82ecee-ed54-4d87-84dd-07511c5f5ad2
uri: https://api.fabric.microsoft.com/v1/workspaces/375e6fae-c43c-47f5-8deb-55ee3c76aa27
response:
body:
string: ''
Expand All @@ -334,11 +332,11 @@ interactions:
Content-Type:
- application/octet-stream
Date:
- Sun, 16 Nov 2025 13:29:45 GMT
- Thu, 05 Feb 2026 13:49:14 GMT
Pragma:
- no-cache
RequestId:
- 87dce47d-17c3-48d7-8046-89b2600e75b1
- 1e8f8194-12d7-4c56-a97a-f97bf24c95a2
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down
Loading
Loading