@typespec/http-client-python 0.1.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.
Files changed (334) hide show
  1. package/README.md +118 -0
  2. package/dist/emitter/code-model.d.ts +4 -0
  3. package/dist/emitter/code-model.d.ts.map +1 -0
  4. package/dist/emitter/code-model.js +195 -0
  5. package/dist/emitter/code-model.js.map +1 -0
  6. package/dist/emitter/emitter.d.ts +6 -0
  7. package/dist/emitter/emitter.d.ts.map +1 -0
  8. package/dist/emitter/emitter.js +104 -0
  9. package/dist/emitter/emitter.js.map +1 -0
  10. package/dist/emitter/external-process.d.ts +20 -0
  11. package/dist/emitter/external-process.d.ts.map +1 -0
  12. package/dist/emitter/external-process.js +44 -0
  13. package/dist/emitter/external-process.js.map +1 -0
  14. package/dist/emitter/http.d.ts +7 -0
  15. package/dist/emitter/http.d.ts.map +1 -0
  16. package/dist/emitter/http.js +268 -0
  17. package/dist/emitter/http.js.map +1 -0
  18. package/dist/emitter/index.d.ts +3 -0
  19. package/dist/emitter/index.d.ts.map +1 -0
  20. package/dist/emitter/index.js +3 -0
  21. package/dist/emitter/index.js.map +1 -0
  22. package/dist/emitter/lib.d.ts +30 -0
  23. package/dist/emitter/lib.d.ts.map +1 -0
  24. package/dist/emitter/lib.js +33 -0
  25. package/dist/emitter/lib.js.map +1 -0
  26. package/dist/emitter/types.d.ts +36 -0
  27. package/dist/emitter/types.d.ts.map +1 -0
  28. package/dist/emitter/types.js +491 -0
  29. package/dist/emitter/types.js.map +1 -0
  30. package/dist/emitter/utils.d.ts +26 -0
  31. package/dist/emitter/utils.d.ts.map +1 -0
  32. package/dist/emitter/utils.js +155 -0
  33. package/dist/emitter/utils.js.map +1 -0
  34. package/emitter/src/code-model.ts +272 -0
  35. package/emitter/src/emitter.ts +127 -0
  36. package/emitter/src/external-process.ts +52 -0
  37. package/emitter/src/http.ts +382 -0
  38. package/emitter/src/index.ts +2 -0
  39. package/emitter/src/lib.ts +59 -0
  40. package/emitter/src/types.ts +573 -0
  41. package/emitter/src/utils.ts +215 -0
  42. package/emitter/temp/tsconfig.tsbuildinfo +1 -0
  43. package/emitter/test/utils.test.ts +22 -0
  44. package/emitter/tsconfig.build.json +11 -0
  45. package/emitter/tsconfig.json +7 -0
  46. package/emitter/vitest.config.ts +4 -0
  47. package/eng/scripts/Build-Packages.ps1 +86 -0
  48. package/eng/scripts/Check-GitChanges.ps1 +22 -0
  49. package/eng/scripts/Functions.ps1 +26 -0
  50. package/eng/scripts/Generate.ps1 +11 -0
  51. package/eng/scripts/Generation.psm1 +22 -0
  52. package/eng/scripts/Initialize-Repository.ps1 +40 -0
  53. package/eng/scripts/Test-Packages.ps1 +65 -0
  54. package/eng/scripts/ci/format.ts +3 -0
  55. package/eng/scripts/ci/lint.ts +39 -0
  56. package/eng/scripts/ci/mypy.ini +38 -0
  57. package/eng/scripts/ci/pylintrc +59 -0
  58. package/eng/scripts/ci/pyproject.toml +18 -0
  59. package/eng/scripts/ci/pyrightconfig.json +6 -0
  60. package/eng/scripts/ci/regenerate.ts +299 -0
  61. package/eng/scripts/ci/run-ci.ts +88 -0
  62. package/eng/scripts/ci/run_apiview.py +40 -0
  63. package/eng/scripts/ci/run_mypy.py +49 -0
  64. package/eng/scripts/ci/run_pylint.py +50 -0
  65. package/eng/scripts/ci/run_pyright.py +58 -0
  66. package/eng/scripts/ci/util.py +72 -0
  67. package/eng/scripts/ci/utils.ts +48 -0
  68. package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
  69. package/eng/scripts/setup/install.py +53 -0
  70. package/eng/scripts/setup/prepare.py +42 -0
  71. package/eng/scripts/setup/run-python3.ts +25 -0
  72. package/eng/scripts/setup/run_tsp.py +42 -0
  73. package/eng/scripts/setup/system-requirements.ts +261 -0
  74. package/eng/scripts/setup/venvtools.py +87 -0
  75. package/generator/LICENSE +21 -0
  76. package/generator/README.md +1 -0
  77. package/generator/dev_requirements.txt +13 -0
  78. package/generator/pygen/__init__.py +107 -0
  79. package/generator/pygen/_version.py +7 -0
  80. package/generator/pygen/black.py +71 -0
  81. package/generator/pygen/codegen/__init__.py +338 -0
  82. package/generator/pygen/codegen/_utils.py +17 -0
  83. package/generator/pygen/codegen/models/__init__.py +204 -0
  84. package/generator/pygen/codegen/models/base.py +186 -0
  85. package/generator/pygen/codegen/models/base_builder.py +118 -0
  86. package/generator/pygen/codegen/models/client.py +433 -0
  87. package/generator/pygen/codegen/models/code_model.py +237 -0
  88. package/generator/pygen/codegen/models/combined_type.py +149 -0
  89. package/generator/pygen/codegen/models/constant_type.py +129 -0
  90. package/generator/pygen/codegen/models/credential_types.py +214 -0
  91. package/generator/pygen/codegen/models/dictionary_type.py +127 -0
  92. package/generator/pygen/codegen/models/enum_type.py +238 -0
  93. package/generator/pygen/codegen/models/imports.py +291 -0
  94. package/generator/pygen/codegen/models/list_type.py +143 -0
  95. package/generator/pygen/codegen/models/lro_operation.py +142 -0
  96. package/generator/pygen/codegen/models/lro_paging_operation.py +32 -0
  97. package/generator/pygen/codegen/models/model_type.py +359 -0
  98. package/generator/pygen/codegen/models/operation.py +530 -0
  99. package/generator/pygen/codegen/models/operation_group.py +184 -0
  100. package/generator/pygen/codegen/models/paging_operation.py +155 -0
  101. package/generator/pygen/codegen/models/parameter.py +412 -0
  102. package/generator/pygen/codegen/models/parameter_list.py +387 -0
  103. package/generator/pygen/codegen/models/primitive_types.py +659 -0
  104. package/generator/pygen/codegen/models/property.py +170 -0
  105. package/generator/pygen/codegen/models/request_builder.py +189 -0
  106. package/generator/pygen/codegen/models/request_builder_parameter.py +115 -0
  107. package/generator/pygen/codegen/models/response.py +348 -0
  108. package/generator/pygen/codegen/models/utils.py +21 -0
  109. package/generator/pygen/codegen/serializers/__init__.py +574 -0
  110. package/generator/pygen/codegen/serializers/base_serializer.py +21 -0
  111. package/generator/pygen/codegen/serializers/builder_serializer.py +1507 -0
  112. package/generator/pygen/codegen/serializers/client_serializer.py +294 -0
  113. package/generator/pygen/codegen/serializers/enum_serializer.py +15 -0
  114. package/generator/pygen/codegen/serializers/general_serializer.py +213 -0
  115. package/generator/pygen/codegen/serializers/import_serializer.py +126 -0
  116. package/generator/pygen/codegen/serializers/metadata_serializer.py +198 -0
  117. package/generator/pygen/codegen/serializers/model_init_serializer.py +33 -0
  118. package/generator/pygen/codegen/serializers/model_serializer.py +317 -0
  119. package/generator/pygen/codegen/serializers/operation_groups_serializer.py +89 -0
  120. package/generator/pygen/codegen/serializers/operations_init_serializer.py +44 -0
  121. package/generator/pygen/codegen/serializers/parameter_serializer.py +221 -0
  122. package/generator/pygen/codegen/serializers/patch_serializer.py +19 -0
  123. package/generator/pygen/codegen/serializers/request_builders_serializer.py +52 -0
  124. package/generator/pygen/codegen/serializers/sample_serializer.py +168 -0
  125. package/generator/pygen/codegen/serializers/test_serializer.py +292 -0
  126. package/generator/pygen/codegen/serializers/types_serializer.py +31 -0
  127. package/generator/pygen/codegen/serializers/utils.py +68 -0
  128. package/generator/pygen/codegen/templates/client.py.jinja2 +37 -0
  129. package/generator/pygen/codegen/templates/client_container.py.jinja2 +12 -0
  130. package/generator/pygen/codegen/templates/config.py.jinja2 +73 -0
  131. package/generator/pygen/codegen/templates/config_container.py.jinja2 +16 -0
  132. package/generator/pygen/codegen/templates/conftest.py.jinja2 +28 -0
  133. package/generator/pygen/codegen/templates/enum.py.jinja2 +13 -0
  134. package/generator/pygen/codegen/templates/enum_container.py.jinja2 +10 -0
  135. package/generator/pygen/codegen/templates/init.py.jinja2 +24 -0
  136. package/generator/pygen/codegen/templates/keywords.jinja2 +19 -0
  137. package/generator/pygen/codegen/templates/lro_operation.py.jinja2 +16 -0
  138. package/generator/pygen/codegen/templates/lro_paging_operation.py.jinja2 +18 -0
  139. package/generator/pygen/codegen/templates/macros.jinja2 +12 -0
  140. package/generator/pygen/codegen/templates/metadata.json.jinja2 +167 -0
  141. package/generator/pygen/codegen/templates/model_base.py.jinja2 +1157 -0
  142. package/generator/pygen/codegen/templates/model_container.py.jinja2 +12 -0
  143. package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +97 -0
  144. package/generator/pygen/codegen/templates/model_init.py.jinja2 +28 -0
  145. package/generator/pygen/codegen/templates/model_msrest.py.jinja2 +92 -0
  146. package/generator/pygen/codegen/templates/operation.py.jinja2 +21 -0
  147. package/generator/pygen/codegen/templates/operation_group.py.jinja2 +75 -0
  148. package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +19 -0
  149. package/generator/pygen/codegen/templates/operation_tools.jinja2 +81 -0
  150. package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +17 -0
  151. package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +6 -0
  152. package/generator/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +21 -0
  153. package/generator/pygen/codegen/templates/packaging_templates/MANIFEST.in.jinja2 +8 -0
  154. package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +107 -0
  155. package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +9 -0
  156. package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +108 -0
  157. package/generator/pygen/codegen/templates/paging_operation.py.jinja2 +21 -0
  158. package/generator/pygen/codegen/templates/patch.py.jinja2 +19 -0
  159. package/generator/pygen/codegen/templates/pkgutil_init.py.jinja2 +1 -0
  160. package/generator/pygen/codegen/templates/request_builder.py.jinja2 +28 -0
  161. package/generator/pygen/codegen/templates/request_builders.py.jinja2 +10 -0
  162. package/generator/pygen/codegen/templates/rest_init.py.jinja2 +12 -0
  163. package/generator/pygen/codegen/templates/sample.py.jinja2 +44 -0
  164. package/generator/pygen/codegen/templates/serialization.py.jinja2 +2114 -0
  165. package/generator/pygen/codegen/templates/test.py.jinja2 +50 -0
  166. package/generator/pygen/codegen/templates/testpreparer.py.jinja2 +26 -0
  167. package/generator/pygen/codegen/templates/types.py.jinja2 +7 -0
  168. package/generator/pygen/codegen/templates/validation.py.jinja2 +38 -0
  169. package/generator/pygen/codegen/templates/vendor.py.jinja2 +95 -0
  170. package/generator/pygen/codegen/templates/version.py.jinja2 +4 -0
  171. package/generator/pygen/m2r.py +65 -0
  172. package/generator/pygen/postprocess/__init__.py +183 -0
  173. package/generator/pygen/postprocess/get_all.py +19 -0
  174. package/generator/pygen/postprocess/venvtools.py +75 -0
  175. package/generator/pygen/preprocess/__init__.py +515 -0
  176. package/generator/pygen/preprocess/helpers.py +27 -0
  177. package/generator/pygen/preprocess/python_mappings.py +224 -0
  178. package/generator/pygen/utils.py +163 -0
  179. package/generator/pygen.egg-info/PKG-INFO +25 -0
  180. package/generator/pygen.egg-info/SOURCES.txt +66 -0
  181. package/generator/pygen.egg-info/dependency_links.txt +1 -0
  182. package/generator/pygen.egg-info/requires.txt +4 -0
  183. package/generator/pygen.egg-info/top_level.txt +1 -0
  184. package/generator/requirements.txt +12 -0
  185. package/generator/setup.py +55 -0
  186. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_models_common_types_managed_identity_async.py +63 -0
  187. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_models_resource_async.py +284 -0
  188. package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_access_async.py +101 -0
  189. package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +93 -0
  190. package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py +31 -0
  191. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py +76 -0
  192. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py +22 -0
  193. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py +39 -0
  194. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_model_async.py +33 -0
  195. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_page_async.py +58 -0
  196. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py +41 -0
  197. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py +87 -0
  198. package/generator/test/azure/mock_api_tests/asynctests/test_azure_example_basic_async.py +30 -0
  199. package/generator/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py +30 -0
  200. package/generator/test/azure/mock_api_tests/conftest.py +150 -0
  201. package/generator/test/azure/mock_api_tests/test_azure_arm_models_common_types_managed_identity.py +60 -0
  202. package/generator/test/azure/mock_api_tests/test_azure_arm_models_resource.py +254 -0
  203. package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_access.py +92 -0
  204. package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +84 -0
  205. package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py +28 -0
  206. package/generator/test/azure/mock_api_tests/test_azure_core_basic.py +70 -0
  207. package/generator/test/azure/mock_api_tests/test_azure_core_lro_rpc.py +20 -0
  208. package/generator/test/azure/mock_api_tests/test_azure_core_lro_standard.py +32 -0
  209. package/generator/test/azure/mock_api_tests/test_azure_core_model.py +30 -0
  210. package/generator/test/azure/mock_api_tests/test_azure_core_page.py +51 -0
  211. package/generator/test/azure/mock_api_tests/test_azure_core_scalar.py +35 -0
  212. package/generator/test/azure/mock_api_tests/test_azure_core_traits.py +85 -0
  213. package/generator/test/azure/mock_api_tests/test_azure_example_basic.py +29 -0
  214. package/generator/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py +29 -0
  215. package/generator/test/azure/requirements.txt +89 -0
  216. package/generator/test/azure/tox.ini +56 -0
  217. package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +121 -0
  218. package/generator/test/generic_mock_api_tests/asynctests/test_client_naming_async.py +69 -0
  219. package/generator/test/generic_mock_api_tests/asynctests/test_client_structure_async.py +62 -0
  220. package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +133 -0
  221. package/generator/test/generic_mock_api_tests/asynctests/test_encode_datetime_async.py +127 -0
  222. package/generator/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py +63 -0
  223. package/generator/test/generic_mock_api_tests/asynctests/test_encode_numeric_async.py +35 -0
  224. package/generator/test/generic_mock_api_tests/asynctests/test_headasboolean_async.py +35 -0
  225. package/generator/test/generic_mock_api_tests/asynctests/test_parameters_basic_async.py +24 -0
  226. package/generator/test/generic_mock_api_tests/asynctests/test_parameters_body_optionality_async.py +30 -0
  227. package/generator/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py +44 -0
  228. package/generator/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py +76 -0
  229. package/generator/test/generic_mock_api_tests/asynctests/test_payload_content_negotiation_async.py +37 -0
  230. package/generator/test/generic_mock_api_tests/asynctests/test_payload_json_merge_patch_async.py +98 -0
  231. package/generator/test/generic_mock_api_tests/asynctests/test_payload_media_type_async.py +27 -0
  232. package/generator/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py +153 -0
  233. package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +19 -0
  234. package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +103 -0
  235. package/generator/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py +128 -0
  236. package/generator/test/generic_mock_api_tests/asynctests/test_routes_async.py +331 -0
  237. package/generator/test/generic_mock_api_tests/asynctests/test_serialization_encoded_name_json_async.py +24 -0
  238. package/generator/test/generic_mock_api_tests/asynctests/test_server_endpoint_not_defined_async.py +18 -0
  239. package/generator/test/generic_mock_api_tests/asynctests/test_server_path_multiple_async.py +25 -0
  240. package/generator/test/generic_mock_api_tests/asynctests/test_server_path_single_async.py +18 -0
  241. package/generator/test/generic_mock_api_tests/asynctests/test_server_versions_not_versioned_async.py +28 -0
  242. package/generator/test/generic_mock_api_tests/asynctests/test_server_versions_versioned_async.py +34 -0
  243. package/generator/test/generic_mock_api_tests/asynctests/test_special_headers_conditional_request_async.py +38 -0
  244. package/generator/test/generic_mock_api_tests/asynctests/test_special_headers_repeatability_async.py +19 -0
  245. package/generator/test/generic_mock_api_tests/asynctests/test_special_words_async.py +42 -0
  246. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_array_async.py +118 -0
  247. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_dictionary_async.py +98 -0
  248. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_enum_extensible_async.py +25 -0
  249. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_enum_fixed_async.py +27 -0
  250. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_empty_async.py +32 -0
  251. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py +70 -0
  252. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py +85 -0
  253. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_not_discriminated_async.py +34 -0
  254. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py +34 -0
  255. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_single_discriminator_async.py +67 -0
  256. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_usage_async.py +32 -0
  257. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_visibility_async.py +47 -0
  258. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py +352 -0
  259. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py +110 -0
  260. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py +197 -0
  261. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py +315 -0
  262. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_scalar_async.py +60 -0
  263. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_union_async.py +90 -0
  264. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py +36 -0
  265. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py +21 -0
  266. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +21 -0
  267. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py +29 -0
  268. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py +18 -0
  269. package/generator/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py +22 -0
  270. package/generator/test/generic_mock_api_tests/conftest.py +113 -0
  271. package/generator/test/generic_mock_api_tests/data/image.jpg +0 -0
  272. package/generator/test/generic_mock_api_tests/data/image.png +0 -0
  273. package/generator/test/generic_mock_api_tests/test_authentication.py +113 -0
  274. package/generator/test/generic_mock_api_tests/test_client_naming.py +57 -0
  275. package/generator/test/generic_mock_api_tests/test_client_structure.py +57 -0
  276. package/generator/test/generic_mock_api_tests/test_encode_bytes.py +128 -0
  277. package/generator/test/generic_mock_api_tests/test_encode_datetime.py +123 -0
  278. package/generator/test/generic_mock_api_tests/test_encode_duration.py +60 -0
  279. package/generator/test/generic_mock_api_tests/test_encode_numeric.py +31 -0
  280. package/generator/test/generic_mock_api_tests/test_headasboolean.py +33 -0
  281. package/generator/test/generic_mock_api_tests/test_parameters_basic.py +22 -0
  282. package/generator/test/generic_mock_api_tests/test_parameters_body_optionality.py +27 -0
  283. package/generator/test/generic_mock_api_tests/test_parameters_collection_format.py +37 -0
  284. package/generator/test/generic_mock_api_tests/test_parameters_spread.py +66 -0
  285. package/generator/test/generic_mock_api_tests/test_payload_content_negotiation.py +33 -0
  286. package/generator/test/generic_mock_api_tests/test_payload_json_merge_patch.py +93 -0
  287. package/generator/test/generic_mock_api_tests/test_payload_media_type.py +25 -0
  288. package/generator/test/generic_mock_api_tests/test_payload_multipart.py +140 -0
  289. package/generator/test/generic_mock_api_tests/test_payload_pageable.py +18 -0
  290. package/generator/test/generic_mock_api_tests/test_payload_xml.py +93 -0
  291. package/generator/test/generic_mock_api_tests/test_resiliency_srv_driven.py +122 -0
  292. package/generator/test/generic_mock_api_tests/test_routes.py +285 -0
  293. package/generator/test/generic_mock_api_tests/test_serialization_encoded_name_json.py +21 -0
  294. package/generator/test/generic_mock_api_tests/test_server_endpoint_not_defined.py +17 -0
  295. package/generator/test/generic_mock_api_tests/test_server_path_multiple.py +21 -0
  296. package/generator/test/generic_mock_api_tests/test_server_path_single.py +17 -0
  297. package/generator/test/generic_mock_api_tests/test_server_versions_not_versioned.py +25 -0
  298. package/generator/test/generic_mock_api_tests/test_server_versions_versioned.py +30 -0
  299. package/generator/test/generic_mock_api_tests/test_special_headers_conditional_request.py +34 -0
  300. package/generator/test/generic_mock_api_tests/test_special_headers_repeatability.py +18 -0
  301. package/generator/test/generic_mock_api_tests/test_special_words.py +37 -0
  302. package/generator/test/generic_mock_api_tests/test_typetest_array.py +103 -0
  303. package/generator/test/generic_mock_api_tests/test_typetest_dictionary.py +86 -0
  304. package/generator/test/generic_mock_api_tests/test_typetest_enum_extensible.py +23 -0
  305. package/generator/test/generic_mock_api_tests/test_typetest_enum_fixed.py +25 -0
  306. package/generator/test/generic_mock_api_tests/test_typetest_model_empty.py +29 -0
  307. package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_enum_discriminator.py +58 -0
  308. package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py +79 -0
  309. package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_not_discriminated.py +31 -0
  310. package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py +32 -0
  311. package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_single_discriminator.py +60 -0
  312. package/generator/test/generic_mock_api_tests/test_typetest_model_usage.py +28 -0
  313. package/generator/test/generic_mock_api_tests/test_typetest_model_visibility.py +40 -0
  314. package/generator/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py +313 -0
  315. package/generator/test/generic_mock_api_tests/test_typetest_property_nullable.py +102 -0
  316. package/generator/test/generic_mock_api_tests/test_typetest_property_optional.py +174 -0
  317. package/generator/test/generic_mock_api_tests/test_typetest_property_valuetypes.py +286 -0
  318. package/generator/test/generic_mock_api_tests/test_typetest_scalar.py +53 -0
  319. package/generator/test/generic_mock_api_tests/test_typetest_union.py +80 -0
  320. package/generator/test/generic_mock_api_tests/test_versioning_added.py +33 -0
  321. package/generator/test/generic_mock_api_tests/test_versioning_made_optional.py +20 -0
  322. package/generator/test/generic_mock_api_tests/test_versioning_removed.py +20 -0
  323. package/generator/test/generic_mock_api_tests/test_versioning_renamed_from.py +27 -0
  324. package/generator/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py +17 -0
  325. package/generator/test/generic_mock_api_tests/test_versioning_type_changed_from.py +21 -0
  326. package/generator/test/generic_mock_api_tests/unittests/test_model_base_serialization.py +4067 -0
  327. package/generator/test/generic_mock_api_tests/unittests/test_model_base_xml_serialization.py +1001 -0
  328. package/generator/test/unbranded/mock_api_tests/asynctests/test_unbranded_async.py +24 -0
  329. package/generator/test/unbranded/mock_api_tests/cadl-ranch-config.yaml +27 -0
  330. package/generator/test/unbranded/mock_api_tests/conftest.py +35 -0
  331. package/generator/test/unbranded/mock_api_tests/test_unbranded.py +57 -0
  332. package/generator/test/unbranded/requirements.txt +72 -0
  333. package/generator/test/unbranded/tox.ini +56 -0
  334. package/package.json +93 -0
@@ -0,0 +1,118 @@
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
+ import pytest
8
+ import isodate
9
+ from typetest.array.aio import ArrayClient
10
+ from typetest.array import models
11
+
12
+
13
+ @pytest.fixture
14
+ async def client():
15
+ async with ArrayClient() as client:
16
+ yield client
17
+
18
+
19
+ @pytest.mark.asyncio
20
+ async def test_boolean_value(client: ArrayClient):
21
+ assert await client.boolean_value.get() == [True, False]
22
+ await client.boolean_value.put([True, False])
23
+
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_datetime_value(client: ArrayClient):
27
+ assert await client.datetime_value.get() == [isodate.parse_datetime("2022-08-26T18:38:00Z")]
28
+ await client.datetime_value.put([isodate.parse_datetime("2022-08-26T18:38:00Z")])
29
+
30
+
31
+ @pytest.mark.asyncio
32
+ async def test_duration_value(client: ArrayClient):
33
+ assert await client.duration_value.get() == [isodate.parse_duration("P123DT22H14M12.011S")]
34
+ await client.duration_value.put([isodate.parse_duration("P123DT22H14M12.011S")])
35
+
36
+
37
+ @pytest.mark.asyncio
38
+ async def test_float32_value(client: ArrayClient):
39
+ assert await client.float32_value.get() == [43.125]
40
+ await client.float32_value.put([43.125])
41
+
42
+
43
+ @pytest.mark.asyncio
44
+ async def test_int32_value(client: ArrayClient):
45
+ assert await client.int32_value.get() == [1, 2]
46
+ await client.int32_value.put([1, 2])
47
+
48
+
49
+ @pytest.mark.asyncio
50
+ async def test_int64_value(client: ArrayClient):
51
+ assert await client.int64_value.get() == [2**53 - 1, -(2**53 - 1)]
52
+ await client.int64_value.put([2**53 - 1, -(2**53 - 1)])
53
+
54
+
55
+ @pytest.mark.asyncio
56
+ async def test_model_value(client: ArrayClient):
57
+ assert await client.model_value.get() == [
58
+ models.InnerModel(property="hello"),
59
+ models.InnerModel(property="world"),
60
+ ]
61
+ await client.model_value.put(
62
+ [
63
+ models.InnerModel(property="hello"),
64
+ models.InnerModel(property="world"),
65
+ ]
66
+ )
67
+
68
+
69
+ @pytest.mark.asyncio
70
+ async def test_nullable_boolean_value(client: ArrayClient):
71
+ assert await client.nullable_boolean_value.get() == [True, None, False]
72
+ await client.nullable_boolean_value.put([True, None, False])
73
+
74
+
75
+ @pytest.mark.asyncio
76
+ async def test_nullable_float_value(client: ArrayClient):
77
+ assert await client.nullable_float_value.get() == [1.25, None, 3.0]
78
+ await client.nullable_float_value.put([1.25, None, 3.0])
79
+
80
+
81
+ @pytest.mark.asyncio
82
+ async def test_nullable_int32_value(client: ArrayClient):
83
+ assert await client.nullable_int32_value.get() == [1, None, 3]
84
+ await client.nullable_int32_value.put([1, None, 3])
85
+
86
+
87
+ @pytest.mark.asyncio
88
+ async def test_nullable_model_value(client: ArrayClient):
89
+ assert await client.nullable_model_value.get() == [
90
+ models.InnerModel(property="hello"),
91
+ None,
92
+ models.InnerModel(property="world"),
93
+ ]
94
+ await client.nullable_model_value.put(
95
+ [
96
+ models.InnerModel(property="hello"),
97
+ None,
98
+ models.InnerModel(property="world"),
99
+ ]
100
+ )
101
+
102
+
103
+ @pytest.mark.asyncio
104
+ async def test_nullable_string_value(client: ArrayClient):
105
+ assert await client.nullable_string_value.get() == ["hello", None, "world"]
106
+ await client.nullable_string_value.put(["hello", None, "world"])
107
+
108
+
109
+ @pytest.mark.asyncio
110
+ async def test_string_value(client: ArrayClient):
111
+ assert await client.string_value.get() == ["hello", ""]
112
+ await client.string_value.put(["hello", ""])
113
+
114
+
115
+ @pytest.mark.asyncio
116
+ async def test_unknown_value(client: ArrayClient):
117
+ assert await client.unknown_value.get() == [1, "hello", None]
118
+ await client.unknown_value.put([1, "hello", None])
@@ -0,0 +1,98 @@
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 typetest.dictionary import models
8
+ from typetest.dictionary.aio import DictionaryClient
9
+ import isodate
10
+
11
+
12
+ @pytest.fixture
13
+ async def client():
14
+ async with DictionaryClient() as client:
15
+ yield client
16
+
17
+
18
+ @pytest.mark.asyncio
19
+ async def test_boolean_value(client: DictionaryClient):
20
+ value = {"k1": True, "k2": False}
21
+ assert await client.boolean_value.get() == value
22
+ await client.boolean_value.put(value)
23
+
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_datetime_value(client: DictionaryClient):
27
+ value = {"k1": isodate.parse_datetime("2022-08-26T18:38:00Z")}
28
+ assert await client.datetime_value.get() == value
29
+ await client.datetime_value.put(value)
30
+
31
+
32
+ @pytest.mark.asyncio
33
+ async def test_duration_value(client: DictionaryClient):
34
+ value = {"k1": isodate.parse_duration("P123DT22H14M12.011S")}
35
+ assert await client.duration_value.get() == value
36
+ await client.duration_value.put(value)
37
+
38
+
39
+ @pytest.mark.asyncio
40
+ async def test_float32_value(client: DictionaryClient):
41
+ value = {"k1": 43.125}
42
+ assert await client.float32_value.get() == value
43
+ await client.float32_value.put(value)
44
+
45
+
46
+ @pytest.mark.asyncio
47
+ async def test_int32_value(client: DictionaryClient):
48
+ value = {"k1": 1, "k2": 2}
49
+ assert await client.int32_value.get() == value
50
+ await client.int32_value.put(value)
51
+
52
+
53
+ @pytest.mark.asyncio
54
+ async def test_int64_value(client: DictionaryClient):
55
+ value = {"k1": 2**53 - 1, "k2": -(2**53 - 1)}
56
+ assert await client.int64_value.get() == value
57
+ await client.int64_value.put(value)
58
+
59
+
60
+ @pytest.mark.asyncio
61
+ async def test_model_value(client: DictionaryClient):
62
+ value = {
63
+ "k1": models.InnerModel(property="hello"),
64
+ "k2": models.InnerModel(property="world"),
65
+ }
66
+ assert await client.model_value.get() == value
67
+ await client.model_value.put(value)
68
+
69
+
70
+ @pytest.mark.asyncio
71
+ async def test_nullable_float_value(client: DictionaryClient):
72
+ value = {"k1": 1.25, "k2": 0.5, "k3": None}
73
+ assert await client.nullable_float_value.get() == value
74
+ await client.nullable_float_value.put(value)
75
+
76
+
77
+ @pytest.mark.asyncio
78
+ async def test_recursive_model_value(client: DictionaryClient):
79
+ value = {
80
+ "k1": models.InnerModel(property="hello", children={}),
81
+ "k2": models.InnerModel(property="world", children={"k2.1": models.InnerModel(property="inner world")}),
82
+ }
83
+ assert await client.recursive_model_value.get() == value
84
+ await client.recursive_model_value.put(value)
85
+
86
+
87
+ @pytest.mark.asyncio
88
+ async def test_string_value(client: DictionaryClient):
89
+ value = {"k1": "hello", "k2": ""}
90
+ assert await client.string_value.get() == value
91
+ await client.string_value.put(value)
92
+
93
+
94
+ @pytest.mark.asyncio
95
+ async def test_unknown_value(client: DictionaryClient):
96
+ value = {"k1": 1, "k2": "hello", "k3": None}
97
+ assert await client.unknown_value.get() == value
98
+ await client.unknown_value.put(value)
@@ -0,0 +1,25 @@
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 typetest.enum.extensible import models, aio
8
+
9
+
10
+ @pytest.fixture
11
+ async def client():
12
+ async with aio.ExtensibleClient() as client:
13
+ yield client
14
+
15
+
16
+ @pytest.mark.asyncio
17
+ async def test_known_value(client):
18
+ assert await client.string.get_known_value() == models.DaysOfWeekExtensibleEnum.MONDAY
19
+ await client.string.put_known_value(models.DaysOfWeekExtensibleEnum.MONDAY)
20
+
21
+
22
+ @pytest.mark.asyncio
23
+ async def test_unknown_value(client):
24
+ assert await client.string.get_unknown_value() == "Weekend"
25
+ await client.string.put_unknown_value("Weekend")
@@ -0,0 +1,27 @@
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 typetest.enum.fixed import aio, models
8
+
9
+
10
+ @pytest.fixture
11
+ async def client():
12
+ async with aio.FixedClient() as client:
13
+ yield client
14
+
15
+
16
+ @pytest.mark.asyncio
17
+ async def test_known_value(client):
18
+ assert await client.string.get_known_value() == models.DaysOfWeekEnum.MONDAY
19
+ await client.string.put_known_value(models.DaysOfWeekEnum.MONDAY)
20
+
21
+
22
+ @pytest.mark.asyncio
23
+ async def test_unknown_value(client: aio.FixedClient, core_library):
24
+ try:
25
+ await client.string.put_unknown_value("Weekend")
26
+ except core_library.exceptions.HttpResponseError as err:
27
+ assert err.status_code == 500
@@ -0,0 +1,32 @@
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 typetest.model.empty.aio import EmptyClient
8
+ from typetest.model.empty.models import EmptyInput, EmptyOutput, EmptyInputOutput
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with EmptyClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.mark.asyncio
18
+ async def test_put(client: EmptyClient):
19
+ await client.put_empty(EmptyInput())
20
+ await client.put_empty({})
21
+
22
+
23
+ @pytest.mark.asyncio
24
+ async def test_get(client: EmptyClient):
25
+ assert await client.get_empty() == EmptyOutput()
26
+ assert await client.get_empty() == {}
27
+
28
+
29
+ @pytest.mark.asyncio
30
+ async def test_post_round(client: EmptyClient):
31
+ assert await client.post_round_trip_empty(EmptyInputOutput()) == EmptyInputOutput()
32
+ assert await client.post_round_trip_empty({}) == {}
@@ -0,0 +1,70 @@
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 typetest.model.enumdiscriminator.aio import EnumDiscriminatorClient
8
+ from typetest.model.enumdiscriminator import models
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with EnumDiscriminatorClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.fixture
18
+ def valid_body():
19
+ return models.Golden(weight=10)
20
+
21
+
22
+ @pytest.fixture
23
+ def valid_fixed_body():
24
+ return models.Cobra(length=10)
25
+
26
+
27
+ @pytest.mark.asyncio
28
+ async def test_get_extensible_model(client: EnumDiscriminatorClient, valid_body: models.Dog):
29
+ assert await client.get_extensible_model() == valid_body
30
+ assert isinstance(await client.get_extensible_model(), models.Golden)
31
+
32
+
33
+ @pytest.mark.asyncio
34
+ async def test_put_extensible_model(client: EnumDiscriminatorClient, valid_body: models.Dog):
35
+ await client.put_extensible_model(valid_body)
36
+
37
+
38
+ @pytest.mark.asyncio
39
+ async def test_get_extensible_model_missing_discriminator(
40
+ client: EnumDiscriminatorClient,
41
+ ):
42
+ assert await client.get_extensible_model_missing_discriminator() == models.Dog(weight=10)
43
+
44
+
45
+ @pytest.mark.asyncio
46
+ async def test_get_extensible_model_wrong_discriminator(
47
+ client: EnumDiscriminatorClient,
48
+ ):
49
+ assert await client.get_extensible_model_wrong_discriminator() == models.Dog(weight=8, kind="wrongKind")
50
+
51
+
52
+ @pytest.mark.asyncio
53
+ async def test_get_fixed_model(client: EnumDiscriminatorClient, valid_fixed_body: models.Snake):
54
+ assert await client.get_fixed_model() == valid_fixed_body
55
+ assert isinstance(await client.get_fixed_model(), models.Cobra)
56
+
57
+
58
+ @pytest.mark.asyncio
59
+ async def test_put_fixed_model(client: EnumDiscriminatorClient, valid_fixed_body: models.Snake):
60
+ await client.put_fixed_model(valid_fixed_body)
61
+
62
+
63
+ @pytest.mark.asyncio
64
+ async def test_get_fixed_model_missing_discriminator(client: EnumDiscriminatorClient):
65
+ assert await client.get_fixed_model_missing_discriminator() == models.Snake(length=10)
66
+
67
+
68
+ @pytest.mark.asyncio
69
+ async def test_get_fixed_model_wrong_discriminator(client: EnumDiscriminatorClient):
70
+ assert await client.get_fixed_model_wrong_discriminator() == models.Snake(length=8, kind="wrongKind")
@@ -0,0 +1,85 @@
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 typetest.model.nesteddiscriminator.aio import NestedDiscriminatorClient
8
+ from typetest.model.nesteddiscriminator.models import GoblinShark, Salmon, Fish
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with NestedDiscriminatorClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.fixture
18
+ async def valid_body():
19
+ return GoblinShark(age=1)
20
+
21
+
22
+ @pytest.mark.asyncio
23
+ async def test_get_model(client, valid_body):
24
+ assert await client.get_model() == valid_body
25
+ assert isinstance(await client.get_model(), GoblinShark)
26
+
27
+
28
+ @pytest.mark.asyncio
29
+ async def test_put_model(client, valid_body):
30
+ await client.put_model(valid_body)
31
+
32
+
33
+ @pytest.fixture
34
+ async def valid_recursive_body():
35
+ return Salmon(
36
+ {
37
+ "age": 1,
38
+ "kind": "salmon",
39
+ "partner": {"age": 2, "kind": "shark", "sharktype": "saw"},
40
+ "friends": [
41
+ {
42
+ "age": 2,
43
+ "kind": "salmon",
44
+ "partner": {"age": 3, "kind": "salmon"},
45
+ "hate": {
46
+ "key1": {"age": 4, "kind": "salmon"},
47
+ "key2": {"age": 2, "kind": "shark", "sharktype": "goblin"},
48
+ },
49
+ },
50
+ {"age": 3, "kind": "shark", "sharktype": "goblin"},
51
+ ],
52
+ "hate": {
53
+ "key3": {"age": 3, "kind": "shark", "sharktype": "saw"},
54
+ "key4": {
55
+ "age": 2,
56
+ "kind": "salmon",
57
+ "friends": [
58
+ {"age": 1, "kind": "salmon"},
59
+ {"age": 4, "kind": "shark", "sharktype": "goblin"},
60
+ ],
61
+ },
62
+ },
63
+ }
64
+ )
65
+
66
+
67
+ @pytest.mark.asyncio
68
+ async def test_get_recursive_model(client, valid_recursive_body):
69
+ assert valid_recursive_body == await client.get_recursive_model()
70
+ assert isinstance(await client.get_recursive_model(), Salmon)
71
+
72
+
73
+ @pytest.mark.asyncio
74
+ async def test_put_recursive_model(client, valid_recursive_body):
75
+ await client.put_recursive_model(valid_recursive_body)
76
+
77
+
78
+ @pytest.mark.asyncio
79
+ async def test_get_missing_discriminator(client):
80
+ assert await client.get_missing_discriminator() == Fish(age=1)
81
+
82
+
83
+ @pytest.mark.asyncio
84
+ async def test_get_wrong_discriminator(client):
85
+ assert await client.get_wrong_discriminator() == Fish(age=1, kind="wrongKind")
@@ -0,0 +1,34 @@
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 typetest.model.notdiscriminated.aio import NotDiscriminatedClient
8
+ from typetest.model.notdiscriminated.models import Siamese
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with NotDiscriminatedClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.fixture
18
+ async def valid_body():
19
+ return Siamese(name="abc", age=32, smart=True)
20
+
21
+
22
+ @pytest.mark.asyncio
23
+ async def test_get_valid(client, valid_body):
24
+ assert await client.get_valid() == valid_body
25
+
26
+
27
+ @pytest.mark.asyncio
28
+ async def test_post_valid(client, valid_body):
29
+ await client.post_valid(valid_body)
30
+
31
+
32
+ @pytest.mark.asyncio
33
+ async def test_put_valid(client, valid_body):
34
+ assert valid_body == await client.put_valid(valid_body)
@@ -0,0 +1,34 @@
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 typetest.model.recursive.aio import RecursiveClient
8
+ from typetest.model.recursive.models import Extension
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with RecursiveClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.fixture
18
+ async def expected():
19
+ return Extension(
20
+ {
21
+ "level": 0,
22
+ "extension": [{"level": 1, "extension": [{"level": 2}]}, {"level": 1}],
23
+ }
24
+ )
25
+
26
+
27
+ @pytest.mark.asyncio
28
+ async def test_put(client: RecursiveClient, expected: Extension):
29
+ await client.put(expected)
30
+
31
+
32
+ @pytest.mark.asyncio
33
+ async def test_get(client: RecursiveClient, expected: Extension):
34
+ assert await client.get() == expected
@@ -0,0 +1,67 @@
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 typetest.model.singlediscriminator.aio import SingleDiscriminatorClient
8
+ from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with SingleDiscriminatorClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.fixture
18
+ async def valid_body():
19
+ return Sparrow(wingspan=1)
20
+
21
+
22
+ @pytest.mark.asyncio
23
+ async def test_get_model(client, valid_body):
24
+ assert await client.get_model() == valid_body
25
+
26
+
27
+ @pytest.mark.asyncio
28
+ async def test_put_model(client, valid_body):
29
+ await client.put_model(valid_body)
30
+
31
+
32
+ @pytest.fixture
33
+ async def recursive_body():
34
+ return Eagle(
35
+ {
36
+ "wingspan": 5,
37
+ "kind": "eagle",
38
+ "partner": {"wingspan": 2, "kind": "goose"},
39
+ "friends": [{"wingspan": 2, "kind": "seagull"}],
40
+ "hate": {"key3": {"wingspan": 1, "kind": "sparrow"}},
41
+ }
42
+ )
43
+
44
+
45
+ @pytest.mark.asyncio
46
+ async def test_get_recursive_model(client, recursive_body):
47
+ assert await client.get_recursive_model() == recursive_body
48
+
49
+
50
+ @pytest.mark.asyncio
51
+ async def test_put_recursive_model(client, recursive_body):
52
+ await client.put_recursive_model(recursive_body)
53
+
54
+
55
+ @pytest.mark.asyncio
56
+ async def test_get_missing_discriminator(client):
57
+ assert await client.get_missing_discriminator() == Bird(wingspan=1)
58
+
59
+
60
+ @pytest.mark.asyncio
61
+ async def test_get_wrong_discriminator(client):
62
+ assert await client.get_wrong_discriminator() == Bird(wingspan=1, kind="wrongKind")
63
+
64
+
65
+ @pytest.mark.asyncio
66
+ async def test_get_legacy_model(client):
67
+ assert await client.get_legacy_model() == Dinosaur(size=20, kind="t-rex")
@@ -0,0 +1,32 @@
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 typetest.model.usage import models
8
+ from typetest.model.usage.aio import UsageClient
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with UsageClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.mark.asyncio
18
+ async def test_input(client: UsageClient):
19
+ input = models.InputRecord(required_prop="example-value")
20
+ assert await client.input(input) is None
21
+
22
+
23
+ @pytest.mark.asyncio
24
+ async def test_output(client: UsageClient):
25
+ output = models.OutputRecord(required_prop="example-value")
26
+ assert output == await client.output()
27
+
28
+
29
+ @pytest.mark.asyncio
30
+ async def test_input_and_output(client: UsageClient):
31
+ input_output = models.InputOutputRecord(required_prop="example-value")
32
+ assert input_output == await client.input_and_output(input_output)
@@ -0,0 +1,47 @@
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 typetest.model.visibility.aio import VisibilityClient
8
+ from typetest.model.visibility import models
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with VisibilityClient() as client:
14
+ yield client
15
+
16
+
17
+ @pytest.mark.asyncio
18
+ async def test_get_model(client):
19
+ result = await client.get_model(models.VisibilityModel(query_prop=123))
20
+ assert result == models.VisibilityModel(read_prop="abc")
21
+
22
+
23
+ @pytest.mark.asyncio
24
+ async def test_put_model(client):
25
+ await client.put_model(models.VisibilityModel(create_prop=["foo", "bar"], update_prop=[1, 2]))
26
+
27
+
28
+ @pytest.mark.asyncio
29
+ async def test_patch_model(client):
30
+ await client.patch_model(models.VisibilityModel(update_prop=[1, 2]))
31
+
32
+
33
+ @pytest.mark.asyncio
34
+ async def test_post_model(client):
35
+ await client.post_model(models.VisibilityModel(create_prop=["foo", "bar"]))
36
+
37
+
38
+ @pytest.mark.asyncio
39
+ async def test_delete_model(client):
40
+ await client.delete_model(models.VisibilityModel(delete_prop=True))
41
+
42
+
43
+ @pytest.mark.asyncio
44
+ async def test_put_read_only_model(client):
45
+ await client.put_read_only_model(
46
+ models.ReadOnlyModel(optional_nullable_int_list=[1, 2], optional_string_record={"foo", "bar"})
47
+ )