@typespec/http-client-python 0.13.0 → 0.14.0
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/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/component-detection-pip-report.json +2 -2
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- 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 +23 -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 +21 -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
|
|
@@ -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
|
|
@@ -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,23 @@
|
|
|
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.override.aio import OverrideClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with OverrideClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_reorder_parameters(client: OverrideClient):
|
|
18
|
+
await client.reorder_parameters.reorder("param1", "param2")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.asyncio
|
|
22
|
+
async def test_group_parameters(client: OverrideClient):
|
|
23
|
+
await client.group_parameters.group(param1="param1", param2="param2")
|
|
@@ -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,21 @@
|
|
|
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.override import OverrideClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with OverrideClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_reorder_parameters(client: OverrideClient):
|
|
17
|
+
client.reorder_parameters.reorder("param1", "param2")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_group_parameters(client: OverrideClient):
|
|
21
|
+
client.group_parameters.group(param1="param1", param2="param2")
|
|
@@ -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)
|
|
@@ -8,6 +8,8 @@ azure-mgmt-core==1.5.0
|
|
|
8
8
|
-e ./generated/azure-client-generator-core-deserialize-empty-string-as-null
|
|
9
9
|
-e ./generated/azure-client-generator-core-flatten-property
|
|
10
10
|
-e ./generated/azure-client-generator-core-usage
|
|
11
|
+
-e ./generated/azure-client-generator-core-override
|
|
12
|
+
-e ./generated/azure-client-generator-core-client-location
|
|
11
13
|
-e ./generated/azure-core-basic
|
|
12
14
|
-e ./generated/azure-core-scalar
|
|
13
15
|
-e ./generated/azure-core-lro-rpc
|
|
@@ -23,7 +25,7 @@ azure-mgmt-core==1.5.0
|
|
|
23
25
|
-e ./generated/azure-resource-manager-non-resource
|
|
24
26
|
-e ./generated/azure-resource-manager-operation-templates
|
|
25
27
|
-e ./generated/azure-resource-manager-resources
|
|
26
|
-
|
|
28
|
+
-e ./generated/client-namespace
|
|
27
29
|
-e ./generated/azure-payload-pageable
|
|
28
30
|
-e ./generated/client-naming
|
|
29
31
|
-e ./generated/client-structure-default
|
|
@@ -84,6 +86,7 @@ azure-mgmt-core==1.5.0
|
|
|
84
86
|
-e ./generated/payload-media-type
|
|
85
87
|
-e ./generated/payload-xml
|
|
86
88
|
-e ./generated/routes
|
|
89
|
+
-e ./generated/response-status-code-range
|
|
87
90
|
-e ./generated/versioning-added
|
|
88
91
|
-e ./generated/versioning-madeoptional
|
|
89
92
|
-e ./generated/versioning-removed
|
|
@@ -11,6 +11,8 @@ from payload.xml.models import (
|
|
|
11
11
|
ModelWithArrayOfModel,
|
|
12
12
|
ModelWithAttributes,
|
|
13
13
|
ModelWithUnwrappedArray,
|
|
14
|
+
ModelWithRenamedArrays,
|
|
15
|
+
ModelWithOptionalField,
|
|
14
16
|
ModelWithRenamedFields,
|
|
15
17
|
ModelWithEmptyArray,
|
|
16
18
|
ModelWithText,
|
|
@@ -65,6 +67,20 @@ async def test_model_with_unwrapped_array(client: XmlClient):
|
|
|
65
67
|
await client.model_with_unwrapped_array_value.put(model)
|
|
66
68
|
|
|
67
69
|
|
|
70
|
+
@pytest.mark.asyncio
|
|
71
|
+
async def test_model_with_renamed_arrays(client: XmlClient):
|
|
72
|
+
model = ModelWithRenamedArrays(colors=["red", "green", "blue"], counts=[1, 2])
|
|
73
|
+
assert await client.model_with_renamed_arrays_value.get() == model
|
|
74
|
+
await client.model_with_renamed_arrays_value.put(model)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@pytest.mark.asyncio
|
|
78
|
+
async def test_model_with_optional_field(client: XmlClient):
|
|
79
|
+
model = ModelWithOptionalField(item="widget")
|
|
80
|
+
assert await client.model_with_optional_field_value.get() == model
|
|
81
|
+
await client.model_with_optional_field_value.put(model)
|
|
82
|
+
|
|
83
|
+
|
|
68
84
|
@pytest.mark.asyncio
|
|
69
85
|
async def test_model_with_renamed_fields(client: XmlClient):
|
|
70
86
|
model = ModelWithRenamedFields(
|
package/generator/test/generic_mock_api_tests/asynctests/test_response_status_code_range_async.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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 response.statuscoderange.aio import StatusCodeRangeClient
|
|
8
|
+
from response.statuscoderange.models import ErrorInRange, NotFoundError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
async def client():
|
|
13
|
+
async with StatusCodeRangeClient(endpoint="http://localhost:3000") as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.asyncio
|
|
18
|
+
async def test_error_response_status_code_in_range(client: StatusCodeRangeClient):
|
|
19
|
+
with pytest.raises(Exception) as exc_info:
|
|
20
|
+
await client.error_response_status_code_in_range()
|
|
21
|
+
|
|
22
|
+
error = exc_info.value.model
|
|
23
|
+
assert isinstance(error, ErrorInRange)
|
|
24
|
+
assert error.code == "request-header-too-large"
|
|
25
|
+
assert error.message == "Request header too large"
|
|
26
|
+
assert exc_info.value.response.status_code == 494
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.mark.asyncio
|
|
30
|
+
async def test_error_response_status_code_404(client: StatusCodeRangeClient):
|
|
31
|
+
with pytest.raises(Exception) as exc_info:
|
|
32
|
+
await client.error_response_status_code404()
|
|
33
|
+
|
|
34
|
+
error = exc_info.value.model
|
|
35
|
+
assert isinstance(error, NotFoundError)
|
|
36
|
+
assert error.code == "not-found"
|
|
37
|
+
assert error.resource_id == "resource1"
|
|
38
|
+
assert exc_info.value.response.status_code == 404
|
|
@@ -19,3 +19,10 @@ async def test_v2(client: RemovedClient):
|
|
|
19
19
|
assert await client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar")) == ModelV2(
|
|
20
20
|
prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar"
|
|
21
21
|
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
async def test_model_v3(client: RemovedClient):
|
|
26
|
+
result = await client.model_v3({"id": "123", "enumProp": "enumMemberV1"})
|
|
27
|
+
assert result.id == "123"
|
|
28
|
+
assert result.enum_prop == "enumMemberV1"
|
|
@@ -11,6 +11,8 @@ from payload.xml.models import (
|
|
|
11
11
|
ModelWithArrayOfModel,
|
|
12
12
|
ModelWithAttributes,
|
|
13
13
|
ModelWithUnwrappedArray,
|
|
14
|
+
ModelWithRenamedArrays,
|
|
15
|
+
ModelWithOptionalField,
|
|
14
16
|
ModelWithRenamedFields,
|
|
15
17
|
ModelWithEmptyArray,
|
|
16
18
|
ModelWithText,
|
|
@@ -60,6 +62,18 @@ def test_model_with_unwrapped_array(client: XmlClient):
|
|
|
60
62
|
client.model_with_unwrapped_array_value.put(model)
|
|
61
63
|
|
|
62
64
|
|
|
65
|
+
def test_model_with_renamed_arrays(client: XmlClient):
|
|
66
|
+
model = ModelWithRenamedArrays(colors=["red", "green", "blue"], counts=[1, 2])
|
|
67
|
+
assert client.model_with_renamed_arrays_value.get() == model
|
|
68
|
+
client.model_with_renamed_arrays_value.put(model)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_model_with_optional_field(client: XmlClient):
|
|
72
|
+
model = ModelWithOptionalField(item="widget")
|
|
73
|
+
assert client.model_with_optional_field_value.get() == model
|
|
74
|
+
client.model_with_optional_field_value.put(model)
|
|
75
|
+
|
|
76
|
+
|
|
63
77
|
def test_model_with_renamed_fields(client: XmlClient):
|
|
64
78
|
model = ModelWithRenamedFields(
|
|
65
79
|
input_data=SimpleModel(name="foo", age=123),
|
|
@@ -0,0 +1,36 @@
|
|
|
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 response.statuscoderange import StatusCodeRangeClient
|
|
8
|
+
from response.statuscoderange.models import ErrorInRange, NotFoundError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def client():
|
|
13
|
+
with StatusCodeRangeClient(endpoint="http://localhost:3000") as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_error_response_status_code_in_range(client: StatusCodeRangeClient):
|
|
18
|
+
with pytest.raises(Exception) as exc_info:
|
|
19
|
+
client.error_response_status_code_in_range()
|
|
20
|
+
|
|
21
|
+
error = exc_info.value.model
|
|
22
|
+
assert isinstance(error, ErrorInRange)
|
|
23
|
+
assert error.code == "request-header-too-large"
|
|
24
|
+
assert error.message == "Request header too large"
|
|
25
|
+
assert exc_info.value.response.status_code == 494
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_error_response_status_code_404(client: StatusCodeRangeClient):
|
|
29
|
+
with pytest.raises(Exception) as exc_info:
|
|
30
|
+
client.error_response_status_code404()
|
|
31
|
+
|
|
32
|
+
error = exc_info.value.model
|
|
33
|
+
assert isinstance(error, NotFoundError)
|
|
34
|
+
assert error.code == "not-found"
|
|
35
|
+
assert error.resource_id == "resource1"
|
|
36
|
+
assert exc_info.value.response.status_code == 404
|
|
@@ -18,3 +18,9 @@ def test_v2(client: RemovedClient):
|
|
|
18
18
|
assert client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar")) == ModelV2(
|
|
19
19
|
prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar"
|
|
20
20
|
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_model_v3(client: RemovedClient):
|
|
24
|
+
result = client.model_v3({"id": "123", "enumProp": "enumMemberV1"})
|
|
25
|
+
assert result.id == "123"
|
|
26
|
+
assert result.enum_prop == "enumMemberV1"
|