@typespec/http-client-python 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eng/scripts/ci/regenerate.ts +3 -1
- 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/__init__.py +7 -2
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +16 -7
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +2 -6
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +3 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +6 -2
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/__init__.py +7 -2
- package/generator/pygen/codegen/serializers/__init__.py +16 -7
- package/generator/pygen/codegen/serializers/builder_serializer.py +2 -6
- package/generator/pygen/codegen/serializers/general_serializer.py +3 -1
- package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +6 -2
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_api_version_header_async.py +18 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_api_version_path_async.py +18 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_api_version_query_async.py +18 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_client_overload_async.py +27 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_header.py +17 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_path.py +17 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_query.py +17 -0
- package/generator/test/azure/mock_api_tests/test_client_overload.py +25 -0
- package/generator/test/azure/requirements.txt +4 -0
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ const argv = parseArgs({
|
|
|
25
25
|
const SKIP_SPECS = [
|
|
26
26
|
"type/union/discriminated",
|
|
27
27
|
"client-operation-group",
|
|
28
|
-
"azure/client-generator-core/api-version",
|
|
29
28
|
"azure/client-generator-core/hierarchy-building",
|
|
30
29
|
];
|
|
31
30
|
|
|
@@ -117,6 +116,9 @@ const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<stri
|
|
|
117
116
|
"client/naming": {
|
|
118
117
|
namespace: "client.naming",
|
|
119
118
|
},
|
|
119
|
+
"client/overload": {
|
|
120
|
+
namespace: "client.overload",
|
|
121
|
+
},
|
|
120
122
|
"encode/duration": {
|
|
121
123
|
namespace: "encode.duration",
|
|
122
124
|
},
|
|
Binary file
|
|
Binary file
|
|
@@ -46,7 +46,7 @@ class OptionsDict(MutableMapping):
|
|
|
46
46
|
self._data = options.copy() if options else {}
|
|
47
47
|
self._validate_combinations()
|
|
48
48
|
|
|
49
|
-
def __getitem__(self, key: str) -> Any:
|
|
49
|
+
def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
|
|
50
50
|
if key == "head-as-boolean" and self.get("azure-arm"):
|
|
51
51
|
# override to always true if azure-arm is set
|
|
52
52
|
return True
|
|
@@ -109,7 +109,12 @@ class OptionsDict(MutableMapping):
|
|
|
109
109
|
if key == "combine-operation-files":
|
|
110
110
|
return self.get("version-tolerant")
|
|
111
111
|
if key == "package-pprint-name":
|
|
112
|
-
|
|
112
|
+
package_names = self.get("package-name", "").split("-")
|
|
113
|
+
return (
|
|
114
|
+
(package_names[-1].capitalize() + " Management")
|
|
115
|
+
if self.get("azure-arm")
|
|
116
|
+
else " ".join([i.capitalize() for i in package_names])
|
|
117
|
+
)
|
|
113
118
|
if key == "builders-visibility":
|
|
114
119
|
# Default to public if low-level client is not set, otherwise embedded
|
|
115
120
|
return "embedded" if not self.get("low-level-client") else "public"
|
|
@@ -149,9 +149,12 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
149
149
|
self._serialize_and_write_package_files()
|
|
150
150
|
|
|
151
151
|
# write apiview-properties.json
|
|
152
|
-
if
|
|
152
|
+
if (
|
|
153
|
+
self.code_model.options.get("emit-cross-language-definition-file")
|
|
154
|
+
and not self.code_model.options["multiapi"]
|
|
155
|
+
):
|
|
153
156
|
self.write_file(
|
|
154
|
-
|
|
157
|
+
self._root_of_sdk / Path("apiview-properties.json"),
|
|
155
158
|
general_serializer.serialize_cross_language_definition_file(),
|
|
156
159
|
)
|
|
157
160
|
|
|
@@ -165,7 +168,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
165
168
|
# add _metadata.json
|
|
166
169
|
if self.code_model.metadata:
|
|
167
170
|
self.write_file(
|
|
168
|
-
|
|
171
|
+
self._root_of_sdk / "_metadata.json",
|
|
169
172
|
json.dumps(self.code_model.metadata, indent=2),
|
|
170
173
|
)
|
|
171
174
|
elif client_namespace_type.clients:
|
|
@@ -216,11 +219,17 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
216
219
|
general_serializer.serialize_pkgutil_init_file(),
|
|
217
220
|
)
|
|
218
221
|
|
|
219
|
-
|
|
222
|
+
# path where README.md is
|
|
223
|
+
@property
|
|
224
|
+
def _root_of_sdk(self) -> Path:
|
|
220
225
|
root_of_sdk = Path(".")
|
|
221
226
|
if self.code_model.options["no-namespace-folders"]:
|
|
222
227
|
compensation = Path("../" * (self.code_model.namespace.count(".") + 1))
|
|
223
228
|
root_of_sdk = root_of_sdk / compensation
|
|
229
|
+
return root_of_sdk
|
|
230
|
+
|
|
231
|
+
def _serialize_and_write_package_files(self) -> None:
|
|
232
|
+
root_of_sdk = self._root_of_sdk
|
|
224
233
|
if self.code_model.options["package-mode"] in VALID_PACKAGE_MODE:
|
|
225
234
|
env = Environment(
|
|
226
235
|
loader=PackageLoader("pygen.codegen", "templates/packaging_templates"),
|
|
@@ -520,14 +529,14 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
520
529
|
namespace_config = get_namespace_config(self.code_model.namespace, self.code_model.options["multiapi"])
|
|
521
530
|
num_of_namespace = namespace_config.count(".") + 1
|
|
522
531
|
num_of_package_namespace = (
|
|
523
|
-
get_namespace_from_package_name(self.code_model.options.get("
|
|
532
|
+
get_namespace_from_package_name(self.code_model.options.get("package-name", "")).count(".") + 1
|
|
524
533
|
)
|
|
525
534
|
if num_of_namespace > num_of_package_namespace:
|
|
526
535
|
return Path("/".join(namespace_config.split(".")[num_of_package_namespace:]))
|
|
527
536
|
return Path("")
|
|
528
537
|
|
|
529
538
|
def _serialize_and_write_sample(self, env: Environment):
|
|
530
|
-
out_path =
|
|
539
|
+
out_path = self._root_of_sdk / "generated_samples"
|
|
531
540
|
for client in self.code_model.clients:
|
|
532
541
|
for op_group in client.operation_groups:
|
|
533
542
|
for operation in op_group.operations:
|
|
@@ -561,7 +570,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
561
570
|
|
|
562
571
|
def _serialize_and_write_test(self, env: Environment):
|
|
563
572
|
self.code_model.for_test = True
|
|
564
|
-
out_path =
|
|
573
|
+
out_path = self._root_of_sdk / "generated_tests"
|
|
565
574
|
general_serializer = TestGeneralSerializer(code_model=self.code_model, env=env)
|
|
566
575
|
self.write_file(out_path / "conftest.py", general_serializer.serialize_conftest())
|
|
567
576
|
if not self.code_model.options["azure-arm"]:
|
|
@@ -1067,9 +1067,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1067
1067
|
)
|
|
1068
1068
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1069
1069
|
if xml_serializable(str(e.default_content_type)):
|
|
1070
|
-
retval.append(
|
|
1071
|
-
f" error = _failsafe_deserialize_xml({type_annotation}, response)"
|
|
1072
|
-
)
|
|
1070
|
+
retval.append(f" error = _failsafe_deserialize_xml({type_annotation}, response)")
|
|
1073
1071
|
else:
|
|
1074
1072
|
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1075
1073
|
else:
|
|
@@ -1086,9 +1084,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1086
1084
|
if builder.non_default_errors:
|
|
1087
1085
|
retval.append(" else:")
|
|
1088
1086
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1089
|
-
retval.append(
|
|
1090
|
-
f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)"
|
|
1091
|
-
)
|
|
1087
|
+
retval.append(f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)")
|
|
1092
1088
|
else:
|
|
1093
1089
|
retval.append(
|
|
1094
1090
|
f"{indent}error = self._deserialize.failsafe_deserialize({default_error_deserialization}, "
|
|
@@ -70,9 +70,11 @@ class GeneralSerializer(BaseSerializer):
|
|
|
70
70
|
# If parsing the pyproject.toml fails, we assume the it does not exist or is incorrectly formatted.
|
|
71
71
|
return result
|
|
72
72
|
|
|
73
|
-
# Keep azure-sdk-build configuration
|
|
73
|
+
# Keep "azure-sdk-build" and "packaging" configuration
|
|
74
74
|
if "tool" in loaded_pyproject_toml and "azure-sdk-build" in loaded_pyproject_toml["tool"]:
|
|
75
75
|
result["KEEP_FIELDS"]["tool.azure-sdk-build"] = loaded_pyproject_toml["tool"]["azure-sdk-build"]
|
|
76
|
+
if "packaging" in loaded_pyproject_toml:
|
|
77
|
+
result["KEEP_FIELDS"]["packaging"] = loaded_pyproject_toml["packaging"]
|
|
76
78
|
|
|
77
79
|
# Process dependencies
|
|
78
80
|
if "project" in loaded_pyproject_toml:
|
package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2
CHANGED
|
@@ -14,7 +14,11 @@ name = "{{ options.get('package-name')|lower }}"
|
|
|
14
14
|
authors = [
|
|
15
15
|
{ name = "{{ code_model.company_name }}"{% if code_model.is_azure_flavor %}, email = "azpysdkhelp@microsoft.com"{% endif %} },
|
|
16
16
|
]
|
|
17
|
+
{% if options.get("azure-arm") %}
|
|
18
|
+
description = "Microsoft Azure {{ options.get('package-pprint-name') }} Client Library for Python"
|
|
19
|
+
{% else %}
|
|
17
20
|
description = "{{ code_model.company_name }} {% if code_model.is_azure_flavor and not options.get('package-pprint-name').startswith('Azure ') %}Azure {% endif %}{{ options.get('package-pprint-name') }} Client Library for Python"
|
|
21
|
+
{% endif %}
|
|
18
22
|
license = "MIT"
|
|
19
23
|
classifiers = [
|
|
20
24
|
"Development Status :: {{ dev_status }}",
|
|
@@ -73,7 +77,7 @@ version = "{{ options.get("package-version", "unknown") }}"
|
|
|
73
77
|
{% if code_model.is_azure_flavor %}
|
|
74
78
|
|
|
75
79
|
[project.urls]
|
|
76
|
-
repository = "https://github.com/Azure/azure-sdk-for-python
|
|
80
|
+
repository = "https://github.com/Azure/azure-sdk-for-python"
|
|
77
81
|
{% endif %}
|
|
78
82
|
|
|
79
83
|
[tool.setuptools.dynamic]
|
|
@@ -84,7 +88,7 @@ version = {attr = "{{ code_model.namespace|lower }}._version.VERSION"}
|
|
|
84
88
|
version = {attr = "{{ options.get('package-name')|lower|replace('-', '.') }}._version.VERSION"}
|
|
85
89
|
{% endif %}
|
|
86
90
|
{% endif %}
|
|
87
|
-
readme = {file = ["README.md"], content-type = "text/markdown"}
|
|
91
|
+
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
|
|
88
92
|
{% if options.get('package-mode') %}
|
|
89
93
|
|
|
90
94
|
[tool.setuptools.packages.find]
|
|
Binary file
|
|
@@ -46,7 +46,7 @@ class OptionsDict(MutableMapping):
|
|
|
46
46
|
self._data = options.copy() if options else {}
|
|
47
47
|
self._validate_combinations()
|
|
48
48
|
|
|
49
|
-
def __getitem__(self, key: str) -> Any:
|
|
49
|
+
def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
|
|
50
50
|
if key == "head-as-boolean" and self.get("azure-arm"):
|
|
51
51
|
# override to always true if azure-arm is set
|
|
52
52
|
return True
|
|
@@ -109,7 +109,12 @@ class OptionsDict(MutableMapping):
|
|
|
109
109
|
if key == "combine-operation-files":
|
|
110
110
|
return self.get("version-tolerant")
|
|
111
111
|
if key == "package-pprint-name":
|
|
112
|
-
|
|
112
|
+
package_names = self.get("package-name", "").split("-")
|
|
113
|
+
return (
|
|
114
|
+
(package_names[-1].capitalize() + " Management")
|
|
115
|
+
if self.get("azure-arm")
|
|
116
|
+
else " ".join([i.capitalize() for i in package_names])
|
|
117
|
+
)
|
|
113
118
|
if key == "builders-visibility":
|
|
114
119
|
# Default to public if low-level client is not set, otherwise embedded
|
|
115
120
|
return "embedded" if not self.get("low-level-client") else "public"
|
|
@@ -149,9 +149,12 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
149
149
|
self._serialize_and_write_package_files()
|
|
150
150
|
|
|
151
151
|
# write apiview-properties.json
|
|
152
|
-
if
|
|
152
|
+
if (
|
|
153
|
+
self.code_model.options.get("emit-cross-language-definition-file")
|
|
154
|
+
and not self.code_model.options["multiapi"]
|
|
155
|
+
):
|
|
153
156
|
self.write_file(
|
|
154
|
-
|
|
157
|
+
self._root_of_sdk / Path("apiview-properties.json"),
|
|
155
158
|
general_serializer.serialize_cross_language_definition_file(),
|
|
156
159
|
)
|
|
157
160
|
|
|
@@ -165,7 +168,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
165
168
|
# add _metadata.json
|
|
166
169
|
if self.code_model.metadata:
|
|
167
170
|
self.write_file(
|
|
168
|
-
|
|
171
|
+
self._root_of_sdk / "_metadata.json",
|
|
169
172
|
json.dumps(self.code_model.metadata, indent=2),
|
|
170
173
|
)
|
|
171
174
|
elif client_namespace_type.clients:
|
|
@@ -216,11 +219,17 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
216
219
|
general_serializer.serialize_pkgutil_init_file(),
|
|
217
220
|
)
|
|
218
221
|
|
|
219
|
-
|
|
222
|
+
# path where README.md is
|
|
223
|
+
@property
|
|
224
|
+
def _root_of_sdk(self) -> Path:
|
|
220
225
|
root_of_sdk = Path(".")
|
|
221
226
|
if self.code_model.options["no-namespace-folders"]:
|
|
222
227
|
compensation = Path("../" * (self.code_model.namespace.count(".") + 1))
|
|
223
228
|
root_of_sdk = root_of_sdk / compensation
|
|
229
|
+
return root_of_sdk
|
|
230
|
+
|
|
231
|
+
def _serialize_and_write_package_files(self) -> None:
|
|
232
|
+
root_of_sdk = self._root_of_sdk
|
|
224
233
|
if self.code_model.options["package-mode"] in VALID_PACKAGE_MODE:
|
|
225
234
|
env = Environment(
|
|
226
235
|
loader=PackageLoader("pygen.codegen", "templates/packaging_templates"),
|
|
@@ -520,14 +529,14 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
520
529
|
namespace_config = get_namespace_config(self.code_model.namespace, self.code_model.options["multiapi"])
|
|
521
530
|
num_of_namespace = namespace_config.count(".") + 1
|
|
522
531
|
num_of_package_namespace = (
|
|
523
|
-
get_namespace_from_package_name(self.code_model.options.get("
|
|
532
|
+
get_namespace_from_package_name(self.code_model.options.get("package-name", "")).count(".") + 1
|
|
524
533
|
)
|
|
525
534
|
if num_of_namespace > num_of_package_namespace:
|
|
526
535
|
return Path("/".join(namespace_config.split(".")[num_of_package_namespace:]))
|
|
527
536
|
return Path("")
|
|
528
537
|
|
|
529
538
|
def _serialize_and_write_sample(self, env: Environment):
|
|
530
|
-
out_path =
|
|
539
|
+
out_path = self._root_of_sdk / "generated_samples"
|
|
531
540
|
for client in self.code_model.clients:
|
|
532
541
|
for op_group in client.operation_groups:
|
|
533
542
|
for operation in op_group.operations:
|
|
@@ -561,7 +570,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
561
570
|
|
|
562
571
|
def _serialize_and_write_test(self, env: Environment):
|
|
563
572
|
self.code_model.for_test = True
|
|
564
|
-
out_path =
|
|
573
|
+
out_path = self._root_of_sdk / "generated_tests"
|
|
565
574
|
general_serializer = TestGeneralSerializer(code_model=self.code_model, env=env)
|
|
566
575
|
self.write_file(out_path / "conftest.py", general_serializer.serialize_conftest())
|
|
567
576
|
if not self.code_model.options["azure-arm"]:
|
|
@@ -1067,9 +1067,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1067
1067
|
)
|
|
1068
1068
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1069
1069
|
if xml_serializable(str(e.default_content_type)):
|
|
1070
|
-
retval.append(
|
|
1071
|
-
f" error = _failsafe_deserialize_xml({type_annotation}, response)"
|
|
1072
|
-
)
|
|
1070
|
+
retval.append(f" error = _failsafe_deserialize_xml({type_annotation}, response)")
|
|
1073
1071
|
else:
|
|
1074
1072
|
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1075
1073
|
else:
|
|
@@ -1086,9 +1084,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1086
1084
|
if builder.non_default_errors:
|
|
1087
1085
|
retval.append(" else:")
|
|
1088
1086
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1089
|
-
retval.append(
|
|
1090
|
-
f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)"
|
|
1091
|
-
)
|
|
1087
|
+
retval.append(f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)")
|
|
1092
1088
|
else:
|
|
1093
1089
|
retval.append(
|
|
1094
1090
|
f"{indent}error = self._deserialize.failsafe_deserialize({default_error_deserialization}, "
|
|
@@ -70,9 +70,11 @@ class GeneralSerializer(BaseSerializer):
|
|
|
70
70
|
# If parsing the pyproject.toml fails, we assume the it does not exist or is incorrectly formatted.
|
|
71
71
|
return result
|
|
72
72
|
|
|
73
|
-
# Keep azure-sdk-build configuration
|
|
73
|
+
# Keep "azure-sdk-build" and "packaging" configuration
|
|
74
74
|
if "tool" in loaded_pyproject_toml and "azure-sdk-build" in loaded_pyproject_toml["tool"]:
|
|
75
75
|
result["KEEP_FIELDS"]["tool.azure-sdk-build"] = loaded_pyproject_toml["tool"]["azure-sdk-build"]
|
|
76
|
+
if "packaging" in loaded_pyproject_toml:
|
|
77
|
+
result["KEEP_FIELDS"]["packaging"] = loaded_pyproject_toml["packaging"]
|
|
76
78
|
|
|
77
79
|
# Process dependencies
|
|
78
80
|
if "project" in loaded_pyproject_toml:
|
|
@@ -14,7 +14,11 @@ name = "{{ options.get('package-name')|lower }}"
|
|
|
14
14
|
authors = [
|
|
15
15
|
{ name = "{{ code_model.company_name }}"{% if code_model.is_azure_flavor %}, email = "azpysdkhelp@microsoft.com"{% endif %} },
|
|
16
16
|
]
|
|
17
|
+
{% if options.get("azure-arm") %}
|
|
18
|
+
description = "Microsoft Azure {{ options.get('package-pprint-name') }} Client Library for Python"
|
|
19
|
+
{% else %}
|
|
17
20
|
description = "{{ code_model.company_name }} {% if code_model.is_azure_flavor and not options.get('package-pprint-name').startswith('Azure ') %}Azure {% endif %}{{ options.get('package-pprint-name') }} Client Library for Python"
|
|
21
|
+
{% endif %}
|
|
18
22
|
license = "MIT"
|
|
19
23
|
classifiers = [
|
|
20
24
|
"Development Status :: {{ dev_status }}",
|
|
@@ -73,7 +77,7 @@ version = "{{ options.get("package-version", "unknown") }}"
|
|
|
73
77
|
{% if code_model.is_azure_flavor %}
|
|
74
78
|
|
|
75
79
|
[project.urls]
|
|
76
|
-
repository = "https://github.com/Azure/azure-sdk-for-python
|
|
80
|
+
repository = "https://github.com/Azure/azure-sdk-for-python"
|
|
77
81
|
{% endif %}
|
|
78
82
|
|
|
79
83
|
[tool.setuptools.dynamic]
|
|
@@ -84,7 +88,7 @@ version = {attr = "{{ code_model.namespace|lower }}._version.VERSION"}
|
|
|
84
88
|
version = {attr = "{{ options.get('package-name')|lower|replace('-', '.') }}._version.VERSION"}
|
|
85
89
|
{% endif %}
|
|
86
90
|
{% endif %}
|
|
87
|
-
readme = {file = ["README.md"], content-type = "text/markdown"}
|
|
91
|
+
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
|
|
88
92
|
{% if options.get('package-mode') %}
|
|
89
93
|
|
|
90
94
|
[tool.setuptools.packages.find]
|
|
@@ -0,0 +1,18 @@
|
|
|
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 client.alternateapiversion.service.header.aio import HeaderClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with HeaderClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_header_api_version(client: HeaderClient):
|
|
18
|
+
await client.header_api_version()
|
|
@@ -0,0 +1,18 @@
|
|
|
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 client.alternateapiversion.service.path.aio import PathClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with PathClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_path_api_version(client: PathClient):
|
|
18
|
+
await client.path_api_version()
|
|
@@ -0,0 +1,18 @@
|
|
|
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 client.alternateapiversion.service.query.aio import QueryClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with QueryClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_query_api_version(client: QueryClient):
|
|
18
|
+
await client.query_api_version()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from client.overload.aio import OverloadClient
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestClientOverloadAsync:
|
|
6
|
+
@pytest.fixture
|
|
7
|
+
def client(self):
|
|
8
|
+
return OverloadClient(endpoint="http://localhost:3000")
|
|
9
|
+
|
|
10
|
+
@pytest.mark.asyncio
|
|
11
|
+
async def test_list(self, client: OverloadClient):
|
|
12
|
+
result = await client.list()
|
|
13
|
+
assert len(result) == 2
|
|
14
|
+
assert result[0]["id"] == "1"
|
|
15
|
+
assert result[0]["name"] == "foo"
|
|
16
|
+
assert result[0]["scope"] == "car"
|
|
17
|
+
assert result[1]["id"] == "2"
|
|
18
|
+
assert result[1]["name"] == "bar"
|
|
19
|
+
assert result[1]["scope"] == "bike"
|
|
20
|
+
|
|
21
|
+
@pytest.mark.asyncio
|
|
22
|
+
async def test_list_by_scope(self, client: OverloadClient):
|
|
23
|
+
result = await client.list_by_scope("car")
|
|
24
|
+
assert len(result) == 1
|
|
25
|
+
assert result[0]["id"] == "1"
|
|
26
|
+
assert result[0]["name"] == "foo"
|
|
27
|
+
assert result[0]["scope"] == "car"
|
package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_header.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 client.alternateapiversion.service.header import HeaderClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with HeaderClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_header_api_version(client: HeaderClient):
|
|
17
|
+
client.header_api_version()
|
package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_path.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 client.alternateapiversion.service.path import PathClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with PathClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_path_api_version(client: PathClient):
|
|
17
|
+
client.path_api_version()
|
package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_api_version_query.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 client.alternateapiversion.service.query import QueryClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with QueryClient(endpoint="http://localhost:3000") as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_query_api_version(client: QueryClient):
|
|
17
|
+
client.query_api_version()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from client.overload import OverloadClient
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestClientOverload:
|
|
6
|
+
@pytest.fixture
|
|
7
|
+
def client(self):
|
|
8
|
+
return OverloadClient(endpoint="http://localhost:3000")
|
|
9
|
+
|
|
10
|
+
def test_list(self, client: OverloadClient):
|
|
11
|
+
result = client.list()
|
|
12
|
+
assert len(result) == 2
|
|
13
|
+
assert result[0]["id"] == "1"
|
|
14
|
+
assert result[0]["name"] == "foo"
|
|
15
|
+
assert result[0]["scope"] == "car"
|
|
16
|
+
assert result[1]["id"] == "2"
|
|
17
|
+
assert result[1]["name"] == "bar"
|
|
18
|
+
assert result[1]["scope"] == "bike"
|
|
19
|
+
|
|
20
|
+
def test_list_by_scope(self, client: OverloadClient):
|
|
21
|
+
result = client.list_by_scope("car")
|
|
22
|
+
assert len(result) == 1
|
|
23
|
+
assert result[0]["id"] == "1"
|
|
24
|
+
assert result[0]["name"] == "foo"
|
|
25
|
+
assert result[0]["scope"] == "car"
|
|
@@ -4,6 +4,9 @@ azure-mgmt-core==1.6.0
|
|
|
4
4
|
|
|
5
5
|
# only for azure
|
|
6
6
|
-e ./generated/azure-client-generator-core-access
|
|
7
|
+
-e ./generated/azure-client-generator-core-api-version-header
|
|
8
|
+
-e ./generated/azure-client-generator-core-api-version-path
|
|
9
|
+
-e ./generated/azure-client-generator-core-api-version-query
|
|
7
10
|
-e ./generated/azure-client-generator-core-client-initialization
|
|
8
11
|
-e ./generated/azure-client-generator-core-deserialize-empty-string-as-null
|
|
9
12
|
-e ./generated/azure-client-generator-core-flatten-property
|
|
@@ -28,6 +31,7 @@ azure-mgmt-core==1.6.0
|
|
|
28
31
|
-e ./generated/client-namespace
|
|
29
32
|
-e ./generated/azure-payload-pageable
|
|
30
33
|
-e ./generated/client-naming
|
|
34
|
+
-e ./generated/client-overload
|
|
31
35
|
-e ./generated/client-structure-default
|
|
32
36
|
-e ./generated/client-structure-multiclient
|
|
33
37
|
-e ./generated/client-structure-renamedoperation
|