@typespec/http-client-python 0.13.0 → 0.14.1-dev.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.
- package/dist/emitter/http.d.ts.map +1 -1
- package/dist/emitter/http.js +13 -3
- package/dist/emitter/http.js.map +1 -1
- package/emitter/src/http.ts +20 -2
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/emitter/vitest.config.ts +1 -1
- package/eng/scripts/ci/regenerate.ts +7 -5
- package/eng/scripts/setup/__pycache__/package_manager.cpython-39.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-39.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/client.py +1 -3
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/operations_init_serializer.py +7 -2
- package/generator/build/lib/pygen/codegen/serializers/sample_serializer.py +3 -2
- package/generator/build/lib/pygen/codegen/templates/sample.py.jinja2 +1 -1
- package/generator/build/lib/pygen/preprocess/python_mappings.py +4 -2
- package/generator/component-detection-pip-report.json +2 -2
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/client.py +1 -3
- package/generator/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/pygen/codegen/serializers/operations_init_serializer.py +7 -2
- package/generator/pygen/codegen/serializers/sample_serializer.py +3 -2
- package/generator/pygen/codegen/templates/sample.py.jinja2 +1 -1
- package/generator/pygen/preprocess/python_mappings.py +4 -2
- package/generator/pygen.egg-info/PKG-INFO +1 -1
- package/generator/pygen.egg-info/requires.txt +1 -1
- package/generator/setup.py +1 -1
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +5 -1
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_client_location_async.py +48 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_override_async.py +43 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py +5 -5
- package/generator/test/azure/mock_api_tests/asynctests/test_client_namespace_async.py +23 -20
- package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +5 -2
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_client_location.py +41 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_override.py +41 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py +2 -2
- package/generator/test/azure/mock_api_tests/test_client_namespace.py +21 -18
- package/generator/test/azure/requirements.txt +4 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +16 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_response_status_code_range_async.py +38 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +7 -0
- package/generator/test/generic_mock_api_tests/test_payload_xml.py +14 -0
- package/generator/test/generic_mock_api_tests/test_response_status_code_range.py +36 -0
- package/generator/test/generic_mock_api_tests/test_versioning_removed.py +6 -0
- package/generator/test/unbranded/requirements.txt +1 -0
- package/package.json +33 -33
|
@@ -58,6 +58,9 @@ const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<stri
|
|
|
58
58
|
"azure/client-generator-core/usage": {
|
|
59
59
|
namespace: "specs.azure.clientgenerator.core.usage",
|
|
60
60
|
},
|
|
61
|
+
"azure/client-generator-core/override": {
|
|
62
|
+
namespace: "specs.azure.clientgenerator.core.override",
|
|
63
|
+
},
|
|
61
64
|
"azure/core/basic": {
|
|
62
65
|
namespace: "specs.azure.core.basic",
|
|
63
66
|
},
|
|
@@ -259,17 +262,13 @@ function getEmitterOption(spec: string, flavor: string): Record<string, string>[
|
|
|
259
262
|
|
|
260
263
|
// Function to execute CLI commands asynchronously
|
|
261
264
|
async function executeCommand(tspCommand: TspCommand): Promise<void> {
|
|
262
|
-
try {
|
|
263
|
-
rmSync(tspCommand.outputDir, { recursive: true, force: true });
|
|
264
|
-
} catch (error) {
|
|
265
|
-
console.error(chalk.red(`rm error: ${error}`));
|
|
266
|
-
}
|
|
267
265
|
const execFileAsync = promisify(execFile);
|
|
268
266
|
try {
|
|
269
267
|
console.log(chalk.green(`start tsp ${tspCommand.command.join(" ")}`));
|
|
270
268
|
await execFileAsync("tsp", tspCommand.command, { shell: true });
|
|
271
269
|
console.log(chalk.green(`tsp ${tspCommand.command.join(" ")} succeeded`));
|
|
272
270
|
} catch (err) {
|
|
271
|
+
rmSync(tspCommand.outputDir, { recursive: true, force: true });
|
|
273
272
|
console.error(chalk.red(`exec error: ${err}`));
|
|
274
273
|
throw err;
|
|
275
274
|
}
|
|
@@ -310,6 +309,9 @@ async function getSubdirectories(baseDir: string, flags: RegenerateFlags): Promi
|
|
|
310
309
|
|
|
311
310
|
const mainTspRelativePath = toPosix(relative(baseDir, mainTspPath));
|
|
312
311
|
|
|
312
|
+
// after support discriminated union, remove this check
|
|
313
|
+
if (mainTspRelativePath.includes("type/union/discriminated")) return;
|
|
314
|
+
|
|
313
315
|
// after fix test generation for nested operation group, remove this check
|
|
314
316
|
if (mainTspRelativePath.includes("client-operation-group")) return;
|
|
315
317
|
|
|
Binary file
|
|
Binary file
|
|
@@ -322,13 +322,11 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]): # pylint: disable=t
|
|
|
322
322
|
)
|
|
323
323
|
serialize_namespace = kwargs.get("serialize_namespace", self.code_model.namespace)
|
|
324
324
|
for og in self.operation_groups:
|
|
325
|
-
suffix = f".{og.filename}" if (not self.code_model.options["multiapi"]) and og.is_mixin else ""
|
|
326
325
|
file_import.add_submodule_import(
|
|
327
326
|
self.code_model.get_relative_import_path(
|
|
328
327
|
serialize_namespace,
|
|
329
328
|
self.code_model.get_imported_namespace_for_operation(og.client_namespace, async_mode),
|
|
330
|
-
)
|
|
331
|
-
+ suffix,
|
|
329
|
+
),
|
|
332
330
|
og.class_name,
|
|
333
331
|
ImportType.LOCAL,
|
|
334
332
|
)
|
|
@@ -9,6 +9,12 @@ from jinja2 import Environment
|
|
|
9
9
|
from ..models import CodeModel, OperationGroup
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
def get_pylint_disable(code_model: CodeModel, og: OperationGroup) -> str:
|
|
13
|
+
if og.is_mixin and not code_model.options["multiapi"]:
|
|
14
|
+
return " # pylint: disable=unused-import"
|
|
15
|
+
return ""
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
class OperationsInitSerializer:
|
|
13
19
|
def __init__(
|
|
14
20
|
self,
|
|
@@ -27,9 +33,8 @@ class OperationsInitSerializer:
|
|
|
27
33
|
return "_operations" if self.code_model.options["combine-operation-files"] else operation_group.filename
|
|
28
34
|
|
|
29
35
|
return [
|
|
30
|
-
f"from .{_get_filename(og)} import {og.class_name}
|
|
36
|
+
f"from .{_get_filename(og)} import {og.class_name} # type: ignore{get_pylint_disable(self.code_model, og)}"
|
|
31
37
|
for og in self.operation_groups
|
|
32
|
-
if not og.is_mixin or self.code_model.options["multiapi"]
|
|
33
38
|
]
|
|
34
39
|
|
|
35
40
|
def serialize(self) -> str:
|
|
@@ -69,7 +69,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
69
69
|
def _client_params(self) -> Dict[str, Any]:
|
|
70
70
|
# client params
|
|
71
71
|
special_param = {}
|
|
72
|
-
credential_type = getattr(self.
|
|
72
|
+
credential_type = getattr(self.operation_group.client.credential, "type", None)
|
|
73
73
|
if isinstance(credential_type, TokenCredentialType):
|
|
74
74
|
special_param.update({"credential": "DefaultAzureCredential()"})
|
|
75
75
|
elif isinstance(credential_type, KeyCredentialType):
|
|
@@ -78,7 +78,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
78
78
|
params = [
|
|
79
79
|
p
|
|
80
80
|
for p in (
|
|
81
|
-
self.
|
|
81
|
+
self.operation_group.client.parameters.positional + self.operation_group.client.parameters.keyword_only
|
|
82
82
|
)
|
|
83
83
|
if not p.optional and p.client_default_value is None
|
|
84
84
|
]
|
|
@@ -153,6 +153,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
153
153
|
operation_result, return_var = self._operation_result()
|
|
154
154
|
return self.env.get_template("sample.py.jinja2").render(
|
|
155
155
|
code_model=self.code_model,
|
|
156
|
+
client=self.operation_group.client,
|
|
156
157
|
file_name=self.file_name,
|
|
157
158
|
operation_result=operation_result,
|
|
158
159
|
operation_params=self._operation_params(),
|
|
@@ -97,7 +97,7 @@ _always_reserved = [
|
|
|
97
97
|
"int",
|
|
98
98
|
]
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
RESERVED_TSP_MODEL_PROPERTIES = [
|
|
101
101
|
"keys",
|
|
102
102
|
"items",
|
|
103
103
|
"values",
|
|
@@ -109,6 +109,8 @@ RESERVED_MODEL_PROPERTIES = [
|
|
|
109
109
|
"get",
|
|
110
110
|
"copy",
|
|
111
111
|
"as_dict",
|
|
112
|
+
# following are reserved special words for TSP models
|
|
113
|
+
"datetime",
|
|
112
114
|
]
|
|
113
115
|
|
|
114
116
|
RESERVED_WORDS = {
|
|
@@ -187,7 +189,7 @@ RESERVED_WORDS = {
|
|
|
187
189
|
|
|
188
190
|
TSP_RESERVED_WORDS = {
|
|
189
191
|
PadType.PARAMETER: ["stream"],
|
|
190
|
-
PadType.PROPERTY:
|
|
192
|
+
PadType.PROPERTY: RESERVED_TSP_MODEL_PROPERTIES,
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
REDEFINED_BUILTINS = [ # we don't pad, but we need to do lint ignores
|
|
@@ -126,9 +126,9 @@
|
|
|
126
126
|
"implementation_version": "3.9.23",
|
|
127
127
|
"os_name": "posix",
|
|
128
128
|
"platform_machine": "x86_64",
|
|
129
|
-
"platform_release": "6.11.0-
|
|
129
|
+
"platform_release": "6.11.0-1018-azure",
|
|
130
130
|
"platform_system": "Linux",
|
|
131
|
-
"platform_version": "#
|
|
131
|
+
"platform_version": "#18~24.04.1-Ubuntu SMP Sat Jun 28 04:46:03 UTC 2025",
|
|
132
132
|
"python_full_version": "3.9.23",
|
|
133
133
|
"platform_python_implementation": "CPython",
|
|
134
134
|
"python_version": "3.9",
|
|
Binary file
|
|
@@ -322,13 +322,11 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]): # pylint: disable=t
|
|
|
322
322
|
)
|
|
323
323
|
serialize_namespace = kwargs.get("serialize_namespace", self.code_model.namespace)
|
|
324
324
|
for og in self.operation_groups:
|
|
325
|
-
suffix = f".{og.filename}" if (not self.code_model.options["multiapi"]) and og.is_mixin else ""
|
|
326
325
|
file_import.add_submodule_import(
|
|
327
326
|
self.code_model.get_relative_import_path(
|
|
328
327
|
serialize_namespace,
|
|
329
328
|
self.code_model.get_imported_namespace_for_operation(og.client_namespace, async_mode),
|
|
330
|
-
)
|
|
331
|
-
+ suffix,
|
|
329
|
+
),
|
|
332
330
|
og.class_name,
|
|
333
331
|
ImportType.LOCAL,
|
|
334
332
|
)
|
|
@@ -9,6 +9,12 @@ from jinja2 import Environment
|
|
|
9
9
|
from ..models import CodeModel, OperationGroup
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
def get_pylint_disable(code_model: CodeModel, og: OperationGroup) -> str:
|
|
13
|
+
if og.is_mixin and not code_model.options["multiapi"]:
|
|
14
|
+
return " # pylint: disable=unused-import"
|
|
15
|
+
return ""
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
class OperationsInitSerializer:
|
|
13
19
|
def __init__(
|
|
14
20
|
self,
|
|
@@ -27,9 +33,8 @@ class OperationsInitSerializer:
|
|
|
27
33
|
return "_operations" if self.code_model.options["combine-operation-files"] else operation_group.filename
|
|
28
34
|
|
|
29
35
|
return [
|
|
30
|
-
f"from .{_get_filename(og)} import {og.class_name}
|
|
36
|
+
f"from .{_get_filename(og)} import {og.class_name} # type: ignore{get_pylint_disable(self.code_model, og)}"
|
|
31
37
|
for og in self.operation_groups
|
|
32
|
-
if not og.is_mixin or self.code_model.options["multiapi"]
|
|
33
38
|
]
|
|
34
39
|
|
|
35
40
|
def serialize(self) -> str:
|
|
@@ -69,7 +69,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
69
69
|
def _client_params(self) -> Dict[str, Any]:
|
|
70
70
|
# client params
|
|
71
71
|
special_param = {}
|
|
72
|
-
credential_type = getattr(self.
|
|
72
|
+
credential_type = getattr(self.operation_group.client.credential, "type", None)
|
|
73
73
|
if isinstance(credential_type, TokenCredentialType):
|
|
74
74
|
special_param.update({"credential": "DefaultAzureCredential()"})
|
|
75
75
|
elif isinstance(credential_type, KeyCredentialType):
|
|
@@ -78,7 +78,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
78
78
|
params = [
|
|
79
79
|
p
|
|
80
80
|
for p in (
|
|
81
|
-
self.
|
|
81
|
+
self.operation_group.client.parameters.positional + self.operation_group.client.parameters.keyword_only
|
|
82
82
|
)
|
|
83
83
|
if not p.optional and p.client_default_value is None
|
|
84
84
|
]
|
|
@@ -153,6 +153,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
153
153
|
operation_result, return_var = self._operation_result()
|
|
154
154
|
return self.env.get_template("sample.py.jinja2").render(
|
|
155
155
|
code_model=self.code_model,
|
|
156
|
+
client=self.operation_group.client,
|
|
156
157
|
file_name=self.file_name,
|
|
157
158
|
operation_result=operation_result,
|
|
158
159
|
operation_params=self._operation_params(),
|
|
@@ -97,7 +97,7 @@ _always_reserved = [
|
|
|
97
97
|
"int",
|
|
98
98
|
]
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
RESERVED_TSP_MODEL_PROPERTIES = [
|
|
101
101
|
"keys",
|
|
102
102
|
"items",
|
|
103
103
|
"values",
|
|
@@ -109,6 +109,8 @@ RESERVED_MODEL_PROPERTIES = [
|
|
|
109
109
|
"get",
|
|
110
110
|
"copy",
|
|
111
111
|
"as_dict",
|
|
112
|
+
# following are reserved special words for TSP models
|
|
113
|
+
"datetime",
|
|
112
114
|
]
|
|
113
115
|
|
|
114
116
|
RESERVED_WORDS = {
|
|
@@ -187,7 +189,7 @@ RESERVED_WORDS = {
|
|
|
187
189
|
|
|
188
190
|
TSP_RESERVED_WORDS = {
|
|
189
191
|
PadType.PARAMETER: ["stream"],
|
|
190
|
-
PadType.PROPERTY:
|
|
192
|
+
PadType.PROPERTY: RESERVED_TSP_MODEL_PROPERTIES,
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
REDEFINED_BUILTINS = [ # we don't pad, but we need to do lint ignores
|
|
@@ -21,7 +21,7 @@ Requires-Dist: docutils>=0.20.1
|
|
|
21
21
|
Requires-Dist: Jinja2==3.1.6
|
|
22
22
|
Requires-Dist: PyYAML==6.0.1
|
|
23
23
|
Requires-Dist: tomli==2.0.1
|
|
24
|
-
Requires-Dist: setuptools==
|
|
24
|
+
Requires-Dist: setuptools==75.3.2
|
|
25
25
|
Dynamic: author
|
|
26
26
|
Dynamic: author-email
|
|
27
27
|
Dynamic: classifier
|
package/generator/setup.py
CHANGED
package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py
CHANGED
|
@@ -47,7 +47,11 @@ async def test_check_name_availability_check_local(client):
|
|
|
47
47
|
@pytest.mark.asyncio
|
|
48
48
|
async def test_operations_list(client):
|
|
49
49
|
result = client.operations.list()
|
|
50
|
-
|
|
50
|
+
async for operation in result:
|
|
51
|
+
assert operation.name == "Microsoft.Compute/virtualMachines/write"
|
|
52
|
+
assert operation.display.operation == "Create or Update Virtual Machine."
|
|
53
|
+
assert operation.origin == "user,system"
|
|
54
|
+
assert operation.action_type == "Internal"
|
|
51
55
|
|
|
52
56
|
|
|
53
57
|
@pytest.mark.asyncio
|
|
@@ -0,0 +1,48 @@
|
|
|
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 specs.azure.clientgenerator.core.clientlocation.aio import ClientLocationClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with ClientLocationClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_get_health_status(client: ClientLocationClient):
|
|
18
|
+
await client.get_health_status()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.asyncio
|
|
22
|
+
async def test_archive_operations_archive_product(client: ClientLocationClient):
|
|
23
|
+
await client.archive_operations.archive_product()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.asyncio
|
|
27
|
+
async def test_move_to_existing_sub_client_admin_operations_get_admin_info(client: ClientLocationClient):
|
|
28
|
+
await client.move_to_existing_sub_client.admin_operations.get_admin_info()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.asyncio
|
|
32
|
+
async def test_move_to_existing_sub_client_admin_operations_delete_user(client: ClientLocationClient):
|
|
33
|
+
await client.move_to_existing_sub_client.admin_operations.delete_user()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.asyncio
|
|
37
|
+
async def test_move_to_existing_sub_client_user_operations_get_user(client: ClientLocationClient):
|
|
38
|
+
await client.move_to_existing_sub_client.user_operations.get_user()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.asyncio
|
|
42
|
+
async def test_move_to_new_sub_client_product_operations_list_products(client: ClientLocationClient):
|
|
43
|
+
await client.move_to_new_sub_client.product_operations.list_products()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_move_to_root_client_resource_operations_get_resource(client: ClientLocationClient):
|
|
48
|
+
await client.move_to_root_client.resource_operations.get_resource()
|
|
@@ -0,0 +1,43 @@
|
|
|
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 inspect
|
|
7
|
+
import pytest
|
|
8
|
+
from specs.azure.clientgenerator.core.override.aio import OverrideClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
async def client():
|
|
13
|
+
async with OverrideClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.asyncio
|
|
18
|
+
async def test_reorder_parameters(client: OverrideClient):
|
|
19
|
+
await client.reorder_parameters.reorder("param1", "param2")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.asyncio
|
|
23
|
+
async def test_group_parameters(client: OverrideClient):
|
|
24
|
+
await client.group_parameters.group(param1="param1", param2="param2")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_reorder_parameters_unit_async(client: OverrideClient):
|
|
28
|
+
# make sure signature name of `reorder_parameters` are ["param1", "param2"]
|
|
29
|
+
# Get the reorder method from the reorder_parameters operation
|
|
30
|
+
reorder_method = client.reorder_parameters.reorder
|
|
31
|
+
|
|
32
|
+
# Inspect the method signature
|
|
33
|
+
sig = inspect.signature(reorder_method)
|
|
34
|
+
|
|
35
|
+
# Get parameter names excluding 'self' and '**kwargs'
|
|
36
|
+
param_names = [
|
|
37
|
+
param_name
|
|
38
|
+
for param_name, param in sig.parameters.items()
|
|
39
|
+
if param_name not in ("self", "kwargs") and param.kind != param.VAR_KEYWORD
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
# Assert that the parameter names are exactly ["param1", "param2"]
|
|
43
|
+
assert param_names == ["param1", "param2"], f"Expected parameter names ['param1', 'param2'], but got {param_names}"
|
|
@@ -31,8 +31,8 @@ async def test_model_usage(client: UsageClient):
|
|
|
31
31
|
) == await client.model_in_operation.model_in_read_only_property(body=models.RoundTripModel())
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
@pytest.mark.asyncio
|
|
35
|
+
async def test_orphan_model_serializable(client: UsageClient):
|
|
36
|
+
await client.model_in_operation.orphan_model_serializable(
|
|
37
|
+
body=models.OrphanModel(model_name="name", description="desc")
|
|
38
|
+
)
|
|
@@ -3,29 +3,32 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import pytest
|
|
7
|
+
from client.clientnamespace.aio import ClientNamespaceFirstClient
|
|
8
|
+
from client.clientnamespace.first.models import FirstClientResult
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
from client.clientnamespace.second.aio import ClientNamespaceSecondClient
|
|
11
|
+
from client.clientnamespace.second.models import SecondClientResult
|
|
12
|
+
from client.clientnamespace.second.sub.models import SecondClientEnumType
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
async def first_client():
|
|
17
|
+
async with ClientNamespaceFirstClient() as client:
|
|
18
|
+
yield client
|
|
19
19
|
|
|
20
|
-
# @pytest.fixture
|
|
21
|
-
# async def second_client():
|
|
22
|
-
# async with ClientNamespaceSecondClient() as client:
|
|
23
|
-
# yield client
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
@pytest.fixture
|
|
22
|
+
async def second_client():
|
|
23
|
+
async with ClientNamespaceSecondClient() as client:
|
|
24
|
+
yield client
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
|
|
27
|
+
@pytest.mark.asyncio
|
|
28
|
+
async def test_get_first(first_client: ClientNamespaceFirstClient):
|
|
29
|
+
assert await first_client.get_first() == FirstClientResult(name="first")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.asyncio
|
|
33
|
+
async def test_get_second(second_client: ClientNamespaceSecondClient):
|
|
34
|
+
assert await second_client.get_second() == SecondClientResult(type=SecondClientEnumType.SECOND)
|
|
@@ -43,8 +43,11 @@ def test_check_name_availability_check_local(client):
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def test_operations_list(client):
|
|
46
|
-
result = client.operations.list()
|
|
47
|
-
assert result
|
|
46
|
+
result = client.operations.list().next()
|
|
47
|
+
assert result.name == "Microsoft.Compute/virtualMachines/write"
|
|
48
|
+
assert result.display.operation == "Create or Update Virtual Machine."
|
|
49
|
+
assert result.origin == "user,system"
|
|
50
|
+
assert result.action_type == "Internal"
|
|
48
51
|
|
|
49
52
|
|
|
50
53
|
def test_lro_begin_create_or_replace(client):
|
package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_client_location.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 specs.azure.clientgenerator.core.clientlocation import ClientLocationClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with ClientLocationClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_get_health_status(client: ClientLocationClient):
|
|
17
|
+
client.get_health_status()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_archive_operations_archive_product(client: ClientLocationClient):
|
|
21
|
+
client.archive_operations.archive_product()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_move_to_existing_sub_client_admin_operations_get_admin_info(client: ClientLocationClient):
|
|
25
|
+
client.move_to_existing_sub_client.admin_operations.get_admin_info()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_move_to_existing_sub_client_admin_operations_delete_user(client: ClientLocationClient):
|
|
29
|
+
client.move_to_existing_sub_client.admin_operations.delete_user()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_move_to_existing_sub_client_user_operations_get_user(client: ClientLocationClient):
|
|
33
|
+
client.move_to_existing_sub_client.user_operations.get_user()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_move_to_new_sub_client_product_operations_list_products(client: ClientLocationClient):
|
|
37
|
+
client.move_to_new_sub_client.product_operations.list_products()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_move_to_root_client_resource_operations_get_resource(client: ClientLocationClient):
|
|
41
|
+
client.move_to_root_client.resource_operations.get_resource()
|
|
@@ -0,0 +1,41 @@
|
|
|
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 inspect
|
|
7
|
+
import pytest
|
|
8
|
+
from specs.azure.clientgenerator.core.override import OverrideClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def client():
|
|
13
|
+
with OverrideClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_reorder_parameters(client: OverrideClient):
|
|
18
|
+
client.reorder_parameters.reorder("param1", "param2")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_group_parameters(client: OverrideClient):
|
|
22
|
+
client.group_parameters.group(param1="param1", param2="param2")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# make sure signature name of `reorder_parameters` are ["param1", "param2"]
|
|
26
|
+
def test_reorder_parameters_unit(client: OverrideClient):
|
|
27
|
+
# Get the reorder method from the reorder_parameters operation
|
|
28
|
+
reorder_method = client.reorder_parameters.reorder
|
|
29
|
+
|
|
30
|
+
# Inspect the method signature
|
|
31
|
+
sig = inspect.signature(reorder_method)
|
|
32
|
+
|
|
33
|
+
# Get parameter names excluding 'self' and '**kwargs'
|
|
34
|
+
param_names = [
|
|
35
|
+
param_name
|
|
36
|
+
for param_name, param in sig.parameters.items()
|
|
37
|
+
if param_name not in ("self", "kwargs") and param.kind != param.VAR_KEYWORD
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
# Assert that the parameter names are exactly ["param1", "param2"]
|
|
41
|
+
assert param_names == ["param1", "param2"], f"Expected parameter names ['param1', 'param2'], but got {param_names}"
|
|
@@ -28,5 +28,5 @@ def test_model_usage(client: UsageClient):
|
|
|
28
28
|
) == client.model_in_operation.model_in_read_only_property(body=models.RoundTripModel())
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
def test_orphan_model_serializable(client: UsageClient):
|
|
32
|
+
client.model_in_operation.orphan_model_serializable(body=models.OrphanModel(model_name="name", description="desc"))
|
|
@@ -3,27 +3,30 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import pytest
|
|
7
|
+
from client.clientnamespace import ClientNamespaceFirstClient
|
|
8
|
+
from client.clientnamespace.first.models import FirstClientResult
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
from client.clientnamespace.second import ClientNamespaceSecondClient
|
|
11
|
+
from client.clientnamespace.second.models import SecondClientResult
|
|
12
|
+
from client.clientnamespace.second.sub.models import SecondClientEnumType
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def first_client():
|
|
17
|
+
with ClientNamespaceFirstClient() as client:
|
|
18
|
+
yield client
|
|
19
19
|
|
|
20
|
-
# @pytest.fixture
|
|
21
|
-
# def second_client():
|
|
22
|
-
# with ClientNamespaceSecondClient() as client:
|
|
23
|
-
# yield client
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
@pytest.fixture
|
|
22
|
+
def second_client():
|
|
23
|
+
with ClientNamespaceSecondClient() as client:
|
|
24
|
+
yield client
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
|
|
27
|
+
def test_get_first(first_client: ClientNamespaceFirstClient):
|
|
28
|
+
assert first_client.get_first() == FirstClientResult(name="first")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_get_second(second_client: ClientNamespaceSecondClient):
|
|
32
|
+
assert second_client.get_second() == SecondClientResult(type=SecondClientEnumType.SECOND)
|