@typespec/http-client-python 0.27.0 → 0.27.2
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.
- package/dist/emitter/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +20 -15
- package/dist/emitter/code-model.js.map +1 -1
- package/dist/emitter/http.js +11 -1
- package/dist/emitter/http.js.map +1 -1
- package/dist/emitter/types.d.ts.map +1 -1
- package/dist/emitter/types.js +30 -11
- package/dist/emitter/types.js.map +1 -1
- package/emitter/src/code-model.ts +28 -21
- package/emitter/src/http.ts +10 -1
- package/emitter/src/types.ts +32 -11
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/ci/regenerate-common.ts +472 -0
- package/eng/scripts/ci/regenerate.ts +41 -427
- package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/client.py +5 -5
- package/generator/build/lib/pygen/codegen/models/credential_types.py +1 -1
- package/generator/build/lib/pygen/codegen/models/enum_type.py +1 -1
- package/generator/build/lib/pygen/codegen/models/imports.py +2 -3
- package/generator/build/lib/pygen/codegen/models/lro_operation.py +1 -1
- package/generator/build/lib/pygen/codegen/models/model_type.py +2 -2
- package/generator/build/lib/pygen/codegen/models/operation.py +10 -6
- package/generator/build/lib/pygen/codegen/models/operation_group.py +1 -1
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +7 -3
- package/generator/build/lib/pygen/codegen/models/primitive_types.py +1 -1
- package/generator/build/lib/pygen/codegen/models/request_builder.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +16 -7
- package/generator/build/lib/pygen/codegen/serializers/import_serializer.py +4 -31
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +8 -2
- package/generator/component-detection-pip-report.json +6 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/client.py +5 -5
- package/generator/pygen/codegen/models/credential_types.py +1 -1
- package/generator/pygen/codegen/models/enum_type.py +1 -1
- package/generator/pygen/codegen/models/imports.py +2 -3
- package/generator/pygen/codegen/models/lro_operation.py +1 -1
- package/generator/pygen/codegen/models/model_type.py +2 -2
- package/generator/pygen/codegen/models/operation.py +10 -6
- package/generator/pygen/codegen/models/operation_group.py +1 -1
- package/generator/pygen/codegen/models/paging_operation.py +7 -3
- package/generator/pygen/codegen/models/primitive_types.py +1 -1
- package/generator/pygen/codegen/models/request_builder.py +1 -1
- package/generator/pygen/codegen/serializers/builder_serializer.py +16 -7
- package/generator/pygen/codegen/serializers/import_serializer.py +4 -31
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +8 -2
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +12 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_client_initialization_async.py +2 -3
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_page_async.py +12 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py +111 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_shared_models_async.py +132 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_payload_multipart_async.py +30 -0
- package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +9 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_client_initialization.py +2 -3
- package/generator/test/azure/mock_api_tests/test_azure_core_page.py +11 -0
- package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py +107 -0
- package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_shared_models.py +128 -0
- package/generator/test/azure/mock_api_tests/test_clear_output_folder.py +9 -0
- package/generator/test/azure/mock_api_tests/test_payload_multipart.py +27 -0
- package/generator/test/azure/requirements.txt +10 -2
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +6 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +10 -5
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +30 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_file_async.py +59 -0
- package/generator/test/generic_mock_api_tests/data/image.jpg +0 -0
- package/generator/test/generic_mock_api_tests/data/image.png +0 -0
- package/generator/test/generic_mock_api_tests/test_encode_bytes.py +6 -0
- package/generator/test/generic_mock_api_tests/test_payload_pageable.py +8 -4
- package/generator/test/generic_mock_api_tests/test_payload_xml.py +27 -0
- package/generator/test/generic_mock_api_tests/test_typetest_file.py +52 -0
- package/generator/test/unbranded/mock_api_tests/asynctests/test_payload_multipart_async.py +31 -0
- package/generator/test/unbranded/mock_api_tests/test_payload_multipart.py +28 -0
- package/generator/test/unbranded/mock_api_tests/test_unbranded.py +9 -8
- package/generator/test/unbranded/requirements.txt +3 -1
- package/generator/test/unittests/test_model_base_serialization.py +161 -0
- package/package.json +38 -38
|
@@ -527,6 +527,8 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):
|
|
|
527
527
|
return self._data.setdefault(key, default)
|
|
528
528
|
|
|
529
529
|
def __eq__(self, other: typing.Any) -> bool:
|
|
530
|
+
if isinstance(other, _MyMutableMapping):
|
|
531
|
+
return self._data == other._data
|
|
530
532
|
try:
|
|
531
533
|
other_model = self.__class__(other)
|
|
532
534
|
except Exception:
|
|
@@ -1020,16 +1022,20 @@ def _deserialize_with_callable(
|
|
|
1020
1022
|
return float(value.text) if value.text else None
|
|
1021
1023
|
if deserializer is bool:
|
|
1022
1024
|
return value.text == "true" if value.text else None
|
|
1025
|
+
if deserializer and deserializer in _DESERIALIZE_MAPPING.values():
|
|
1026
|
+
return deserializer(value.text) if value.text else None
|
|
1027
|
+
if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values():
|
|
1028
|
+
return deserializer(value.text) if value.text else None
|
|
1023
1029
|
if deserializer is None:
|
|
1024
1030
|
return value
|
|
1025
1031
|
if deserializer in [int, float, bool]:
|
|
1026
1032
|
return deserializer(value)
|
|
1027
1033
|
if isinstance(deserializer, CaseInsensitiveEnumMeta):
|
|
1028
1034
|
try:
|
|
1029
|
-
return deserializer(value)
|
|
1035
|
+
return deserializer(value.text if isinstance(value, ET.Element) else value)
|
|
1030
1036
|
except ValueError:
|
|
1031
1037
|
# for unknown value, return raw value
|
|
1032
|
-
return value
|
|
1038
|
+
return value.text if isinstance(value, ET.Element) else value
|
|
1033
1039
|
if isinstance(deserializer, type) and issubclass(deserializer, Model):
|
|
1034
1040
|
return deserializer._deserialize(value, [])
|
|
1035
1041
|
return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value)
|
package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py
CHANGED
|
@@ -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
|
|
@@ -66,3 +66,15 @@ async def test_list_with_parameterized_next_link(client: aio.PageClient):
|
|
|
66
66
|
assert result[0].name == "User1"
|
|
67
67
|
assert result[1].id == 2
|
|
68
68
|
assert result[1].name == "User2"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.asyncio
|
|
72
|
+
async def test_list_with_relative_next_link(client: aio.PageClient):
|
|
73
|
+
result = [item async for item in client.with_relative_next_link()]
|
|
74
|
+
assert len(result) == 2
|
|
75
|
+
assert result[0].id == 1
|
|
76
|
+
assert result[0].name == "User1"
|
|
77
|
+
assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
|
|
78
|
+
assert result[1].id == 2
|
|
79
|
+
assert result[1].name == "User2"
|
|
80
|
+
assert result[1].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
|
|
@@ -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():
|
|
@@ -58,3 +58,14 @@ def test_list_with_parameterized_next_link(client: PageClient):
|
|
|
58
58
|
assert result[0].name == "User1"
|
|
59
59
|
assert result[1].id == 2
|
|
60
60
|
assert result[1].name == "User2"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_list_with_relative_next_link(client: PageClient):
|
|
64
|
+
result = list(client.with_relative_next_link())
|
|
65
|
+
assert len(result) == 2
|
|
66
|
+
assert result[0].id == 1
|
|
67
|
+
assert result[0].name == "User1"
|
|
68
|
+
assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
|
|
69
|
+
assert result[1].id == 2
|
|
70
|
+
assert result[1].name == "User2"
|
|
71
|
+
assert result[1].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
|
|
@@ -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
|
|
@@ -0,0 +1,128 @@
|
|
|
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 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
|
+
def client(credential, authentication_policy):
|
|
19
|
+
"""Create a Combined 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
|
+
def test_virtual_machines_get(client):
|
|
30
|
+
"""Test getting a virtual machine with shared metadata."""
|
|
31
|
+
resource_group_name = "test-rg"
|
|
32
|
+
vm_name = "vm-shared1"
|
|
33
|
+
|
|
34
|
+
result = 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.type == "Microsoft.Compute/virtualMachinesShared"
|
|
41
|
+
assert result.properties is not None
|
|
42
|
+
assert result.properties.provisioning_state == "Succeeded"
|
|
43
|
+
assert result.properties.metadata is not None
|
|
44
|
+
assert result.properties.metadata.created_by == "user@example.com"
|
|
45
|
+
assert result.properties.metadata.tags == {"environment": "production"}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_virtual_machines_create_or_update(client):
|
|
49
|
+
"""Test creating or updating a virtual machine with shared metadata."""
|
|
50
|
+
resource_group_name = "test-rg"
|
|
51
|
+
vm_name = "vm-shared1"
|
|
52
|
+
|
|
53
|
+
vm_resource = VirtualMachine(
|
|
54
|
+
location="eastus",
|
|
55
|
+
properties=VirtualMachineProperties(
|
|
56
|
+
metadata=SharedMetadata(
|
|
57
|
+
created_by="user@example.com",
|
|
58
|
+
tags={"environment": "production"},
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
poller = client.virtual_machines.begin_create_or_update(
|
|
64
|
+
resource_group_name=resource_group_name,
|
|
65
|
+
vm_name=vm_name,
|
|
66
|
+
resource=vm_resource,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
result = poller.result()
|
|
70
|
+
assert result is not None
|
|
71
|
+
assert isinstance(result, VirtualMachine)
|
|
72
|
+
assert result.location == "eastus"
|
|
73
|
+
assert result.properties is not None
|
|
74
|
+
assert result.properties.provisioning_state == "Succeeded"
|
|
75
|
+
assert result.properties.metadata is not None
|
|
76
|
+
assert result.properties.metadata.created_by == "user@example.com"
|
|
77
|
+
assert result.properties.metadata.tags == {"environment": "production"}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_storage_accounts_get(client):
|
|
81
|
+
"""Test getting a storage account with shared metadata."""
|
|
82
|
+
resource_group_name = "test-rg"
|
|
83
|
+
account_name = "account1"
|
|
84
|
+
|
|
85
|
+
result = client.storage_accounts.get(resource_group_name=resource_group_name, account_name=account_name)
|
|
86
|
+
|
|
87
|
+
assert result is not None
|
|
88
|
+
assert isinstance(result, StorageAccount)
|
|
89
|
+
assert result.name == account_name
|
|
90
|
+
assert result.location == "westus"
|
|
91
|
+
assert result.type == "Microsoft.Storage/storageAccounts"
|
|
92
|
+
assert result.properties is not None
|
|
93
|
+
assert result.properties.provisioning_state == "Succeeded"
|
|
94
|
+
assert result.properties.metadata is not None
|
|
95
|
+
assert result.properties.metadata.created_by == "admin@example.com"
|
|
96
|
+
assert result.properties.metadata.tags == {"department": "engineering"}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_storage_accounts_create_or_update(client):
|
|
100
|
+
"""Test creating or updating a storage account with shared metadata."""
|
|
101
|
+
resource_group_name = "test-rg"
|
|
102
|
+
account_name = "account1"
|
|
103
|
+
|
|
104
|
+
storage_resource = StorageAccount(
|
|
105
|
+
location="westus",
|
|
106
|
+
properties=StorageAccountProperties(
|
|
107
|
+
metadata=SharedMetadata(
|
|
108
|
+
created_by="admin@example.com",
|
|
109
|
+
tags={"department": "engineering"},
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
poller = client.storage_accounts.begin_create_or_update(
|
|
115
|
+
resource_group_name=resource_group_name,
|
|
116
|
+
account_name=account_name,
|
|
117
|
+
resource=storage_resource,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
result = poller.result()
|
|
121
|
+
assert result is not None
|
|
122
|
+
assert isinstance(result, StorageAccount)
|
|
123
|
+
assert result.location == "westus"
|
|
124
|
+
assert result.properties is not None
|
|
125
|
+
assert result.properties.provisioning_state == "Succeeded"
|
|
126
|
+
assert result.properties.metadata is not None
|
|
127
|
+
assert result.properties.metadata.created_by == "admin@example.com"
|
|
128
|
+
assert result.properties.metadata.tags == {"department": "engineering"}
|
|
@@ -12,3 +12,12 @@ def test_clear_output_folder():
|
|
|
12
12
|
folder = GENERATED_PATH / "authentication-api-key/authentication/apikey/_operations"
|
|
13
13
|
assert folder.exists(), "Operations folder should exist"
|
|
14
14
|
assert not (folder / "to_be_deleted.py").exists(), "File to_be_deleted.py should be deleted after regeneration"
|
|
15
|
+
|
|
16
|
+
if (GENERATED_PATH / "generation-subdir").exists():
|
|
17
|
+
assert (GENERATED_PATH / "generation-subdir/generated_tests").exists()
|
|
18
|
+
assert not (GENERATED_PATH / "generation-subdir/generated_tests/to_be_deleted.py").exists()
|
|
19
|
+
|
|
20
|
+
assert (GENERATED_PATH / "generation-subdir/generation/subdir/_generated").exists()
|
|
21
|
+
assert not (GENERATED_PATH / "generation-subdir/generation/subdir/_generated/to_be_deleted.py").exists()
|
|
22
|
+
|
|
23
|
+
assert (GENERATED_PATH / "generation-subdir/generation/subdir/to_be_kept.py").exists()
|