@typespec/http-client-python 0.27.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/emitter/types.d.ts.map +1 -1
  2. package/dist/emitter/types.js +30 -11
  3. package/dist/emitter/types.js.map +1 -1
  4. package/emitter/src/types.ts +32 -11
  5. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  6. package/eng/scripts/ci/regenerate.ts +13 -3
  7. package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
  8. package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
  9. package/generator/build/lib/pygen/codegen/models/operation.py +5 -1
  10. package/generator/build/lib/pygen/codegen/models/paging_operation.py +5 -1
  11. package/generator/component-detection-pip-report.json +6 -6
  12. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  13. package/generator/pygen/codegen/models/operation.py +5 -1
  14. package/generator/pygen/codegen/models/paging_operation.py +5 -1
  15. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +12 -0
  16. package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_client_initialization_async.py +2 -3
  17. package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py +111 -0
  18. package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_shared_models_async.py +132 -0
  19. package/generator/test/azure/mock_api_tests/asynctests/test_payload_multipart_async.py +30 -0
  20. package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +9 -0
  21. package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_client_initialization.py +2 -3
  22. package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py +107 -0
  23. package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_shared_models.py +128 -0
  24. package/generator/test/azure/mock_api_tests/test_payload_multipart.py +27 -0
  25. package/generator/test/azure/requirements.txt +6 -1
  26. package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +10 -5
  27. package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +9 -0
  28. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_file_async.py +59 -0
  29. package/generator/test/generic_mock_api_tests/test_payload_pageable.py +8 -4
  30. package/generator/test/generic_mock_api_tests/test_payload_xml.py +8 -0
  31. package/generator/test/generic_mock_api_tests/test_typetest_file.py +52 -0
  32. package/generator/test/unbranded/mock_api_tests/asynctests/test_payload_multipart_async.py +31 -0
  33. package/generator/test/unbranded/mock_api_tests/test_payload_multipart.py +28 -0
  34. package/generator/test/unbranded/requirements.txt +1 -0
  35. package/package.json +32 -32
@@ -22,7 +22,7 @@ const argv = parseArgs({
22
22
  });
23
23
 
24
24
  // Add this near the top with other constants
25
- const SKIP_SPECS: string[] = [];
25
+ const SKIP_SPECS: string[] = ["type/file"];
26
26
 
27
27
  // Get the directory of the current file
28
28
  const PLUGIN_DIR = argv.values.pluginDir
@@ -49,8 +49,14 @@ const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<stri
49
49
  "azure/client-generator-core/api-version": {
50
50
  namespace: "specs.azure.clientgenerator.core.apiversion",
51
51
  },
52
- "azure/client-generator-core/client-initialization": {
53
- namespace: "specs.azure.clientgenerator.core.clientinitialization",
52
+ "azure/client-generator-core/client-initialization/default": {
53
+ namespace: "specs.azure.clientgenerator.core.clientinitialization.default",
54
+ },
55
+ "azure/client-generator-core/client-initialization/individually": {
56
+ namespace: "specs.azure.clientgenerator.core.clientinitialization.individually",
57
+ },
58
+ "azure/client-generator-core/client-initialization/individuallyParent": {
59
+ namespace: "specs.azure.clientgenerator.core.clientinitialization.individuallyparent",
54
60
  },
55
61
  "azure/client-generator-core/client-location": {
56
62
  namespace: "specs.azure.clientgenerator.core.clientlocation",
@@ -279,6 +285,10 @@ const EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, st
279
285
  "package-name": "typetest-discriminatedunion",
280
286
  namespace: "typetest.discriminatedunion",
281
287
  },
288
+ "type/file": {
289
+ "package-name": "typetest-file",
290
+ namespace: "typetest.file",
291
+ },
282
292
  documentation: {
283
293
  "package-name": "specs-documentation",
284
294
  namespace: "specs.documentation",
@@ -284,6 +284,10 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
284
284
  def need_deserialize(self) -> bool:
285
285
  return any(r.type and not isinstance(r.type, BinaryIteratorType) for r in self.responses)
286
286
 
287
+ @property
288
+ def enable_import_deserialize_xml(self) -> bool:
289
+ return any(xml_serializable(str(r.default_content_type)) for r in self.responses + self.exceptions)
290
+
287
291
  def imports( # pylint: disable=too-many-branches, disable=too-many-statements
288
292
  self, async_mode: bool, **kwargs: Any
289
293
  ) -> FileImport:
@@ -443,7 +447,7 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
443
447
  ImportType.LOCAL,
444
448
  )
445
449
  file_import.add_import("json", ImportType.STDLIB)
446
- if any(xml_serializable(str(r.default_content_type)) for r in self.responses + self.exceptions):
450
+ if self.enable_import_deserialize_xml:
447
451
  file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
448
452
  elif self.need_deserialize:
449
453
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
@@ -17,6 +17,7 @@ from .parameter_list import ParameterList
17
17
  from .model_type import ModelType
18
18
  from .list_type import ListType
19
19
  from .parameter import Parameter
20
+ from ...utils import xml_serializable
20
21
 
21
22
  if TYPE_CHECKING:
22
23
  from .code_model import CodeModel
@@ -135,6 +136,10 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
135
136
  def has_optional_return_type(self) -> bool:
136
137
  return False
137
138
 
139
+ @property
140
+ def enable_import_deserialize_xml(self):
141
+ return any(xml_serializable(str(r.default_content_type)) for r in self.exceptions)
142
+
138
143
  def imports(self, async_mode: bool, **kwargs: Any) -> FileImport:
139
144
  if self.abstract:
140
145
  return FileImport(self.code_model)
@@ -185,7 +190,6 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
185
190
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
186
191
  if self.is_xml_paging:
187
192
  file_import.add_submodule_import("xml.etree", "ElementTree", ImportType.STDLIB, alias="ET")
188
- file_import.add_submodule_import(relative_path, "_convert_element", ImportType.LOCAL)
189
193
  return file_import
190
194
 
191
195
 
@@ -4,11 +4,11 @@
4
4
  "install": [
5
5
  {
6
6
  "download_info": {
7
- "url": "https://files.pythonhosted.org/packages/94/b8/f1f62a5e3c0ad2ff1d189590bfa4c46b4f3b6e49cef6f26c6ee4e575394d/setuptools-80.10.2-py3-none-any.whl",
7
+ "url": "https://files.pythonhosted.org/packages/e1/c6/76dc613121b793286a3f91621d7b75a2b493e0390ddca50f11993eadf192/setuptools-82.0.0-py3-none-any.whl",
8
8
  "archive_info": {
9
- "hash": "sha256=95b30ddfb717250edb492926c92b5221f7ef3fbcc2b07579bcd4a27da21d0173",
9
+ "hash": "sha256=70b18734b607bd1da571d097d236cfcfacaf01de45717d59e6e04b96877532e0",
10
10
  "hashes": {
11
- "sha256": "95b30ddfb717250edb492926c92b5221f7ef3fbcc2b07579bcd4a27da21d0173"
11
+ "sha256": "70b18734b607bd1da571d097d236cfcfacaf01de45717d59e6e04b96877532e0"
12
12
  }
13
13
  }
14
14
  },
@@ -18,7 +18,7 @@
18
18
  "metadata": {
19
19
  "metadata_version": "2.4",
20
20
  "name": "setuptools",
21
- "version": "80.10.2",
21
+ "version": "82.0.0",
22
22
  "dynamic": [
23
23
  "license-file"
24
24
  ],
@@ -93,11 +93,11 @@
93
93
  "more_itertools; extra == \"core\"",
94
94
  "pytest-checkdocs>=2.4; extra == \"check\"",
95
95
  "pytest-ruff>=0.2.1; sys_platform != \"cygwin\" and extra == \"check\"",
96
- "ruff>=0.8.0; sys_platform != \"cygwin\" and extra == \"check\"",
96
+ "ruff>=0.13.0; sys_platform != \"cygwin\" and extra == \"check\"",
97
97
  "pytest-cov; extra == \"cover\"",
98
98
  "pytest-enabler>=2.2; extra == \"enabler\"",
99
99
  "pytest-mypy; extra == \"type\"",
100
- "mypy==1.14.*; extra == \"type\"",
100
+ "mypy==1.18.*; extra == \"type\"",
101
101
  "importlib_metadata>=7.0.2; python_version < \"3.10\" and extra == \"type\"",
102
102
  "jaraco.develop>=7.21; sys_platform != \"cygwin\" and extra == \"type\""
103
103
  ],
@@ -284,6 +284,10 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
284
284
  def need_deserialize(self) -> bool:
285
285
  return any(r.type and not isinstance(r.type, BinaryIteratorType) for r in self.responses)
286
286
 
287
+ @property
288
+ def enable_import_deserialize_xml(self) -> bool:
289
+ return any(xml_serializable(str(r.default_content_type)) for r in self.responses + self.exceptions)
290
+
287
291
  def imports( # pylint: disable=too-many-branches, disable=too-many-statements
288
292
  self, async_mode: bool, **kwargs: Any
289
293
  ) -> FileImport:
@@ -443,7 +447,7 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
443
447
  ImportType.LOCAL,
444
448
  )
445
449
  file_import.add_import("json", ImportType.STDLIB)
446
- if any(xml_serializable(str(r.default_content_type)) for r in self.responses + self.exceptions):
450
+ if self.enable_import_deserialize_xml:
447
451
  file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
448
452
  elif self.need_deserialize:
449
453
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
@@ -17,6 +17,7 @@ from .parameter_list import ParameterList
17
17
  from .model_type import ModelType
18
18
  from .list_type import ListType
19
19
  from .parameter import Parameter
20
+ from ...utils import xml_serializable
20
21
 
21
22
  if TYPE_CHECKING:
22
23
  from .code_model import CodeModel
@@ -135,6 +136,10 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
135
136
  def has_optional_return_type(self) -> bool:
136
137
  return False
137
138
 
139
+ @property
140
+ def enable_import_deserialize_xml(self):
141
+ return any(xml_serializable(str(r.default_content_type)) for r in self.exceptions)
142
+
138
143
  def imports(self, async_mode: bool, **kwargs: Any) -> FileImport:
139
144
  if self.abstract:
140
145
  return FileImport(self.code_model)
@@ -185,7 +190,6 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
185
190
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
186
191
  if self.is_xml_paging:
187
192
  file_import.add_submodule_import("xml.etree", "ElementTree", ImportType.STDLIB, alias="ET")
188
- file_import.add_submodule_import(relative_path, "_convert_element", ImportType.LOCAL)
189
193
  return file_import
190
194
 
191
195
 
@@ -176,6 +176,18 @@ async def test_optional_body_provider_post_with_body(client):
176
176
  assert result.status == "Changed to requested allowance"
177
177
 
178
178
 
179
+ @pytest.mark.asyncio
180
+ async def test_lro_begin_export_array(client):
181
+ result = await (
182
+ await client.lro.begin_export_array(
183
+ body=models.ExportRequest(format="csv"),
184
+ )
185
+ ).result()
186
+ assert len(result) == 2
187
+ assert result[0].content == "order1,product1,1"
188
+ assert result[1].content == "order2,product2,2"
189
+
190
+
179
191
  @pytest.mark.asyncio
180
192
  async def test_lro_paging_begin_post_paging_lro(client):
181
193
  poller = await client.lro_paging.begin_post_paging_lro(
@@ -4,15 +4,14 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  import pytest
7
- from specs.azure.clientgenerator.core.clientinitialization.aio import (
7
+ from specs.azure.clientgenerator.core.clientinitialization.default.aio import (
8
8
  HeaderParamClient,
9
9
  MultipleParamsClient,
10
10
  MixedParamsClient,
11
11
  PathParamClient,
12
12
  ParamAliasClient,
13
- ParentClient,
14
13
  )
15
- from specs.azure.clientgenerator.core.clientinitialization.models import Input
14
+ from specs.azure.clientgenerator.core.clientinitialization.default.models import Input
16
15
 
17
16
 
18
17
  @pytest.mark.asyncio
@@ -0,0 +1,111 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import pytest
7
+ from azure.resourcemanager.multiserviceolderversions.combined.aio import CombinedClient
8
+ from azure.resourcemanager.multiserviceolderversions.combined.models import (
9
+ VirtualMachine,
10
+ Disk,
11
+ VirtualMachineProperties,
12
+ DiskProperties,
13
+ )
14
+
15
+
16
+ @pytest.fixture
17
+ async def client(credential, authentication_policy):
18
+ """Create a Combined async client for testing."""
19
+ return CombinedClient(
20
+ credential=credential,
21
+ subscription_id="00000000-0000-0000-0000-000000000000",
22
+ base_url="http://localhost:3000",
23
+ authentication_policy=authentication_policy,
24
+ polling_interval=0.1,
25
+ )
26
+
27
+
28
+ @pytest.mark.asyncio
29
+ async def test_virtual_machines_get(client):
30
+ """Test getting a virtual machine."""
31
+ resource_group_name = "test-rg"
32
+ vm_name = "vm-old1"
33
+
34
+ result = await client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name)
35
+
36
+ assert result is not None
37
+ assert isinstance(result, VirtualMachine)
38
+ assert result.name == vm_name
39
+ assert result.location == "eastus"
40
+ assert result.properties is not None
41
+ assert result.properties.provisioning_state == "Succeeded"
42
+ assert result.properties.size == "Standard_D2s_v3"
43
+
44
+
45
+ @pytest.mark.asyncio
46
+ async def test_virtual_machines_create_or_update(client):
47
+ """Test creating or updating a virtual machine."""
48
+ resource_group_name = "test-rg"
49
+ vm_name = "vm-old1"
50
+
51
+ vm_resource = VirtualMachine(
52
+ location="eastus",
53
+ properties=VirtualMachineProperties(size="Standard_D2s_v3"),
54
+ )
55
+
56
+ poller = await client.virtual_machines.begin_create_or_update(
57
+ resource_group_name=resource_group_name,
58
+ vm_name=vm_name,
59
+ resource=vm_resource,
60
+ )
61
+
62
+ result = await poller.result()
63
+ assert result is not None
64
+ assert isinstance(result, VirtualMachine)
65
+ assert result.location == "eastus"
66
+ assert result.properties is not None
67
+ assert result.properties.provisioning_state == "Succeeded"
68
+ assert result.properties.size == "Standard_D2s_v3"
69
+
70
+
71
+ @pytest.mark.asyncio
72
+ async def test_disks_get(client):
73
+ """Test getting a disk."""
74
+ resource_group_name = "test-rg"
75
+ disk_name = "disk-old1"
76
+
77
+ result = await client.disks.get(resource_group_name=resource_group_name, disk_name=disk_name)
78
+
79
+ assert result is not None
80
+ assert isinstance(result, Disk)
81
+ assert result.name == disk_name
82
+ assert result.location == "eastus"
83
+ assert result.properties is not None
84
+ assert result.properties.provisioning_state == "Succeeded"
85
+ assert result.properties.disk_size_gb == 128
86
+
87
+
88
+ @pytest.mark.asyncio
89
+ async def test_disks_create_or_update(client):
90
+ """Test creating or updating a disk."""
91
+ resource_group_name = "test-rg"
92
+ disk_name = "disk-old1"
93
+
94
+ disk_resource = Disk(
95
+ location="eastus",
96
+ properties=DiskProperties(disk_size_gb=128),
97
+ )
98
+
99
+ poller = await client.disks.begin_create_or_update(
100
+ resource_group_name=resource_group_name,
101
+ disk_name=disk_name,
102
+ resource=disk_resource,
103
+ )
104
+
105
+ result = await poller.result()
106
+ assert result is not None
107
+ assert isinstance(result, Disk)
108
+ assert result.location == "eastus"
109
+ assert result.properties is not None
110
+ assert result.properties.provisioning_state == "Succeeded"
111
+ assert result.properties.disk_size_gb == 128
@@ -0,0 +1,132 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import pytest
7
+ from azure.resourcemanager.multiservicesharedmodels.combined.aio import CombinedClient
8
+ from azure.resourcemanager.multiservicesharedmodels.combined.models import (
9
+ VirtualMachine,
10
+ VirtualMachineProperties,
11
+ StorageAccount,
12
+ StorageAccountProperties,
13
+ SharedMetadata,
14
+ )
15
+
16
+
17
+ @pytest.fixture
18
+ async def client(credential, authentication_policy):
19
+ """Create a Combined async client for testing."""
20
+ return CombinedClient(
21
+ credential=credential,
22
+ subscription_id="00000000-0000-0000-0000-000000000000",
23
+ base_url="http://localhost:3000",
24
+ authentication_policy=authentication_policy,
25
+ polling_interval=0.1,
26
+ )
27
+
28
+
29
+ @pytest.mark.asyncio
30
+ async def test_virtual_machines_get(client):
31
+ """Test getting a virtual machine with shared metadata."""
32
+ resource_group_name = "test-rg"
33
+ vm_name = "vm-shared1"
34
+
35
+ result = await client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name)
36
+
37
+ assert result is not None
38
+ assert isinstance(result, VirtualMachine)
39
+ assert result.name == vm_name
40
+ assert result.location == "eastus"
41
+ assert result.type == "Microsoft.Compute/virtualMachinesShared"
42
+ assert result.properties is not None
43
+ assert result.properties.provisioning_state == "Succeeded"
44
+ assert result.properties.metadata is not None
45
+ assert result.properties.metadata.created_by == "user@example.com"
46
+ assert result.properties.metadata.tags == {"environment": "production"}
47
+
48
+
49
+ @pytest.mark.asyncio
50
+ async def test_virtual_machines_create_or_update(client):
51
+ """Test creating or updating a virtual machine with shared metadata."""
52
+ resource_group_name = "test-rg"
53
+ vm_name = "vm-shared1"
54
+
55
+ vm_resource = VirtualMachine(
56
+ location="eastus",
57
+ properties=VirtualMachineProperties(
58
+ metadata=SharedMetadata(
59
+ created_by="user@example.com",
60
+ tags={"environment": "production"},
61
+ ),
62
+ ),
63
+ )
64
+
65
+ poller = await client.virtual_machines.begin_create_or_update(
66
+ resource_group_name=resource_group_name,
67
+ vm_name=vm_name,
68
+ resource=vm_resource,
69
+ )
70
+
71
+ result = await poller.result()
72
+ assert result is not None
73
+ assert isinstance(result, VirtualMachine)
74
+ assert result.location == "eastus"
75
+ assert result.properties is not None
76
+ assert result.properties.provisioning_state == "Succeeded"
77
+ assert result.properties.metadata is not None
78
+ assert result.properties.metadata.created_by == "user@example.com"
79
+ assert result.properties.metadata.tags == {"environment": "production"}
80
+
81
+
82
+ @pytest.mark.asyncio
83
+ async def test_storage_accounts_get(client):
84
+ """Test getting a storage account with shared metadata."""
85
+ resource_group_name = "test-rg"
86
+ account_name = "account1"
87
+
88
+ result = await client.storage_accounts.get(resource_group_name=resource_group_name, account_name=account_name)
89
+
90
+ assert result is not None
91
+ assert isinstance(result, StorageAccount)
92
+ assert result.name == account_name
93
+ assert result.location == "westus"
94
+ assert result.type == "Microsoft.Storage/storageAccounts"
95
+ assert result.properties is not None
96
+ assert result.properties.provisioning_state == "Succeeded"
97
+ assert result.properties.metadata is not None
98
+ assert result.properties.metadata.created_by == "admin@example.com"
99
+ assert result.properties.metadata.tags == {"department": "engineering"}
100
+
101
+
102
+ @pytest.mark.asyncio
103
+ async def test_storage_accounts_create_or_update(client):
104
+ """Test creating or updating a storage account with shared metadata."""
105
+ resource_group_name = "test-rg"
106
+ account_name = "account1"
107
+
108
+ storage_resource = StorageAccount(
109
+ location="westus",
110
+ properties=StorageAccountProperties(
111
+ metadata=SharedMetadata(
112
+ created_by="admin@example.com",
113
+ tags={"department": "engineering"},
114
+ ),
115
+ ),
116
+ )
117
+
118
+ poller = await client.storage_accounts.begin_create_or_update(
119
+ resource_group_name=resource_group_name,
120
+ account_name=account_name,
121
+ resource=storage_resource,
122
+ )
123
+
124
+ result = await poller.result()
125
+ assert result is not None
126
+ assert isinstance(result, StorageAccount)
127
+ assert result.location == "westus"
128
+ assert result.properties is not None
129
+ assert result.properties.provisioning_state == "Succeeded"
130
+ assert result.properties.metadata is not None
131
+ assert result.properties.metadata.created_by == "admin@example.com"
132
+ assert result.properties.metadata.tags == {"department": "engineering"}
@@ -184,3 +184,33 @@ async def test_optional_parts(client: MultiPartClient):
184
184
  profile_image=open(str(JPG), "rb"),
185
185
  )
186
186
  )
187
+
188
+
189
+ @pytest.mark.asyncio
190
+ async def test_file_upload_file_specific_content_type(client: MultiPartClient):
191
+ await client.form_data.file.upload_file_specific_content_type(
192
+ models.UploadFileSpecificContentTypeRequest(
193
+ file=("image.png", open(str(PNG), "rb"), "image/png"),
194
+ )
195
+ )
196
+
197
+
198
+ @pytest.mark.asyncio
199
+ async def test_file_upload_file_required_filename(client: MultiPartClient):
200
+ await client.form_data.file.upload_file_required_filename(
201
+ models.UploadFileRequiredFilenameRequest(
202
+ file=("image.png", open(str(PNG), "rb"), "image/png"),
203
+ )
204
+ )
205
+
206
+
207
+ @pytest.mark.asyncio
208
+ async def test_file_upload_file_array(client: MultiPartClient):
209
+ await client.form_data.file.upload_file_array(
210
+ models.UploadFileArrayRequest(
211
+ files=[
212
+ ("image.png", open(str(PNG), "rb"), "image/png"),
213
+ ("image.png", open(str(PNG), "rb"), "image/png"),
214
+ ],
215
+ )
216
+ )
@@ -156,6 +156,15 @@ def test_optional_body_provider_post_with_body(client):
156
156
  assert result.status == "Changed to requested allowance"
157
157
 
158
158
 
159
+ def test_lro_begin_export_array(client):
160
+ result = client.lro.begin_export_array(
161
+ body=models.ExportRequest(format="csv"),
162
+ ).result()
163
+ assert len(result) == 2
164
+ assert result[0].content == "order1,product1,1"
165
+ assert result[1].content == "order2,product2,2"
166
+
167
+
159
168
  def test_lro_paging_begin_post_paging_lro(client):
160
169
  result = client.lro_paging.begin_post_paging_lro(
161
170
  resource_group_name=RESOURCE_GROUP_NAME,
@@ -3,15 +3,14 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
- from specs.azure.clientgenerator.core.clientinitialization import (
6
+ from specs.azure.clientgenerator.core.clientinitialization.default import (
7
7
  HeaderParamClient,
8
8
  MultipleParamsClient,
9
9
  MixedParamsClient,
10
10
  PathParamClient,
11
11
  ParamAliasClient,
12
- ParentClient,
13
12
  )
14
- from specs.azure.clientgenerator.core.clientinitialization.models import Input
13
+ from specs.azure.clientgenerator.core.clientinitialization.default.models import Input
15
14
 
16
15
 
17
16
  def test_header_param_client():
@@ -0,0 +1,107 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import pytest
7
+ from azure.resourcemanager.multiserviceolderversions.combined import CombinedClient
8
+ from azure.resourcemanager.multiserviceolderversions.combined.models import (
9
+ VirtualMachine,
10
+ Disk,
11
+ VirtualMachineProperties,
12
+ DiskProperties,
13
+ )
14
+
15
+
16
+ @pytest.fixture
17
+ def client(credential, authentication_policy):
18
+ """Create a Combined client for testing."""
19
+ return CombinedClient(
20
+ credential=credential,
21
+ subscription_id="00000000-0000-0000-0000-000000000000",
22
+ base_url="http://localhost:3000",
23
+ authentication_policy=authentication_policy,
24
+ polling_interval=0.1,
25
+ )
26
+
27
+
28
+ def test_virtual_machines_get(client):
29
+ """Test getting a virtual machine."""
30
+ resource_group_name = "test-rg"
31
+ vm_name = "vm-old1"
32
+
33
+ result = client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name)
34
+
35
+ assert result is not None
36
+ assert isinstance(result, VirtualMachine)
37
+ assert result.name == vm_name
38
+ assert result.location == "eastus"
39
+ assert result.properties is not None
40
+ assert result.properties.provisioning_state == "Succeeded"
41
+ assert result.properties.size == "Standard_D2s_v3"
42
+
43
+
44
+ def test_virtual_machines_create_or_update(client):
45
+ """Test creating or updating a virtual machine."""
46
+ resource_group_name = "test-rg"
47
+ vm_name = "vm-old1"
48
+
49
+ vm_resource = VirtualMachine(
50
+ location="eastus",
51
+ properties=VirtualMachineProperties(size="Standard_D2s_v3"),
52
+ )
53
+
54
+ poller = client.virtual_machines.begin_create_or_update(
55
+ resource_group_name=resource_group_name,
56
+ vm_name=vm_name,
57
+ resource=vm_resource,
58
+ )
59
+
60
+ result = poller.result()
61
+ assert result is not None
62
+ assert isinstance(result, VirtualMachine)
63
+ assert result.location == "eastus"
64
+ assert result.properties is not None
65
+ assert result.properties.provisioning_state == "Succeeded"
66
+ assert result.properties.size == "Standard_D2s_v3"
67
+
68
+
69
+ def test_disks_get(client):
70
+ """Test getting a disk."""
71
+ resource_group_name = "test-rg"
72
+ disk_name = "disk-old1"
73
+
74
+ result = client.disks.get(resource_group_name=resource_group_name, disk_name=disk_name)
75
+
76
+ assert result is not None
77
+ assert isinstance(result, Disk)
78
+ assert result.name == disk_name
79
+ assert result.location == "eastus"
80
+ assert result.properties is not None
81
+ assert result.properties.provisioning_state == "Succeeded"
82
+ assert result.properties.disk_size_gb == 128
83
+
84
+
85
+ def test_disks_create_or_update(client):
86
+ """Test creating or updating a disk."""
87
+ resource_group_name = "test-rg"
88
+ disk_name = "disk-old1"
89
+
90
+ disk_resource = Disk(
91
+ location="eastus",
92
+ properties=DiskProperties(disk_size_gb=128),
93
+ )
94
+
95
+ poller = client.disks.begin_create_or_update(
96
+ resource_group_name=resource_group_name,
97
+ disk_name=disk_name,
98
+ resource=disk_resource,
99
+ )
100
+
101
+ result = poller.result()
102
+ assert result is not None
103
+ assert isinstance(result, Disk)
104
+ assert result.location == "eastus"
105
+ assert result.properties is not None
106
+ assert result.properties.provisioning_state == "Succeeded"
107
+ assert result.properties.disk_size_gb == 128