@typespec/http-client-python 0.26.3 → 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.
- package/dist/emitter/http.d.ts.map +1 -1
- package/dist/emitter/http.js +3 -2
- 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/http.ts +4 -1
- package/emitter/src/types.ts +32 -11
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/ci/regenerate.ts +13 -3
- 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/operation.py +5 -1
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +5 -1
- package/generator/component-detection-pip-report.json +7 -7
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/operation.py +5 -1
- package/generator/pygen/codegen/models/paging_operation.py +5 -1
- 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_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_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_payload_multipart.py +27 -0
- package/generator/test/azure/requirements.txt +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 +9 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_file_async.py +59 -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 +8 -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/requirements.txt +1 -0
- package/package.json +32 -32
|
@@ -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"}
|
|
@@ -169,3 +169,30 @@ def test_optional_parts(client: MultiPartClient):
|
|
|
169
169
|
profile_image=open(str(JPG), "rb"),
|
|
170
170
|
)
|
|
171
171
|
)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def test_file_upload_file_specific_content_type(client: MultiPartClient):
|
|
175
|
+
client.form_data.file.upload_file_specific_content_type(
|
|
176
|
+
models.UploadFileSpecificContentTypeRequest(
|
|
177
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_file_upload_file_required_filename(client: MultiPartClient):
|
|
183
|
+
client.form_data.file.upload_file_required_filename(
|
|
184
|
+
models.UploadFileRequiredFilenameRequest(
|
|
185
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def test_file_upload_file_array(client: MultiPartClient):
|
|
191
|
+
client.form_data.file.upload_file_array(
|
|
192
|
+
models.UploadFileArrayRequest(
|
|
193
|
+
files=[
|
|
194
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
195
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
196
|
+
],
|
|
197
|
+
)
|
|
198
|
+
)
|
|
@@ -7,7 +7,9 @@ azure-mgmt-core==1.6.0
|
|
|
7
7
|
-e ./generated/azure-client-generator-core-api-version-header
|
|
8
8
|
-e ./generated/azure-client-generator-core-api-version-path
|
|
9
9
|
-e ./generated/azure-client-generator-core-api-version-query
|
|
10
|
-
-e ./generated/azure-client-generator-core-client-initialization
|
|
10
|
+
-e ./generated/azure-client-generator-core-client-initialization-default
|
|
11
|
+
-e ./generated/azure-client-generator-core-client-initialization-individually
|
|
12
|
+
-e ./generated/azure-client-generator-core-client-initialization-individuallyparent
|
|
11
13
|
-e ./generated/azure-client-generator-core-deserialize-empty-string-as-null
|
|
12
14
|
-e ./generated/azure-client-generator-core-flatten-property
|
|
13
15
|
-e ./generated/azure-client-generator-core-hierarchy-building
|
|
@@ -37,6 +39,8 @@ azure-mgmt-core==1.6.0
|
|
|
37
39
|
-e ./generated/azure-resource-manager-resources
|
|
38
40
|
-e ./generated/azure-resource-manager-method-subscription-id
|
|
39
41
|
-e ./generated/azure-resource-manager-multi-service
|
|
42
|
+
-e ./generated/azure-resource-manager-multi-service-older-versions
|
|
43
|
+
-e ./generated/azure-resource-manager-multi-service-shared-models
|
|
40
44
|
-e ./generated/azure-versioning-previewversion
|
|
41
45
|
-e ./generated/client-namespace
|
|
42
46
|
-e ./generated/azure-payload-pageable
|
|
@@ -80,6 +84,7 @@ azure-mgmt-core==1.6.0
|
|
|
80
84
|
-e ./generated/typetest-dictionary
|
|
81
85
|
-e ./generated/typetest-enum-extensible
|
|
82
86
|
-e ./generated/typetest-enum-fixed
|
|
87
|
+
# -e ./generated/typetest-file
|
|
83
88
|
-e ./generated/typetest-model-enumdiscriminator
|
|
84
89
|
-e ./generated/typetest-model-nesteddiscriminator
|
|
85
90
|
-e ./generated/typetest-model-notdiscriminated
|
|
@@ -115,8 +115,13 @@ async def test_list_without_continuation(client: PageableClient):
|
|
|
115
115
|
assert_result(result)
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
@pytest.mark.asyncio
|
|
119
|
+
async def test_xml_pagination_list_with_continuation(client: PageableClient):
|
|
120
|
+
result = [p async for p in client.xml_pagination.list_with_continuation()]
|
|
121
|
+
assert_result(result)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@pytest.mark.asyncio
|
|
125
|
+
async def test_xml_pagination_list_with_next_link(client: PageableClient):
|
|
126
|
+
result = [p async for p in client.xml_pagination.list_with_next_link()]
|
|
127
|
+
assert_result(result)
|
|
@@ -117,3 +117,12 @@ async def test_model_with_encoded_names(client: XmlClient):
|
|
|
117
117
|
model = ModelWithEncodedNames(model_data=SimpleModel(name="foo", age=123), colors=["red", "green", "blue"])
|
|
118
118
|
assert await client.model_with_encoded_names_value.get() == model
|
|
119
119
|
await client.model_with_encoded_names_value.put(model)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@pytest.mark.asyncio
|
|
123
|
+
async def test_xml_error_value(client: XmlClient, core_library):
|
|
124
|
+
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
125
|
+
await client.xml_error_value.get()
|
|
126
|
+
assert ex.value.status_code == 400
|
|
127
|
+
assert ex.value.model.message == "Something went wrong"
|
|
128
|
+
assert ex.value.model.code == 400
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
# after we support Http.File case, enable these tests again
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# import json
|
|
10
|
+
|
|
11
|
+
# import pytest
|
|
12
|
+
# from typetest.file.aio import FileClient
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# @pytest.fixture
|
|
16
|
+
# async def client():
|
|
17
|
+
# async with FileClient(endpoint="http://localhost:3000") as client:
|
|
18
|
+
# yield client
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# @pytest.mark.asyncio
|
|
22
|
+
# async def test_upload_file_specific_content_type(client: FileClient, png_data: bytes):
|
|
23
|
+
# await client.body.upload_file_specific_content_type(png_data)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# # Do not support this case for now
|
|
27
|
+
# # @pytest.mark.asyncio
|
|
28
|
+
# # async def test_upload_file_json_content_type(client: FileClient):
|
|
29
|
+
# # await client.body.upload_file_json_content_type(json.dumps({"message": "test file content"}).encode())
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# # although result is expected but actually there is deserialization issue
|
|
33
|
+
# # @pytest.mark.asyncio
|
|
34
|
+
# # async def test_download_file_json_content_type(client: FileClient):
|
|
35
|
+
# # result = await client.body.download_file_json_content_type()
|
|
36
|
+
# # assert result == {"message": "test file content"}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# @pytest.mark.asyncio
|
|
40
|
+
# async def test_download_file_specific_content_type(client: FileClient, png_data: bytes):
|
|
41
|
+
# result = b"".join([d async for d in (await client.body.download_file_specific_content_type())])
|
|
42
|
+
# assert result == png_data
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# @pytest.mark.asyncio
|
|
46
|
+
# async def test_download_file_multiple_content_types(client: FileClient, png_data: bytes):
|
|
47
|
+
# result = b"".join([d async for d in (await client.body.download_file_multiple_content_types())])
|
|
48
|
+
# assert result == png_data
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# @pytest.mark.asyncio
|
|
52
|
+
# async def test_upload_file_default_content_type(client: FileClient, png_data: bytes):
|
|
53
|
+
# await client.body.upload_file_default_content_type(png_data, content_type="image/png")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# @pytest.mark.asyncio
|
|
57
|
+
# async def test_download_file_default_content_type(client: FileClient, png_data: bytes):
|
|
58
|
+
# result = b"".join([d async for d in (await client.body.download_file_default_content_type())])
|
|
59
|
+
# assert result == png_data
|
|
@@ -83,7 +83,11 @@ def test_list_without_continuation(client: PageableClient):
|
|
|
83
83
|
assert_result(result)
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
def test_xml_pagination_list_with_continuation(client: PageableClient):
|
|
87
|
+
result = list(client.xml_pagination.list_with_continuation())
|
|
88
|
+
assert_result(result)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_xml_pagination_list_with_next_link(client: PageableClient):
|
|
92
|
+
result = list(client.xml_pagination.list_with_next_link())
|
|
93
|
+
assert_result(result)
|
|
@@ -105,3 +105,11 @@ def test_model_with_encoded_names(client: XmlClient):
|
|
|
105
105
|
model = ModelWithEncodedNames(model_data=SimpleModel(name="foo", age=123), colors=["red", "green", "blue"])
|
|
106
106
|
assert client.model_with_encoded_names_value.get() == model
|
|
107
107
|
client.model_with_encoded_names_value.put(model)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_xml_error_value(client: XmlClient, core_library):
|
|
111
|
+
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
112
|
+
client.xml_error_value.get()
|
|
113
|
+
assert ex.value.status_code == 400
|
|
114
|
+
assert ex.value.model.message == "Something went wrong"
|
|
115
|
+
assert ex.value.model.code == 400
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
|
|
7
|
+
# after we support Http.File case, enable these tests again
|
|
8
|
+
|
|
9
|
+
# import json
|
|
10
|
+
|
|
11
|
+
# import pytest
|
|
12
|
+
# from typetest.file import FileClient
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# @pytest.fixture
|
|
16
|
+
# def client():
|
|
17
|
+
# with FileClient(endpoint="http://localhost:3000") as client:
|
|
18
|
+
# yield client
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# def test_upload_file_specific_content_type(client: FileClient, png_data: bytes):
|
|
22
|
+
# client.body.upload_file_specific_content_type(png_data)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# # Do not support this case for now
|
|
26
|
+
# # def test_upload_file_json_content_type(client: FileClient):
|
|
27
|
+
# # client.body.upload_file_json_content_type(json.dumps({"message": "test file content"}).encode())
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# # although result is expected but actually there is deserialization issue
|
|
31
|
+
# # def test_download_file_json_content_type(client: FileClient):
|
|
32
|
+
# # result = client.body.download_file_json_content_type()
|
|
33
|
+
# # assert result == {"message": "test file content"}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# def test_download_file_specific_content_type(client: FileClient, png_data: bytes):
|
|
37
|
+
# result = b"".join(client.body.download_file_specific_content_type())
|
|
38
|
+
# assert result == png_data
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# def test_download_file_multiple_content_types(client: FileClient, png_data: bytes):
|
|
42
|
+
# result = b"".join(client.body.download_file_multiple_content_types())
|
|
43
|
+
# assert result == png_data
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# def test_upload_file_default_content_type(client: FileClient, png_data: bytes):
|
|
47
|
+
# client.body.upload_file_default_content_type(png_data, content_type="image/png")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# def test_download_file_default_content_type(client: FileClient, png_data: bytes):
|
|
51
|
+
# result = b"".join(client.body.download_file_default_content_type())
|
|
52
|
+
# assert result == png_data
|
|
@@ -8,6 +8,7 @@ import pytest
|
|
|
8
8
|
from payload.multipart import models
|
|
9
9
|
from payload.multipart.aio import MultiPartClient
|
|
10
10
|
from payload.multipart.formdata.httpparts.nonstring.models import FloatRequest
|
|
11
|
+
from payload.multipart.formdata.file import models as file_models
|
|
11
12
|
|
|
12
13
|
JPG = Path(__file__).parent.parent / "data/image.jpg"
|
|
13
14
|
PNG = Path(__file__).parent.parent / "data/image.png"
|
|
@@ -185,3 +186,33 @@ async def test_optional_parts(client: MultiPartClient):
|
|
|
185
186
|
profile_image=open(str(JPG), "rb"),
|
|
186
187
|
)
|
|
187
188
|
)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@pytest.mark.asyncio
|
|
192
|
+
async def test_file_upload_file_specific_content_type(client: MultiPartClient):
|
|
193
|
+
await client.form_data.file.upload_file_specific_content_type(
|
|
194
|
+
file_models.UploadFileSpecificContentTypeRequest(
|
|
195
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
196
|
+
)
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@pytest.mark.asyncio
|
|
201
|
+
async def test_file_upload_file_required_filename(client: MultiPartClient):
|
|
202
|
+
await client.form_data.file.upload_file_required_filename(
|
|
203
|
+
file_models.UploadFileRequiredFilenameRequest(
|
|
204
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@pytest.mark.asyncio
|
|
210
|
+
async def test_file_upload_file_array(client: MultiPartClient):
|
|
211
|
+
await client.form_data.file.upload_file_array(
|
|
212
|
+
file_models.UploadFileArrayRequest(
|
|
213
|
+
files=[
|
|
214
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
215
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
216
|
+
],
|
|
217
|
+
)
|
|
218
|
+
)
|
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
import pytest
|
|
8
8
|
from payload.multipart import MultiPartClient, models
|
|
9
9
|
from payload.multipart.formdata.httpparts.nonstring.models import FloatRequest
|
|
10
|
+
from payload.multipart.formdata.file import models as file_models
|
|
10
11
|
|
|
11
12
|
JPG = Path(__file__).parent / "data/image.jpg"
|
|
12
13
|
PNG = Path(__file__).parent / "data/image.png"
|
|
@@ -170,3 +171,30 @@ def test_optional_parts(client: MultiPartClient):
|
|
|
170
171
|
profile_image=open(str(JPG), "rb"),
|
|
171
172
|
)
|
|
172
173
|
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_file_upload_file_specific_content_type(client: MultiPartClient):
|
|
177
|
+
client.form_data.file.upload_file_specific_content_type(
|
|
178
|
+
file_models.UploadFileSpecificContentTypeRequest(
|
|
179
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def test_file_upload_file_required_filename(client: MultiPartClient):
|
|
185
|
+
client.form_data.file.upload_file_required_filename(
|
|
186
|
+
file_models.UploadFileRequiredFilenameRequest(
|
|
187
|
+
file=("image.png", open(str(PNG), "rb"), "image/png"),
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def test_file_upload_file_array(client: MultiPartClient):
|
|
193
|
+
client.form_data.file.upload_file_array(
|
|
194
|
+
file_models.UploadFileArrayRequest(
|
|
195
|
+
files=[
|
|
196
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
197
|
+
("image.png", open(str(PNG), "rb"), "image/png"),
|
|
198
|
+
],
|
|
199
|
+
)
|
|
200
|
+
)
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
-e ./generated/typetest-dictionary
|
|
30
30
|
-e ./generated/typetest-enum-extensible
|
|
31
31
|
-e ./generated/typetest-enum-fixed
|
|
32
|
+
# -e ./generated/typetest-file
|
|
32
33
|
-e ./generated/typetest-model-enumdiscriminator
|
|
33
34
|
-e ./generated/typetest-model-nesteddiscriminator
|
|
34
35
|
-e ./generated/typetest-model-notdiscriminated
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"emitter"
|
|
55
55
|
],
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@azure-tools/typespec-autorest": ">=0.
|
|
58
|
-
"@azure-tools/typespec-azure-core": ">=0.
|
|
59
|
-
"@azure-tools/typespec-azure-resource-manager": ">=0.
|
|
60
|
-
"@azure-tools/typespec-azure-rulesets": ">=0.
|
|
61
|
-
"@azure-tools/typespec-client-generator-core": ">=0.
|
|
62
|
-
"@typespec/compiler": "^1.
|
|
63
|
-
"@typespec/http": "^1.
|
|
64
|
-
"@typespec/openapi": "^1.
|
|
65
|
-
"@typespec/rest": ">=0.
|
|
66
|
-
"@typespec/versioning": ">=0.
|
|
67
|
-
"@typespec/events": ">=0.
|
|
68
|
-
"@typespec/sse": ">=0.
|
|
69
|
-
"@typespec/streams": ">=0.
|
|
70
|
-
"@typespec/xml": ">=0.
|
|
57
|
+
"@azure-tools/typespec-autorest": ">=0.65.0 <1.0.0",
|
|
58
|
+
"@azure-tools/typespec-azure-core": ">=0.65.0 <1.0.0",
|
|
59
|
+
"@azure-tools/typespec-azure-resource-manager": ">=0.65.0 <1.0.0",
|
|
60
|
+
"@azure-tools/typespec-azure-rulesets": ">=0.65.0 <1.0.0",
|
|
61
|
+
"@azure-tools/typespec-client-generator-core": ">=0.65.0 <1.0.0",
|
|
62
|
+
"@typespec/compiler": "^1.9.0",
|
|
63
|
+
"@typespec/http": "^1.9.0",
|
|
64
|
+
"@typespec/openapi": "^1.9.0",
|
|
65
|
+
"@typespec/rest": ">=0.79.0 <1.0.0",
|
|
66
|
+
"@typespec/versioning": ">=0.79.0 <1.0.0",
|
|
67
|
+
"@typespec/events": ">=0.79.0 <1.0.0",
|
|
68
|
+
"@typespec/sse": ">=0.79.0 <1.0.0",
|
|
69
|
+
"@typespec/streams": ">=0.79.0 <1.0.0",
|
|
70
|
+
"@typespec/xml": ">=0.79.0 <1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"js-yaml": "~4.1.0",
|
|
@@ -77,24 +77,24 @@
|
|
|
77
77
|
"tsx": "~4.19.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@azure-tools/typespec-autorest": "~0.
|
|
81
|
-
"@azure-tools/typespec-azure-core": "~0.
|
|
82
|
-
"@azure-tools/typespec-azure-resource-manager": "~0.
|
|
83
|
-
"@azure-tools/typespec-azure-rulesets": "~0.
|
|
84
|
-
"@azure-tools/typespec-client-generator-core": "~0.
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
86
|
-
"@typespec/compiler": "^1.
|
|
87
|
-
"@typespec/http": "^1.
|
|
88
|
-
"@typespec/openapi": "^1.
|
|
89
|
-
"@typespec/rest": "~0.
|
|
90
|
-
"@typespec/versioning": "~0.
|
|
91
|
-
"@typespec/events": "~0.
|
|
92
|
-
"@typespec/spector": "0.1.0-alpha.
|
|
80
|
+
"@azure-tools/typespec-autorest": "~0.65.0",
|
|
81
|
+
"@azure-tools/typespec-azure-core": "~0.65.0",
|
|
82
|
+
"@azure-tools/typespec-azure-resource-manager": "~0.65.0",
|
|
83
|
+
"@azure-tools/typespec-azure-rulesets": "~0.65.0",
|
|
84
|
+
"@azure-tools/typespec-client-generator-core": "~0.65.0",
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.37",
|
|
86
|
+
"@typespec/compiler": "^1.9.0",
|
|
87
|
+
"@typespec/http": "^1.9.0",
|
|
88
|
+
"@typespec/openapi": "^1.9.0",
|
|
89
|
+
"@typespec/rest": "~0.79.0",
|
|
90
|
+
"@typespec/versioning": "~0.79.0",
|
|
91
|
+
"@typespec/events": "~0.79.0",
|
|
92
|
+
"@typespec/spector": "0.1.0-alpha.23",
|
|
93
93
|
"@typespec/spec-api": "0.1.0-alpha.12",
|
|
94
|
-
"@typespec/sse": "~0.
|
|
95
|
-
"@typespec/streams": "~0.
|
|
96
|
-
"@typespec/xml": "~0.
|
|
97
|
-
"@typespec/http-specs": "0.1.0-alpha.32
|
|
94
|
+
"@typespec/sse": "~0.79.0",
|
|
95
|
+
"@typespec/streams": "~0.79.0",
|
|
96
|
+
"@typespec/xml": "~0.79.0",
|
|
97
|
+
"@typespec/http-specs": "0.1.0-alpha.32",
|
|
98
98
|
"@types/js-yaml": "~4.0.5",
|
|
99
99
|
"@types/node": "~24.1.0",
|
|
100
100
|
"@types/semver": "7.5.8",
|