@typespec/http-client-python 0.24.1 → 0.26.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/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +5 -1
- package/dist/emitter/code-model.js.map +1 -1
- package/dist/emitter/http.d.ts.map +1 -1
- package/dist/emitter/http.js +9 -1
- package/dist/emitter/http.js.map +1 -1
- package/emitter/src/code-model.ts +5 -1
- package/emitter/src/http.ts +9 -1
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- 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/paging_operation.py +10 -0
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +24 -2
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +20 -10
- package/generator/component-detection-pip-report.json +4 -4
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/paging_operation.py +10 -0
- package/generator/pygen/codegen/serializers/builder_serializer.py +24 -2
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +20 -10
- package/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +5 -0
- package/generator/test/azure/mock_api_tests/test_special_words.py +4 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_array_async.py +96 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +7 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_specs_documentation_async.py +1 -2
- package/generator/test/generic_mock_api_tests/test_encode_array.py +88 -0
- package/generator/test/generic_mock_api_tests/test_payload_pageable.py +6 -0
- package/generator/test/generic_mock_api_tests/test_specs_documentation.py +0 -1
- package/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +23 -0
- package/generator/test/unbranded/mock_api_tests/test_special_words.py +21 -0
- package/generator/test/unittests/test_model_base_serialization.py +53 -0
- package/package.json +5 -5
|
Binary file
|
|
Binary file
|
|
@@ -73,6 +73,13 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
73
73
|
def next_variable_name(self) -> str:
|
|
74
74
|
return "_continuation_token" if self.has_continuation_token else "next_link"
|
|
75
75
|
|
|
76
|
+
@property
|
|
77
|
+
def is_xml_paging(self) -> bool:
|
|
78
|
+
try:
|
|
79
|
+
return bool(self.responses[0].item_type.xml_metadata)
|
|
80
|
+
except KeyError:
|
|
81
|
+
return False
|
|
82
|
+
|
|
76
83
|
def _get_attr_name(self, wire_name: str) -> str:
|
|
77
84
|
response_type = self.responses[0].type
|
|
78
85
|
if not response_type:
|
|
@@ -176,6 +183,9 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
176
183
|
file_import.merge(self.item_type.imports(**kwargs))
|
|
177
184
|
if self.default_error_deserialization(serialize_namespace) or self.need_deserialize:
|
|
178
185
|
file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
|
|
186
|
+
if self.is_xml_paging:
|
|
187
|
+
file_import.add_submodule_import("xml.etree", "ElementTree", ImportType.STDLIB, alias="ET")
|
|
188
|
+
file_import.add_submodule_import(relative_path, "_convert_element", ImportType.LOCAL)
|
|
179
189
|
return file_import
|
|
180
190
|
|
|
181
191
|
|
|
@@ -1372,10 +1372,15 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1372
1372
|
def _function_def(self) -> str:
|
|
1373
1373
|
return "def"
|
|
1374
1374
|
|
|
1375
|
-
def _extract_data_callback(
|
|
1375
|
+
def _extract_data_callback( # pylint: disable=too-many-statements,too-many-branches
|
|
1376
|
+
self, builder: PagingOperationType
|
|
1377
|
+
) -> list[str]:
|
|
1376
1378
|
retval = [f"{'async ' if self.async_mode else ''}def extract_data(pipeline_response):"]
|
|
1377
1379
|
response = builder.responses[0]
|
|
1378
|
-
|
|
1380
|
+
if builder.is_xml_paging:
|
|
1381
|
+
deserialized = "ET.fromstring(pipeline_response.http_response.text())"
|
|
1382
|
+
else:
|
|
1383
|
+
deserialized = "pipeline_response.http_response.json()"
|
|
1379
1384
|
if self.code_model.options["models-mode"] == "msrest":
|
|
1380
1385
|
suffix = ".http_response" if hasattr(builder, "initial_operation") else ""
|
|
1381
1386
|
deserialize_type = response.serialization_type(serialize_namespace=self.serialize_namespace)
|
|
@@ -1395,6 +1400,10 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1395
1400
|
item_name = builder.item_name
|
|
1396
1401
|
if self.code_model.options["models-mode"] == "msrest":
|
|
1397
1402
|
access = f".{item_name}"
|
|
1403
|
+
elif builder.is_xml_paging:
|
|
1404
|
+
# For XML, use .find() to navigate the element tree
|
|
1405
|
+
item_name_array = item_name.split(".")
|
|
1406
|
+
access = "".join([f'.find("{i}")' for i in item_name_array])
|
|
1398
1407
|
else:
|
|
1399
1408
|
item_name_array = item_name.split(".")
|
|
1400
1409
|
access = (
|
|
@@ -1412,11 +1421,17 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1412
1421
|
retval.append(" if cls:")
|
|
1413
1422
|
retval.append(" list_of_elem = cls(list_of_elem) # type: ignore")
|
|
1414
1423
|
|
|
1424
|
+
cont_token_expr: Optional[str] = None # For XML, we need to extract find() result first
|
|
1415
1425
|
if builder.has_continuation_token:
|
|
1416
1426
|
location = builder.continuation_token.get("output", {}).get("location")
|
|
1417
1427
|
wire_name = builder.continuation_token.get("output", {}).get("wireName") or ""
|
|
1418
1428
|
if location == "header":
|
|
1419
1429
|
cont_token_property = f'pipeline_response.http_response.headers.get("{wire_name}") or None'
|
|
1430
|
+
elif builder.is_xml_paging:
|
|
1431
|
+
wire_name_array = wire_name.split(".")
|
|
1432
|
+
wire_name_call = "".join([f'.find("{i}")' for i in wire_name_array])
|
|
1433
|
+
cont_token_expr = f"deserialized{wire_name_call}"
|
|
1434
|
+
cont_token_property = "_cont_token_elem.text if _cont_token_elem is not None else None"
|
|
1420
1435
|
else:
|
|
1421
1436
|
wire_name_array = wire_name.split(".")
|
|
1422
1437
|
wire_name_call = (
|
|
@@ -1429,6 +1444,11 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1429
1444
|
cont_token_property = "None"
|
|
1430
1445
|
elif self.code_model.options["models-mode"] == "msrest":
|
|
1431
1446
|
cont_token_property = f"deserialized.{next_link_name} or None"
|
|
1447
|
+
elif builder.is_xml_paging:
|
|
1448
|
+
next_link_name_array = next_link_name.split(".")
|
|
1449
|
+
access = "".join([f'.find("{i}")' for i in next_link_name_array])
|
|
1450
|
+
cont_token_expr = f"deserialized{access}"
|
|
1451
|
+
cont_token_property = "_cont_token_elem.text if _cont_token_elem is not None else None"
|
|
1432
1452
|
elif builder.next_link_is_nested:
|
|
1433
1453
|
next_link_name_array = next_link_name.split(".")
|
|
1434
1454
|
access = (
|
|
@@ -1439,6 +1459,8 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1439
1459
|
else:
|
|
1440
1460
|
cont_token_property = f'deserialized.get("{next_link_name}") or None'
|
|
1441
1461
|
list_type = "AsyncList" if self.async_mode else "iter"
|
|
1462
|
+
if cont_token_expr:
|
|
1463
|
+
retval.append(f" _cont_token_elem = {cont_token_expr}")
|
|
1442
1464
|
retval.append(f" return {cont_token_property}, {list_type}(list_of_elem)")
|
|
1443
1465
|
return retval
|
|
1444
1466
|
|
|
@@ -848,6 +848,14 @@ def _deserialize_multiple_sequence(
|
|
|
848
848
|
return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers))
|
|
849
849
|
|
|
850
850
|
|
|
851
|
+
def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool:
|
|
852
|
+
return (
|
|
853
|
+
isinstance(deserializer, functools.partial)
|
|
854
|
+
and isinstance(deserializer.args[0], functools.partial)
|
|
855
|
+
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
|
|
851
859
|
def _deserialize_sequence(
|
|
852
860
|
deserializer: typing.Optional[typing.Callable],
|
|
853
861
|
module: typing.Optional[str],
|
|
@@ -857,17 +865,19 @@ def _deserialize_sequence(
|
|
|
857
865
|
return obj
|
|
858
866
|
if isinstance(obj, ET.Element):
|
|
859
867
|
obj = list(obj)
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
|
|
866
|
-
):
|
|
867
|
-
# encoded string may be deserialized to sequence
|
|
868
|
+
|
|
869
|
+
# encoded string may be deserialized to sequence
|
|
870
|
+
if isinstance(obj, str) and isinstance(deserializer, functools.partial):
|
|
871
|
+
# for list[str]
|
|
872
|
+
if _is_array_encoded_deserializer(deserializer):
|
|
868
873
|
return deserializer(obj)
|
|
869
|
-
|
|
870
|
-
|
|
874
|
+
|
|
875
|
+
# for list[Union[...]]
|
|
876
|
+
if isinstance(deserializer.args[0], list):
|
|
877
|
+
for sub_deserializer in deserializer.args[0]:
|
|
878
|
+
if _is_array_encoded_deserializer(sub_deserializer):
|
|
879
|
+
return sub_deserializer(obj)
|
|
880
|
+
|
|
871
881
|
return type(obj)(_deserialize(deserializer, entry, module) for entry in obj)
|
|
872
882
|
|
|
873
883
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"install": [
|
|
5
5
|
{
|
|
6
6
|
"download_info": {
|
|
7
|
-
"url": "https://files.pythonhosted.org/packages/
|
|
7
|
+
"url": "https://files.pythonhosted.org/packages/94/b8/f1f62a5e3c0ad2ff1d189590bfa4c46b4f3b6e49cef6f26c6ee4e575394d/setuptools-80.10.2-py3-none-any.whl",
|
|
8
8
|
"archive_info": {
|
|
9
|
-
"hash": "sha256=
|
|
9
|
+
"hash": "sha256=95b30ddfb717250edb492926c92b5221f7ef3fbcc2b07579bcd4a27da21d0173",
|
|
10
10
|
"hashes": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "95b30ddfb717250edb492926c92b5221f7ef3fbcc2b07579bcd4a27da21d0173"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"metadata": {
|
|
19
19
|
"metadata_version": "2.4",
|
|
20
20
|
"name": "setuptools",
|
|
21
|
-
"version": "80.
|
|
21
|
+
"version": "80.10.2",
|
|
22
22
|
"dynamic": [
|
|
23
23
|
"license-file"
|
|
24
24
|
],
|
|
Binary file
|
|
@@ -73,6 +73,13 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
73
73
|
def next_variable_name(self) -> str:
|
|
74
74
|
return "_continuation_token" if self.has_continuation_token else "next_link"
|
|
75
75
|
|
|
76
|
+
@property
|
|
77
|
+
def is_xml_paging(self) -> bool:
|
|
78
|
+
try:
|
|
79
|
+
return bool(self.responses[0].item_type.xml_metadata)
|
|
80
|
+
except KeyError:
|
|
81
|
+
return False
|
|
82
|
+
|
|
76
83
|
def _get_attr_name(self, wire_name: str) -> str:
|
|
77
84
|
response_type = self.responses[0].type
|
|
78
85
|
if not response_type:
|
|
@@ -176,6 +183,9 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
176
183
|
file_import.merge(self.item_type.imports(**kwargs))
|
|
177
184
|
if self.default_error_deserialization(serialize_namespace) or self.need_deserialize:
|
|
178
185
|
file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
|
|
186
|
+
if self.is_xml_paging:
|
|
187
|
+
file_import.add_submodule_import("xml.etree", "ElementTree", ImportType.STDLIB, alias="ET")
|
|
188
|
+
file_import.add_submodule_import(relative_path, "_convert_element", ImportType.LOCAL)
|
|
179
189
|
return file_import
|
|
180
190
|
|
|
181
191
|
|
|
@@ -1372,10 +1372,15 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1372
1372
|
def _function_def(self) -> str:
|
|
1373
1373
|
return "def"
|
|
1374
1374
|
|
|
1375
|
-
def _extract_data_callback(
|
|
1375
|
+
def _extract_data_callback( # pylint: disable=too-many-statements,too-many-branches
|
|
1376
|
+
self, builder: PagingOperationType
|
|
1377
|
+
) -> list[str]:
|
|
1376
1378
|
retval = [f"{'async ' if self.async_mode else ''}def extract_data(pipeline_response):"]
|
|
1377
1379
|
response = builder.responses[0]
|
|
1378
|
-
|
|
1380
|
+
if builder.is_xml_paging:
|
|
1381
|
+
deserialized = "ET.fromstring(pipeline_response.http_response.text())"
|
|
1382
|
+
else:
|
|
1383
|
+
deserialized = "pipeline_response.http_response.json()"
|
|
1379
1384
|
if self.code_model.options["models-mode"] == "msrest":
|
|
1380
1385
|
suffix = ".http_response" if hasattr(builder, "initial_operation") else ""
|
|
1381
1386
|
deserialize_type = response.serialization_type(serialize_namespace=self.serialize_namespace)
|
|
@@ -1395,6 +1400,10 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1395
1400
|
item_name = builder.item_name
|
|
1396
1401
|
if self.code_model.options["models-mode"] == "msrest":
|
|
1397
1402
|
access = f".{item_name}"
|
|
1403
|
+
elif builder.is_xml_paging:
|
|
1404
|
+
# For XML, use .find() to navigate the element tree
|
|
1405
|
+
item_name_array = item_name.split(".")
|
|
1406
|
+
access = "".join([f'.find("{i}")' for i in item_name_array])
|
|
1398
1407
|
else:
|
|
1399
1408
|
item_name_array = item_name.split(".")
|
|
1400
1409
|
access = (
|
|
@@ -1412,11 +1421,17 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1412
1421
|
retval.append(" if cls:")
|
|
1413
1422
|
retval.append(" list_of_elem = cls(list_of_elem) # type: ignore")
|
|
1414
1423
|
|
|
1424
|
+
cont_token_expr: Optional[str] = None # For XML, we need to extract find() result first
|
|
1415
1425
|
if builder.has_continuation_token:
|
|
1416
1426
|
location = builder.continuation_token.get("output", {}).get("location")
|
|
1417
1427
|
wire_name = builder.continuation_token.get("output", {}).get("wireName") or ""
|
|
1418
1428
|
if location == "header":
|
|
1419
1429
|
cont_token_property = f'pipeline_response.http_response.headers.get("{wire_name}") or None'
|
|
1430
|
+
elif builder.is_xml_paging:
|
|
1431
|
+
wire_name_array = wire_name.split(".")
|
|
1432
|
+
wire_name_call = "".join([f'.find("{i}")' for i in wire_name_array])
|
|
1433
|
+
cont_token_expr = f"deserialized{wire_name_call}"
|
|
1434
|
+
cont_token_property = "_cont_token_elem.text if _cont_token_elem is not None else None"
|
|
1420
1435
|
else:
|
|
1421
1436
|
wire_name_array = wire_name.split(".")
|
|
1422
1437
|
wire_name_call = (
|
|
@@ -1429,6 +1444,11 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1429
1444
|
cont_token_property = "None"
|
|
1430
1445
|
elif self.code_model.options["models-mode"] == "msrest":
|
|
1431
1446
|
cont_token_property = f"deserialized.{next_link_name} or None"
|
|
1447
|
+
elif builder.is_xml_paging:
|
|
1448
|
+
next_link_name_array = next_link_name.split(".")
|
|
1449
|
+
access = "".join([f'.find("{i}")' for i in next_link_name_array])
|
|
1450
|
+
cont_token_expr = f"deserialized{access}"
|
|
1451
|
+
cont_token_property = "_cont_token_elem.text if _cont_token_elem is not None else None"
|
|
1432
1452
|
elif builder.next_link_is_nested:
|
|
1433
1453
|
next_link_name_array = next_link_name.split(".")
|
|
1434
1454
|
access = (
|
|
@@ -1439,6 +1459,8 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1439
1459
|
else:
|
|
1440
1460
|
cont_token_property = f'deserialized.get("{next_link_name}") or None'
|
|
1441
1461
|
list_type = "AsyncList" if self.async_mode else "iter"
|
|
1462
|
+
if cont_token_expr:
|
|
1463
|
+
retval.append(f" _cont_token_elem = {cont_token_expr}")
|
|
1442
1464
|
retval.append(f" return {cont_token_property}, {list_type}(list_of_elem)")
|
|
1443
1465
|
return retval
|
|
1444
1466
|
|
|
@@ -848,6 +848,14 @@ def _deserialize_multiple_sequence(
|
|
|
848
848
|
return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers))
|
|
849
849
|
|
|
850
850
|
|
|
851
|
+
def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool:
|
|
852
|
+
return (
|
|
853
|
+
isinstance(deserializer, functools.partial)
|
|
854
|
+
and isinstance(deserializer.args[0], functools.partial)
|
|
855
|
+
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
|
|
851
859
|
def _deserialize_sequence(
|
|
852
860
|
deserializer: typing.Optional[typing.Callable],
|
|
853
861
|
module: typing.Optional[str],
|
|
@@ -857,17 +865,19 @@ def _deserialize_sequence(
|
|
|
857
865
|
return obj
|
|
858
866
|
if isinstance(obj, ET.Element):
|
|
859
867
|
obj = list(obj)
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable
|
|
866
|
-
):
|
|
867
|
-
# encoded string may be deserialized to sequence
|
|
868
|
+
|
|
869
|
+
# encoded string may be deserialized to sequence
|
|
870
|
+
if isinstance(obj, str) and isinstance(deserializer, functools.partial):
|
|
871
|
+
# for list[str]
|
|
872
|
+
if _is_array_encoded_deserializer(deserializer):
|
|
868
873
|
return deserializer(obj)
|
|
869
|
-
|
|
870
|
-
|
|
874
|
+
|
|
875
|
+
# for list[Union[...]]
|
|
876
|
+
if isinstance(deserializer.args[0], list):
|
|
877
|
+
for sub_deserializer in deserializer.args[0]:
|
|
878
|
+
if _is_array_encoded_deserializer(sub_deserializer):
|
|
879
|
+
return sub_deserializer(obj)
|
|
880
|
+
|
|
871
881
|
return type(obj)(_deserialize(deserializer, entry, module) for entry in obj)
|
|
872
882
|
|
|
873
883
|
|
|
@@ -58,3 +58,8 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient):
|
|
|
58
58
|
copy_property="ok",
|
|
59
59
|
)
|
|
60
60
|
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@pytest.mark.asyncio
|
|
64
|
+
async def test_model_properties_with_list(client: SpecialWordsClient):
|
|
65
|
+
await client.model_properties.with_list(models.ModelWithList(list="ok"))
|
|
@@ -41,3 +41,99 @@ async def test_newline_delimited(client: ArrayClient):
|
|
|
41
41
|
body = models.NewlineDelimitedArrayProperty(value=["blue", "red", "green"])
|
|
42
42
|
result = await client.property.newline_delimited(body)
|
|
43
43
|
assert result.value == ["blue", "red", "green"]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_enum_comma_delimited(client: ArrayClient):
|
|
48
|
+
body = models.CommaDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
49
|
+
result = await client.property.enum_comma_delimited(body)
|
|
50
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.asyncio
|
|
54
|
+
async def test_enum_space_delimited(client: ArrayClient):
|
|
55
|
+
body = models.SpaceDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
56
|
+
result = await client.property.enum_space_delimited(body)
|
|
57
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@pytest.mark.asyncio
|
|
61
|
+
async def test_enum_pipe_delimited(client: ArrayClient):
|
|
62
|
+
body = models.PipeDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
63
|
+
result = await client.property.enum_pipe_delimited(body)
|
|
64
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.asyncio
|
|
68
|
+
async def test_enum_newline_delimited(client: ArrayClient):
|
|
69
|
+
body = models.NewlineDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
70
|
+
result = await client.property.enum_newline_delimited(body)
|
|
71
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@pytest.mark.asyncio
|
|
75
|
+
async def test_extensible_enum_comma_delimited(client: ArrayClient):
|
|
76
|
+
body = models.CommaDelimitedExtensibleEnumArrayProperty(
|
|
77
|
+
value=[
|
|
78
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
79
|
+
models.ColorsExtensibleEnum.RED,
|
|
80
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
81
|
+
]
|
|
82
|
+
)
|
|
83
|
+
result = await client.property.extensible_enum_comma_delimited(body)
|
|
84
|
+
assert result.value == [
|
|
85
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
86
|
+
models.ColorsExtensibleEnum.RED,
|
|
87
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@pytest.mark.asyncio
|
|
92
|
+
async def test_extensible_enum_space_delimited(client: ArrayClient):
|
|
93
|
+
body = models.SpaceDelimitedExtensibleEnumArrayProperty(
|
|
94
|
+
value=[
|
|
95
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
96
|
+
models.ColorsExtensibleEnum.RED,
|
|
97
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
result = await client.property.extensible_enum_space_delimited(body)
|
|
101
|
+
assert result.value == [
|
|
102
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
103
|
+
models.ColorsExtensibleEnum.RED,
|
|
104
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.asyncio
|
|
109
|
+
async def test_extensible_enum_pipe_delimited(client: ArrayClient):
|
|
110
|
+
body = models.PipeDelimitedExtensibleEnumArrayProperty(
|
|
111
|
+
value=[
|
|
112
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
113
|
+
models.ColorsExtensibleEnum.RED,
|
|
114
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
result = await client.property.extensible_enum_pipe_delimited(body)
|
|
118
|
+
assert result.value == [
|
|
119
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
120
|
+
models.ColorsExtensibleEnum.RED,
|
|
121
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@pytest.mark.asyncio
|
|
126
|
+
async def test_extensible_enum_newline_delimited(client: ArrayClient):
|
|
127
|
+
body = models.NewlineDelimitedExtensibleEnumArrayProperty(
|
|
128
|
+
value=[
|
|
129
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
130
|
+
models.ColorsExtensibleEnum.RED,
|
|
131
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
132
|
+
]
|
|
133
|
+
)
|
|
134
|
+
result = await client.property.extensible_enum_newline_delimited(body)
|
|
135
|
+
assert result.value == [
|
|
136
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
137
|
+
models.ColorsExtensibleEnum.RED,
|
|
138
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
139
|
+
]
|
|
@@ -113,3 +113,10 @@ async def test_request_header_nested_response_body(client: PageableClient):
|
|
|
113
113
|
async def test_list_without_continuation(client: PageableClient):
|
|
114
114
|
result = [p async for p in client.page_size.list_without_continuation()]
|
|
115
115
|
assert_result(result)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# after https://github.com/microsoft/typespec/pull/9455 released, we could enable this test again
|
|
119
|
+
# @pytest.mark.asyncio
|
|
120
|
+
# async def test_xml_pagination_list_with_next_link(client: PageableClient):
|
|
121
|
+
# result = [p async for p in client.xml_pagination.list_with_next_link()]
|
|
122
|
+
# assert_result(result)
|
|
@@ -22,11 +22,10 @@ class TestLists:
|
|
|
22
22
|
# Expected: 204 No Content
|
|
23
23
|
await client.lists.bullet_points_op()
|
|
24
24
|
|
|
25
|
-
@pytest.mark.skip(reason="https://github.com/microsoft/typespec/issues/9173")
|
|
26
25
|
@pytest.mark.asyncio
|
|
27
26
|
async def test_bullet_points_model(self, client: DocumentationClient):
|
|
28
27
|
# POST /documentation/lists/bullet-points/model
|
|
29
|
-
# Expected request body: {"prop": "Simple"}
|
|
28
|
+
# Expected request body: {"input": {"prop": "Simple"}}
|
|
30
29
|
# Expected: 200 OK
|
|
31
30
|
await client.lists.bullet_points_model(input=models.BulletPointsModel(prop="Simple"))
|
|
32
31
|
|
|
@@ -36,3 +36,91 @@ def test_newline_delimited(client: ArrayClient):
|
|
|
36
36
|
body = models.NewlineDelimitedArrayProperty(value=["blue", "red", "green"])
|
|
37
37
|
result = client.property.newline_delimited(body)
|
|
38
38
|
assert result.value == ["blue", "red", "green"]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_enum_comma_delimited(client: ArrayClient):
|
|
42
|
+
body = models.CommaDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
43
|
+
result = client.property.enum_comma_delimited(body)
|
|
44
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_enum_space_delimited(client: ArrayClient):
|
|
48
|
+
body = models.SpaceDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
49
|
+
result = client.property.enum_space_delimited(body)
|
|
50
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_enum_pipe_delimited(client: ArrayClient):
|
|
54
|
+
body = models.PipeDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
55
|
+
result = client.property.enum_pipe_delimited(body)
|
|
56
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_enum_newline_delimited(client: ArrayClient):
|
|
60
|
+
body = models.NewlineDelimitedEnumArrayProperty(value=[models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN])
|
|
61
|
+
result = client.property.enum_newline_delimited(body)
|
|
62
|
+
assert result.value == [models.Colors.BLUE, models.Colors.RED, models.Colors.GREEN]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_extensible_enum_comma_delimited(client: ArrayClient):
|
|
66
|
+
body = models.CommaDelimitedExtensibleEnumArrayProperty(
|
|
67
|
+
value=[
|
|
68
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
69
|
+
models.ColorsExtensibleEnum.RED,
|
|
70
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
71
|
+
]
|
|
72
|
+
)
|
|
73
|
+
result = client.property.extensible_enum_comma_delimited(body)
|
|
74
|
+
assert result.value == [
|
|
75
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
76
|
+
models.ColorsExtensibleEnum.RED,
|
|
77
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_extensible_enum_space_delimited(client: ArrayClient):
|
|
82
|
+
body = models.SpaceDelimitedExtensibleEnumArrayProperty(
|
|
83
|
+
value=[
|
|
84
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
85
|
+
models.ColorsExtensibleEnum.RED,
|
|
86
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
87
|
+
]
|
|
88
|
+
)
|
|
89
|
+
result = client.property.extensible_enum_space_delimited(body)
|
|
90
|
+
assert result.value == [
|
|
91
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
92
|
+
models.ColorsExtensibleEnum.RED,
|
|
93
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_extensible_enum_pipe_delimited(client: ArrayClient):
|
|
98
|
+
body = models.PipeDelimitedExtensibleEnumArrayProperty(
|
|
99
|
+
value=[
|
|
100
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
101
|
+
models.ColorsExtensibleEnum.RED,
|
|
102
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
103
|
+
]
|
|
104
|
+
)
|
|
105
|
+
result = client.property.extensible_enum_pipe_delimited(body)
|
|
106
|
+
assert result.value == [
|
|
107
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
108
|
+
models.ColorsExtensibleEnum.RED,
|
|
109
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_extensible_enum_newline_delimited(client: ArrayClient):
|
|
114
|
+
body = models.NewlineDelimitedExtensibleEnumArrayProperty(
|
|
115
|
+
value=[
|
|
116
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
117
|
+
models.ColorsExtensibleEnum.RED,
|
|
118
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
result = client.property.extensible_enum_newline_delimited(body)
|
|
122
|
+
assert result.value == [
|
|
123
|
+
models.ColorsExtensibleEnum.BLUE,
|
|
124
|
+
models.ColorsExtensibleEnum.RED,
|
|
125
|
+
models.ColorsExtensibleEnum.GREEN,
|
|
126
|
+
]
|
|
@@ -81,3 +81,9 @@ def test_request_header_nested_response_body(client: PageableClient):
|
|
|
81
81
|
def test_list_without_continuation(client: PageableClient):
|
|
82
82
|
result = list(client.page_size.list_without_continuation())
|
|
83
83
|
assert_result(result)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# # after https://github.com/microsoft/typespec/pull/9455 released, we could enable this test again
|
|
87
|
+
# def test_xml_pagination_list_with_next_link(client: PageableClient):
|
|
88
|
+
# result = list(client.xml_pagination.list_with_next_link())
|
|
89
|
+
# assert_result(result)
|
|
@@ -20,7 +20,6 @@ class TestLists:
|
|
|
20
20
|
# Expected: 204 No Content
|
|
21
21
|
client.lists.bullet_points_op()
|
|
22
22
|
|
|
23
|
-
@pytest.mark.skip(reason="https://github.com/microsoft/typespec/issues/9173")
|
|
24
23
|
def test_bullet_points_model(self, client: DocumentationClient):
|
|
25
24
|
# POST /documentation/lists/bullet-points/model
|
|
26
25
|
# Expected: 200 OK
|
|
@@ -41,3 +41,26 @@ async def test_model(client: SpecialWordsClient, special_words):
|
|
|
41
41
|
@pytest.mark.asyncio
|
|
42
42
|
async def test_model_properties(client: SpecialWordsClient):
|
|
43
43
|
await client.model_properties.same_as_model(model_properties_models.SameAsModel(same_as_model="ok"))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_model_properties_dict_methods(client: SpecialWordsClient):
|
|
48
|
+
await client.model_properties.dict_methods(
|
|
49
|
+
body=model_properties_models.DictMethods(
|
|
50
|
+
keys_property="ok",
|
|
51
|
+
items_property="ok",
|
|
52
|
+
values_property="ok",
|
|
53
|
+
popitem_property="ok",
|
|
54
|
+
clear_property="ok",
|
|
55
|
+
update_property="ok",
|
|
56
|
+
setdefault_property="ok",
|
|
57
|
+
pop_property="ok",
|
|
58
|
+
get_property="ok",
|
|
59
|
+
copy_property="ok",
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.asyncio
|
|
65
|
+
async def test_model_properties_with_list(client: SpecialWordsClient):
|
|
66
|
+
await client.model_properties.with_list(model_properties_models.ModelWithList(list="ok"))
|
|
@@ -37,3 +37,24 @@ def test_model(client: SpecialWordsClient, special_words):
|
|
|
37
37
|
|
|
38
38
|
def test_model_properties(client: SpecialWordsClient):
|
|
39
39
|
client.model_properties.same_as_model(model_properties_models.SameAsModel(same_as_model="ok"))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_model_properties_dict_methods(client: SpecialWordsClient):
|
|
43
|
+
client.model_properties.dict_methods(
|
|
44
|
+
body=model_properties_models.DictMethods(
|
|
45
|
+
keys_property="ok",
|
|
46
|
+
items_property="ok",
|
|
47
|
+
values_property="ok",
|
|
48
|
+
popitem_property="ok",
|
|
49
|
+
clear_property="ok",
|
|
50
|
+
update_property="ok",
|
|
51
|
+
setdefault_property="ok",
|
|
52
|
+
pop_property="ok",
|
|
53
|
+
get_property="ok",
|
|
54
|
+
copy_property="ok",
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_model_properties_with_list(client: SpecialWordsClient):
|
|
60
|
+
client.model_properties.with_list(model_properties_models.ModelWithList(list="ok"))
|