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
90 changes: 77 additions & 13 deletions tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)
from tests.test_commands.utils import cli_path_join, set_vcr_mode_env

custom_parametrize = pytest.mark.parametrize("item_type", [
item_type_paramerter = pytest.mark.parametrize("item_type", [
ItemType.DATA_PIPELINE,
ItemType.ENVIRONMENT, ItemType.EVENTHOUSE, ItemType.EVENTSTREAM,
ItemType.KQL_DASHBOARD, ItemType.KQL_QUERYSET,
Expand All @@ -60,6 +60,58 @@
ItemType.REFLEX, ItemType.SPARK_JOB_DEFINITION,
])

# Export command parametrizations
export_item_with_extension_parameters = pytest.mark.parametrize("item_type,expected_file_extension", [
(ItemType.NOTEBOOK, ".ipynb"),
(ItemType.SPARK_JOB_DEFINITION, ".json"),
(ItemType.DATA_PIPELINE, ".json"),
(ItemType.MIRRORED_DATABASE, ".json"),
(ItemType.COSMOS_DB_DATABASE, ".json"),
(ItemType.USER_DATA_FUNCTION, ".json"),
(ItemType.GRAPH_QUERY_SET, ".json")
])

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

export_item_format_parameters = pytest.mark.parametrize("item_type,export_format,expected_file_extension", [
(ItemType.NOTEBOOK, ".py", ".py"),
(ItemType.NOTEBOOK, ".ipynb", ".ipynb")
])

export_item_default_format_parameters = 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),
(ItemType.COSMOS_DB_DATABASE, 2),
(ItemType.USER_DATA_FUNCTION, 2),
(ItemType.GRAPH_QUERY_SET, 2)
])

export_item_invalid_format_parameters = 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"),
(ItemType.COSMOS_DB_DATABASE, ".txt", "No formats are supported"),
(ItemType.USER_DATA_FUNCTION, ".txt", "No formats are supported"),
(ItemType.GRAPH_QUERY_SET, ".txt", "No formats are supported")
])

FILTER_HEADERS = [
"authorization",
"client-request-id",
Expand Down Expand Up @@ -267,7 +319,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 +345,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 +372,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 +403,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 +430,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 +484,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 +515,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 +625,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 +734,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 +749,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 +764,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 @@ -26,15 +26,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '1192'
- '2771'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 23 Dec 2025 11:30:37 GMT
- Fri, 06 Feb 2026 11:29:54 GMT
Pragma:
- no-cache
RequestId:
- 8ad97a30-5906-4171-83e8-74d61cf60b98
- 25370ffe-1798-4bec-ba8c-f00a36634497
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -75,15 +75,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '1192'
- '2771'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 23 Dec 2025 11:30:39 GMT
- Fri, 06 Feb 2026 11:29:54 GMT
Pragma:
- no-cache
RequestId:
- c4462b24-6089-4c0d-89bd-25b7decab5ba
- 168455dd-c065-4342-adee-bb7aaad2f78d
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -115,7 +115,7 @@ interactions:
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:
- '871'
- '424'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 23 Dec 2025 11:30:45 GMT
- Fri, 06 Feb 2026 11:30:00 GMT
Pragma:
- no-cache
RequestId:
- 1d1d9593-4ace-48a5-aab1-4e52e2329d33
- 6c094039-19d0-4e5e-a012-6d90c3070203
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -167,7 +167,7 @@ interactions:
uri: https://api.fabric.microsoft.com/v1/workspaces
response:
body:
string: '{"id": "a4843949-27b0-40ce-bbca-d5498698e0f1", "displayName": "fabriccli_WorkspacePerTestclass_000001",
string: '{"id": "cf67653a-969e-41c3-836d-a8c16eb9404d", "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:
- Tue, 23 Dec 2025 11:30:53 GMT
- Fri, 06 Feb 2026 11:30:09 GMT
Location:
- https://api.fabric.microsoft.com/v1/workspaces/a4843949-27b0-40ce-bbca-d5498698e0f1
- https://api.fabric.microsoft.com/v1/workspaces/cf67653a-969e-41c3-836d-a8c16eb9404d
Pragma:
- no-cache
RequestId:
- 8f191dd1-0890-4566-b70f-57baf75fb262
- 37f38b0a-6ce6-4e2c-8cf9-ffad70df194d
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -219,7 +219,7 @@ interactions:
response:
body:
string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName":
"My workspace", "description": "", "type": "Personal"}, {"id": "a4843949-27b0-40ce-bbca-d5498698e0f1",
"My workspace", "description": "", "type": "Personal"}, {"id": "cf67653a-969e-41c3-836d-a8c16eb9404d",
"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:
- '1226'
- '2806'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 23 Dec 2025 11:31:53 GMT
- Fri, 06 Feb 2026 11:55:04 GMT
Pragma:
- no-cache
RequestId:
- 6f118d47-f742-426b-ac69-76a5bbee5b9f
- 5e77c57c-1459-4a5f-bed0-0f31543e327f
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -266,11 +266,21 @@ interactions:
User-Agent:
- ms-fabric-cli/1.3.1 (export; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces/a4843949-27b0-40ce-bbca-d5498698e0f1/items
uri: https://api.fabric.microsoft.com/v1/workspaces/cf67653a-969e-41c3-836d-a8c16eb9404d/items
response:
body:
string: '{"value": [{"id": "b827b069-1573-4288-9964-8415956062ef", "type": "SemanticModel",
"displayName": "fabcli000001_auto", "description": "", "workspaceId": "a4843949-27b0-40ce-bbca-d5498698e0f1"}]}'
string: '{"value": [{"id": "94d8e448-add6-49fc-a93e-932eb195dea7", "type": "SemanticModel",
"displayName": "fabcli000001_auto", "description": "", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"},
{"id": "a1266542-c1e2-4ba3-887c-550c530ad38a", "type": "SemanticModel", "displayName":
"fabcli000001_auto", "description": "", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"},
{"id": "82a052a8-1f8f-4242-9fb4-1b2b85c7a11e", "type": "Eventhouse", "displayName":
"fabcli000001_auto", "description": "Created by fab", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"},
{"id": "f8fc2d91-77e7-47f5-9562-4b53f61ae155", "type": "KQLDatabase", "displayName":
"fabcli000001_auto", "description": "fabcli000001_auto", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"},
{"id": "a61b0bae-edfa-43df-b591-f811582c3795", "type": "Eventhouse", "displayName":
"fabcli000001_auto", "description": "Created by fab", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"},
{"id": "0da8e632-1608-4352-bc3a-32781190fa42", "type": "KQLDatabase", "displayName":
"fabcli000001_auto", "description": "fabcli000001_auto", "workspaceId": "cf67653a-969e-41c3-836d-a8c16eb9404d"}]}'
headers:
Access-Control-Expose-Headers:
- RequestId
Expand All @@ -279,15 +289,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '175'
- '387'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 23 Dec 2025 11:31:55 GMT
- Fri, 06 Feb 2026 11:55:04 GMT
Pragma:
- no-cache
RequestId:
- e42ff689-c578-4ecc-91c3-93c1949d11a0
- a56e9b75-42e8-4d08-95f8-b337b1380342
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -317,7 +327,7 @@ interactions:
User-Agent:
- ms-fabric-cli/1.3.1 (export; Linux; x86_64; 6.6.87.2-microsoft-standard-WSL2)
method: DELETE
uri: https://api.fabric.microsoft.com/v1/workspaces/a4843949-27b0-40ce-bbca-d5498698e0f1
uri: https://api.fabric.microsoft.com/v1/workspaces/cf67653a-969e-41c3-836d-a8c16eb9404d
response:
body:
string: ''
Expand All @@ -333,11 +343,11 @@ interactions:
Content-Type:
- application/octet-stream
Date:
- Tue, 23 Dec 2025 11:31:57 GMT
- Fri, 06 Feb 2026 11:55:05 GMT
Pragma:
- no-cache
RequestId:
- 7b1603a3-54f4-4f0a-baa4-4947902f7baf
- 29cdc8b5-256b-457a-9b08-7cf7e7f20090
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down
Loading