@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.
- package/README.md +118 -0
- package/dist/emitter/code-model.d.ts +4 -0
- package/dist/emitter/code-model.d.ts.map +1 -0
- package/dist/emitter/code-model.js +195 -0
- package/dist/emitter/code-model.js.map +1 -0
- package/dist/emitter/emitter.d.ts +6 -0
- package/dist/emitter/emitter.d.ts.map +1 -0
- package/dist/emitter/emitter.js +104 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/emitter/external-process.d.ts +20 -0
- package/dist/emitter/external-process.d.ts.map +1 -0
- package/dist/emitter/external-process.js +44 -0
- package/dist/emitter/external-process.js.map +1 -0
- package/dist/emitter/http.d.ts +7 -0
- package/dist/emitter/http.d.ts.map +1 -0
- package/dist/emitter/http.js +268 -0
- package/dist/emitter/http.js.map +1 -0
- package/dist/emitter/index.d.ts +3 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +3 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/emitter/lib.d.ts +30 -0
- package/dist/emitter/lib.d.ts.map +1 -0
- package/dist/emitter/lib.js +33 -0
- package/dist/emitter/lib.js.map +1 -0
- package/dist/emitter/types.d.ts +36 -0
- package/dist/emitter/types.d.ts.map +1 -0
- package/dist/emitter/types.js +491 -0
- package/dist/emitter/types.js.map +1 -0
- package/dist/emitter/utils.d.ts +26 -0
- package/dist/emitter/utils.d.ts.map +1 -0
- package/dist/emitter/utils.js +155 -0
- package/dist/emitter/utils.js.map +1 -0
- package/emitter/src/code-model.ts +272 -0
- package/emitter/src/emitter.ts +127 -0
- package/emitter/src/external-process.ts +52 -0
- package/emitter/src/http.ts +382 -0
- package/emitter/src/index.ts +2 -0
- package/emitter/src/lib.ts +59 -0
- package/emitter/src/types.ts +573 -0
- package/emitter/src/utils.ts +215 -0
- package/emitter/temp/tsconfig.tsbuildinfo +1 -0
- package/emitter/test/utils.test.ts +22 -0
- package/emitter/tsconfig.build.json +11 -0
- package/emitter/tsconfig.json +7 -0
- package/emitter/vitest.config.ts +4 -0
- package/eng/scripts/Build-Packages.ps1 +86 -0
- package/eng/scripts/Check-GitChanges.ps1 +22 -0
- package/eng/scripts/Functions.ps1 +26 -0
- package/eng/scripts/Generate.ps1 +11 -0
- package/eng/scripts/Generation.psm1 +22 -0
- package/eng/scripts/Initialize-Repository.ps1 +40 -0
- package/eng/scripts/Test-Packages.ps1 +65 -0
- package/eng/scripts/ci/format.ts +3 -0
- package/eng/scripts/ci/lint.ts +39 -0
- package/eng/scripts/ci/mypy.ini +38 -0
- package/eng/scripts/ci/pylintrc +59 -0
- package/eng/scripts/ci/pyproject.toml +18 -0
- package/eng/scripts/ci/pyrightconfig.json +6 -0
- package/eng/scripts/ci/regenerate.ts +299 -0
- package/eng/scripts/ci/run-ci.ts +88 -0
- package/eng/scripts/ci/run_apiview.py +40 -0
- package/eng/scripts/ci/run_mypy.py +49 -0
- package/eng/scripts/ci/run_pylint.py +50 -0
- package/eng/scripts/ci/run_pyright.py +58 -0
- package/eng/scripts/ci/util.py +72 -0
- package/eng/scripts/ci/utils.ts +48 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
- package/eng/scripts/setup/install.py +53 -0
- package/eng/scripts/setup/prepare.py +42 -0
- package/eng/scripts/setup/run-python3.ts +25 -0
- package/eng/scripts/setup/run_tsp.py +42 -0
- package/eng/scripts/setup/system-requirements.ts +261 -0
- package/eng/scripts/setup/venvtools.py +87 -0
- package/generator/LICENSE +21 -0
- package/generator/README.md +1 -0
- package/generator/dev_requirements.txt +13 -0
- package/generator/pygen/__init__.py +107 -0
- package/generator/pygen/_version.py +7 -0
- package/generator/pygen/black.py +71 -0
- package/generator/pygen/codegen/__init__.py +338 -0
- package/generator/pygen/codegen/_utils.py +17 -0
- package/generator/pygen/codegen/models/__init__.py +204 -0
- package/generator/pygen/codegen/models/base.py +186 -0
- package/generator/pygen/codegen/models/base_builder.py +118 -0
- package/generator/pygen/codegen/models/client.py +433 -0
- package/generator/pygen/codegen/models/code_model.py +237 -0
- package/generator/pygen/codegen/models/combined_type.py +149 -0
- package/generator/pygen/codegen/models/constant_type.py +129 -0
- package/generator/pygen/codegen/models/credential_types.py +214 -0
- package/generator/pygen/codegen/models/dictionary_type.py +127 -0
- package/generator/pygen/codegen/models/enum_type.py +238 -0
- package/generator/pygen/codegen/models/imports.py +291 -0
- package/generator/pygen/codegen/models/list_type.py +143 -0
- package/generator/pygen/codegen/models/lro_operation.py +142 -0
- package/generator/pygen/codegen/models/lro_paging_operation.py +32 -0
- package/generator/pygen/codegen/models/model_type.py +359 -0
- package/generator/pygen/codegen/models/operation.py +530 -0
- package/generator/pygen/codegen/models/operation_group.py +184 -0
- package/generator/pygen/codegen/models/paging_operation.py +155 -0
- package/generator/pygen/codegen/models/parameter.py +412 -0
- package/generator/pygen/codegen/models/parameter_list.py +387 -0
- package/generator/pygen/codegen/models/primitive_types.py +659 -0
- package/generator/pygen/codegen/models/property.py +170 -0
- package/generator/pygen/codegen/models/request_builder.py +189 -0
- package/generator/pygen/codegen/models/request_builder_parameter.py +115 -0
- package/generator/pygen/codegen/models/response.py +348 -0
- package/generator/pygen/codegen/models/utils.py +21 -0
- package/generator/pygen/codegen/serializers/__init__.py +574 -0
- package/generator/pygen/codegen/serializers/base_serializer.py +21 -0
- package/generator/pygen/codegen/serializers/builder_serializer.py +1507 -0
- package/generator/pygen/codegen/serializers/client_serializer.py +294 -0
- package/generator/pygen/codegen/serializers/enum_serializer.py +15 -0
- package/generator/pygen/codegen/serializers/general_serializer.py +213 -0
- package/generator/pygen/codegen/serializers/import_serializer.py +126 -0
- package/generator/pygen/codegen/serializers/metadata_serializer.py +198 -0
- package/generator/pygen/codegen/serializers/model_init_serializer.py +33 -0
- package/generator/pygen/codegen/serializers/model_serializer.py +317 -0
- package/generator/pygen/codegen/serializers/operation_groups_serializer.py +89 -0
- package/generator/pygen/codegen/serializers/operations_init_serializer.py +44 -0
- package/generator/pygen/codegen/serializers/parameter_serializer.py +221 -0
- package/generator/pygen/codegen/serializers/patch_serializer.py +19 -0
- package/generator/pygen/codegen/serializers/request_builders_serializer.py +52 -0
- package/generator/pygen/codegen/serializers/sample_serializer.py +168 -0
- package/generator/pygen/codegen/serializers/test_serializer.py +292 -0
- package/generator/pygen/codegen/serializers/types_serializer.py +31 -0
- package/generator/pygen/codegen/serializers/utils.py +68 -0
- package/generator/pygen/codegen/templates/client.py.jinja2 +37 -0
- package/generator/pygen/codegen/templates/client_container.py.jinja2 +12 -0
- package/generator/pygen/codegen/templates/config.py.jinja2 +73 -0
- package/generator/pygen/codegen/templates/config_container.py.jinja2 +16 -0
- package/generator/pygen/codegen/templates/conftest.py.jinja2 +28 -0
- package/generator/pygen/codegen/templates/enum.py.jinja2 +13 -0
- package/generator/pygen/codegen/templates/enum_container.py.jinja2 +10 -0
- package/generator/pygen/codegen/templates/init.py.jinja2 +24 -0
- package/generator/pygen/codegen/templates/keywords.jinja2 +19 -0
- package/generator/pygen/codegen/templates/lro_operation.py.jinja2 +16 -0
- package/generator/pygen/codegen/templates/lro_paging_operation.py.jinja2 +18 -0
- package/generator/pygen/codegen/templates/macros.jinja2 +12 -0
- package/generator/pygen/codegen/templates/metadata.json.jinja2 +167 -0
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +1157 -0
- package/generator/pygen/codegen/templates/model_container.py.jinja2 +12 -0
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +97 -0
- package/generator/pygen/codegen/templates/model_init.py.jinja2 +28 -0
- package/generator/pygen/codegen/templates/model_msrest.py.jinja2 +92 -0
- package/generator/pygen/codegen/templates/operation.py.jinja2 +21 -0
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +75 -0
- package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +19 -0
- package/generator/pygen/codegen/templates/operation_tools.jinja2 +81 -0
- package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +17 -0
- package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +6 -0
- package/generator/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +21 -0
- package/generator/pygen/codegen/templates/packaging_templates/MANIFEST.in.jinja2 +8 -0
- package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +107 -0
- package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +9 -0
- package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +108 -0
- package/generator/pygen/codegen/templates/paging_operation.py.jinja2 +21 -0
- package/generator/pygen/codegen/templates/patch.py.jinja2 +19 -0
- package/generator/pygen/codegen/templates/pkgutil_init.py.jinja2 +1 -0
- package/generator/pygen/codegen/templates/request_builder.py.jinja2 +28 -0
- package/generator/pygen/codegen/templates/request_builders.py.jinja2 +10 -0
- package/generator/pygen/codegen/templates/rest_init.py.jinja2 +12 -0
- package/generator/pygen/codegen/templates/sample.py.jinja2 +44 -0
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +2114 -0
- package/generator/pygen/codegen/templates/test.py.jinja2 +50 -0
- package/generator/pygen/codegen/templates/testpreparer.py.jinja2 +26 -0
- package/generator/pygen/codegen/templates/types.py.jinja2 +7 -0
- package/generator/pygen/codegen/templates/validation.py.jinja2 +38 -0
- package/generator/pygen/codegen/templates/vendor.py.jinja2 +95 -0
- package/generator/pygen/codegen/templates/version.py.jinja2 +4 -0
- package/generator/pygen/m2r.py +65 -0
- package/generator/pygen/postprocess/__init__.py +183 -0
- package/generator/pygen/postprocess/get_all.py +19 -0
- package/generator/pygen/postprocess/venvtools.py +75 -0
- package/generator/pygen/preprocess/__init__.py +515 -0
- package/generator/pygen/preprocess/helpers.py +27 -0
- package/generator/pygen/preprocess/python_mappings.py +224 -0
- package/generator/pygen/utils.py +163 -0
- package/generator/pygen.egg-info/PKG-INFO +25 -0
- package/generator/pygen.egg-info/SOURCES.txt +66 -0
- package/generator/pygen.egg-info/dependency_links.txt +1 -0
- package/generator/pygen.egg-info/requires.txt +4 -0
- package/generator/pygen.egg-info/top_level.txt +1 -0
- package/generator/requirements.txt +12 -0
- package/generator/setup.py +55 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_models_common_types_managed_identity_async.py +63 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_models_resource_async.py +284 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_access_async.py +101 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +93 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py +31 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py +76 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py +22 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py +39 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_model_async.py +33 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_page_async.py +58 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py +41 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py +87 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_example_basic_async.py +30 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py +30 -0
- package/generator/test/azure/mock_api_tests/conftest.py +150 -0
- package/generator/test/azure/mock_api_tests/test_azure_arm_models_common_types_managed_identity.py +60 -0
- package/generator/test/azure/mock_api_tests/test_azure_arm_models_resource.py +254 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_access.py +92 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +84 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py +28 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_basic.py +70 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_lro_rpc.py +20 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_lro_standard.py +32 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_model.py +30 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_page.py +51 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_scalar.py +35 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_traits.py +85 -0
- package/generator/test/azure/mock_api_tests/test_azure_example_basic.py +29 -0
- package/generator/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py +29 -0
- package/generator/test/azure/requirements.txt +89 -0
- package/generator/test/azure/tox.ini +56 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +121 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_client_naming_async.py +69 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_client_structure_async.py +62 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +133 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_datetime_async.py +127 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py +63 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_numeric_async.py +35 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_headasboolean_async.py +35 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_parameters_basic_async.py +24 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_parameters_body_optionality_async.py +30 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py +44 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py +76 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_content_negotiation_async.py +37 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_json_merge_patch_async.py +98 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_media_type_async.py +27 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py +153 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +19 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +103 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py +128 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_routes_async.py +331 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_serialization_encoded_name_json_async.py +24 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_server_endpoint_not_defined_async.py +18 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_server_path_multiple_async.py +25 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_server_path_single_async.py +18 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_server_versions_not_versioned_async.py +28 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_server_versions_versioned_async.py +34 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_special_headers_conditional_request_async.py +38 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_special_headers_repeatability_async.py +19 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_special_words_async.py +42 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_array_async.py +118 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_dictionary_async.py +98 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_enum_extensible_async.py +25 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_enum_fixed_async.py +27 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_empty_async.py +32 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py +70 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py +85 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_not_discriminated_async.py +34 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py +34 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_single_discriminator_async.py +67 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_usage_async.py +32 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_model_visibility_async.py +47 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py +352 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py +110 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py +197 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py +315 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_scalar_async.py +60 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_union_async.py +90 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py +36 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py +21 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +21 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py +29 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py +18 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py +22 -0
- package/generator/test/generic_mock_api_tests/conftest.py +113 -0
- package/generator/test/generic_mock_api_tests/data/image.jpg +0 -0
- package/generator/test/generic_mock_api_tests/data/image.png +0 -0
- package/generator/test/generic_mock_api_tests/test_authentication.py +113 -0
- package/generator/test/generic_mock_api_tests/test_client_naming.py +57 -0
- package/generator/test/generic_mock_api_tests/test_client_structure.py +57 -0
- package/generator/test/generic_mock_api_tests/test_encode_bytes.py +128 -0
- package/generator/test/generic_mock_api_tests/test_encode_datetime.py +123 -0
- package/generator/test/generic_mock_api_tests/test_encode_duration.py +60 -0
- package/generator/test/generic_mock_api_tests/test_encode_numeric.py +31 -0
- package/generator/test/generic_mock_api_tests/test_headasboolean.py +33 -0
- package/generator/test/generic_mock_api_tests/test_parameters_basic.py +22 -0
- package/generator/test/generic_mock_api_tests/test_parameters_body_optionality.py +27 -0
- package/generator/test/generic_mock_api_tests/test_parameters_collection_format.py +37 -0
- package/generator/test/generic_mock_api_tests/test_parameters_spread.py +66 -0
- package/generator/test/generic_mock_api_tests/test_payload_content_negotiation.py +33 -0
- package/generator/test/generic_mock_api_tests/test_payload_json_merge_patch.py +93 -0
- package/generator/test/generic_mock_api_tests/test_payload_media_type.py +25 -0
- package/generator/test/generic_mock_api_tests/test_payload_multipart.py +140 -0
- package/generator/test/generic_mock_api_tests/test_payload_pageable.py +18 -0
- package/generator/test/generic_mock_api_tests/test_payload_xml.py +93 -0
- package/generator/test/generic_mock_api_tests/test_resiliency_srv_driven.py +122 -0
- package/generator/test/generic_mock_api_tests/test_routes.py +285 -0
- package/generator/test/generic_mock_api_tests/test_serialization_encoded_name_json.py +21 -0
- package/generator/test/generic_mock_api_tests/test_server_endpoint_not_defined.py +17 -0
- package/generator/test/generic_mock_api_tests/test_server_path_multiple.py +21 -0
- package/generator/test/generic_mock_api_tests/test_server_path_single.py +17 -0
- package/generator/test/generic_mock_api_tests/test_server_versions_not_versioned.py +25 -0
- package/generator/test/generic_mock_api_tests/test_server_versions_versioned.py +30 -0
- package/generator/test/generic_mock_api_tests/test_special_headers_conditional_request.py +34 -0
- package/generator/test/generic_mock_api_tests/test_special_headers_repeatability.py +18 -0
- package/generator/test/generic_mock_api_tests/test_special_words.py +37 -0
- package/generator/test/generic_mock_api_tests/test_typetest_array.py +103 -0
- package/generator/test/generic_mock_api_tests/test_typetest_dictionary.py +86 -0
- package/generator/test/generic_mock_api_tests/test_typetest_enum_extensible.py +23 -0
- package/generator/test/generic_mock_api_tests/test_typetest_enum_fixed.py +25 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_empty.py +29 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_enum_discriminator.py +58 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py +79 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_not_discriminated.py +31 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py +32 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_inheritance_single_discriminator.py +60 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_usage.py +28 -0
- package/generator/test/generic_mock_api_tests/test_typetest_model_visibility.py +40 -0
- package/generator/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py +313 -0
- package/generator/test/generic_mock_api_tests/test_typetest_property_nullable.py +102 -0
- package/generator/test/generic_mock_api_tests/test_typetest_property_optional.py +174 -0
- package/generator/test/generic_mock_api_tests/test_typetest_property_valuetypes.py +286 -0
- package/generator/test/generic_mock_api_tests/test_typetest_scalar.py +53 -0
- package/generator/test/generic_mock_api_tests/test_typetest_union.py +80 -0
- package/generator/test/generic_mock_api_tests/test_versioning_added.py +33 -0
- package/generator/test/generic_mock_api_tests/test_versioning_made_optional.py +20 -0
- package/generator/test/generic_mock_api_tests/test_versioning_removed.py +20 -0
- package/generator/test/generic_mock_api_tests/test_versioning_renamed_from.py +27 -0
- package/generator/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py +17 -0
- package/generator/test/generic_mock_api_tests/test_versioning_type_changed_from.py +21 -0
- package/generator/test/generic_mock_api_tests/unittests/test_model_base_serialization.py +4067 -0
- package/generator/test/generic_mock_api_tests/unittests/test_model_base_xml_serialization.py +1001 -0
- package/generator/test/unbranded/mock_api_tests/asynctests/test_unbranded_async.py +24 -0
- package/generator/test/unbranded/mock_api_tests/cadl-ranch-config.yaml +27 -0
- package/generator/test/unbranded/mock_api_tests/conftest.py +35 -0
- package/generator/test/unbranded/mock_api_tests/test_unbranded.py +57 -0
- package/generator/test/unbranded/requirements.txt +72 -0
- package/generator/test/unbranded/tox.ini +56 -0
- package/package.json +93 -0
|
@@ -0,0 +1,352 @@
|
|
|
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.property.additionalproperties import models
|
|
8
|
+
from typetest.property.additionalproperties.aio import AdditionalPropertiesClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
async def client():
|
|
13
|
+
async with AdditionalPropertiesClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.asyncio
|
|
18
|
+
async def test_extends_different_spread_float(client: AdditionalPropertiesClient):
|
|
19
|
+
body = models.DifferentSpreadFloatDerived({"name": "abc", "prop": 43.125, "derivedProp": 43.125})
|
|
20
|
+
assert await client.extends_different_spread_float.get() == body
|
|
21
|
+
await client.extends_different_spread_float.put(body)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
async def test_extends_different_spread_model(client: AdditionalPropertiesClient):
|
|
26
|
+
body = models.DifferentSpreadModelDerived(
|
|
27
|
+
{"knownProp": "abc", "prop": {"state": "ok"}, "derivedProp": {"state": "ok"}}
|
|
28
|
+
)
|
|
29
|
+
assert await client.extends_different_spread_model.get() == body
|
|
30
|
+
await client.extends_different_spread_model.put(body)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@pytest.mark.asyncio
|
|
34
|
+
async def test_extends_different_spread_model_array(client: AdditionalPropertiesClient):
|
|
35
|
+
body = models.DifferentSpreadModelArrayDerived(
|
|
36
|
+
{
|
|
37
|
+
"knownProp": "abc",
|
|
38
|
+
"prop": [{"state": "ok"}, {"state": "ok"}],
|
|
39
|
+
"derivedProp": [{"state": "ok"}, {"state": "ok"}],
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
assert await client.extends_different_spread_model_array.get() == body
|
|
43
|
+
await client.extends_different_spread_model_array.put(body)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_extends_different_spread_string(client: AdditionalPropertiesClient):
|
|
48
|
+
body = models.DifferentSpreadStringDerived({"id": 43.125, "prop": "abc", "derivedProp": "abc"})
|
|
49
|
+
assert await client.extends_different_spread_string.get() == body
|
|
50
|
+
await client.extends_different_spread_string.put(body)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.asyncio
|
|
54
|
+
async def test_extends_float(client: AdditionalPropertiesClient):
|
|
55
|
+
body = models.ExtendsFloatAdditionalProperties({"id": 43.125, "prop": 43.125})
|
|
56
|
+
assert await client.extends_float.get() == body
|
|
57
|
+
await client.extends_float.put(body)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@pytest.mark.asyncio
|
|
61
|
+
async def test_extends_model(client: AdditionalPropertiesClient):
|
|
62
|
+
body = models.ExtendsModelAdditionalProperties({"knownProp": {"state": "ok"}, "prop": {"state": "ok"}})
|
|
63
|
+
assert await client.extends_model.get() == body
|
|
64
|
+
await client.extends_model.put(body)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.asyncio
|
|
68
|
+
async def test_extends_model_array(client: AdditionalPropertiesClient):
|
|
69
|
+
body = models.ExtendsModelArrayAdditionalProperties(
|
|
70
|
+
{
|
|
71
|
+
"knownProp": [{"state": "ok"}, {"state": "ok"}],
|
|
72
|
+
"prop": [{"state": "ok"}, {"state": "ok"}],
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
assert await client.extends_model_array.get() == body
|
|
76
|
+
await client.extends_model_array.put(body)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.asyncio
|
|
80
|
+
async def test_extends_string(client: AdditionalPropertiesClient):
|
|
81
|
+
body = models.ExtendsStringAdditionalProperties({"name": "ExtendsStringAdditionalProperties", "prop": "abc"})
|
|
82
|
+
assert await client.extends_string.get() == body
|
|
83
|
+
await client.extends_string.put(body)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@pytest.mark.asyncio
|
|
87
|
+
async def test_extends_unknown(client: AdditionalPropertiesClient):
|
|
88
|
+
body = models.ExtendsUnknownAdditionalProperties(
|
|
89
|
+
{
|
|
90
|
+
"name": "ExtendsUnknownAdditionalProperties",
|
|
91
|
+
"prop1": 32,
|
|
92
|
+
"prop2": True,
|
|
93
|
+
"prop3": "abc",
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
assert await client.extends_unknown.get() == body
|
|
97
|
+
await client.extends_unknown.put(body)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@pytest.mark.asyncio
|
|
101
|
+
async def test_extends_unknown_derived(client: AdditionalPropertiesClient):
|
|
102
|
+
body = models.ExtendsUnknownAdditionalPropertiesDerived(
|
|
103
|
+
{
|
|
104
|
+
"name": "ExtendsUnknownAdditionalProperties",
|
|
105
|
+
"index": 314,
|
|
106
|
+
"age": 2.71875,
|
|
107
|
+
"prop1": 32,
|
|
108
|
+
"prop2": True,
|
|
109
|
+
"prop3": "abc",
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
assert await client.extends_unknown_derived.get() == body
|
|
113
|
+
await client.extends_unknown_derived.put(body)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@pytest.mark.asyncio
|
|
117
|
+
async def test_extends_unknown_discriminated(client: AdditionalPropertiesClient):
|
|
118
|
+
body = models.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived(
|
|
119
|
+
{
|
|
120
|
+
"kind": "derived",
|
|
121
|
+
"name": "Derived",
|
|
122
|
+
"index": 314,
|
|
123
|
+
"age": 2.71875,
|
|
124
|
+
"prop1": 32,
|
|
125
|
+
"prop2": True,
|
|
126
|
+
"prop3": "abc",
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
assert await client.extends_unknown_discriminated.get() == body
|
|
130
|
+
await client.extends_unknown_discriminated.put(body)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@pytest.mark.asyncio
|
|
134
|
+
async def test_is_float(client: AdditionalPropertiesClient):
|
|
135
|
+
body = models.IsFloatAdditionalProperties({"id": 43.125, "prop": 43.125})
|
|
136
|
+
assert await client.is_float.get() == body
|
|
137
|
+
await client.is_float.put(body)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@pytest.mark.asyncio
|
|
141
|
+
async def test_is_model(client: AdditionalPropertiesClient):
|
|
142
|
+
body = models.IsModelAdditionalProperties({"knownProp": {"state": "ok"}, "prop": {"state": "ok"}})
|
|
143
|
+
assert await client.is_model.get() == body
|
|
144
|
+
await client.is_model.put(body)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@pytest.mark.asyncio
|
|
148
|
+
async def test_is_model_array(client: AdditionalPropertiesClient):
|
|
149
|
+
body = models.IsModelArrayAdditionalProperties(
|
|
150
|
+
{
|
|
151
|
+
"knownProp": [{"state": "ok"}, {"state": "ok"}],
|
|
152
|
+
"prop": [{"state": "ok"}, {"state": "ok"}],
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
assert await client.is_model_array.get() == body
|
|
156
|
+
await client.is_model_array.put(body)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@pytest.mark.asyncio
|
|
160
|
+
async def test_is_string(client: AdditionalPropertiesClient):
|
|
161
|
+
body = models.IsStringAdditionalProperties({"name": "IsStringAdditionalProperties", "prop": "abc"})
|
|
162
|
+
assert await client.is_string.get() == body
|
|
163
|
+
await client.is_string.put(body)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@pytest.mark.asyncio
|
|
167
|
+
async def test_is_unknown(client: AdditionalPropertiesClient):
|
|
168
|
+
body = models.IsUnknownAdditionalProperties(
|
|
169
|
+
{
|
|
170
|
+
"name": "IsUnknownAdditionalProperties",
|
|
171
|
+
"prop1": 32,
|
|
172
|
+
"prop2": True,
|
|
173
|
+
"prop3": "abc",
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
assert await client.is_unknown.get() == body
|
|
177
|
+
await client.is_unknown.put(body)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@pytest.mark.asyncio
|
|
181
|
+
async def test_is_unknown_derived(client: AdditionalPropertiesClient):
|
|
182
|
+
body = models.IsUnknownAdditionalPropertiesDerived(
|
|
183
|
+
{
|
|
184
|
+
"name": "IsUnknownAdditionalProperties",
|
|
185
|
+
"index": 314,
|
|
186
|
+
"age": 2.71875,
|
|
187
|
+
"prop1": 32,
|
|
188
|
+
"prop2": True,
|
|
189
|
+
"prop3": "abc",
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
assert await client.is_unknown_derived.get() == body
|
|
193
|
+
await client.is_unknown_derived.put(body)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@pytest.mark.asyncio
|
|
197
|
+
async def test_is_unknown_discriminated(client: AdditionalPropertiesClient):
|
|
198
|
+
body = models.IsUnknownAdditionalPropertiesDiscriminatedDerived(
|
|
199
|
+
{
|
|
200
|
+
"kind": "derived",
|
|
201
|
+
"name": "Derived",
|
|
202
|
+
"index": 314,
|
|
203
|
+
"age": 2.71875,
|
|
204
|
+
"prop1": 32,
|
|
205
|
+
"prop2": True,
|
|
206
|
+
"prop3": "abc",
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
assert await client.is_unknown_discriminated.get() == body
|
|
210
|
+
await client.is_unknown_discriminated.put(body)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@pytest.mark.asyncio
|
|
214
|
+
async def test_multiple_spread(client: AdditionalPropertiesClient):
|
|
215
|
+
body = {"flag": True, "prop1": "abc", "prop2": 43.125}
|
|
216
|
+
assert await client.multiple_spread.get() == body
|
|
217
|
+
await client.multiple_spread.put(body)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@pytest.mark.asyncio
|
|
221
|
+
async def test_spread_different_float(client: AdditionalPropertiesClient):
|
|
222
|
+
body = {"name": "abc", "prop": 43.125}
|
|
223
|
+
assert await client.spread_different_float.get() == body
|
|
224
|
+
await client.spread_different_float.put(body)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@pytest.mark.asyncio
|
|
228
|
+
async def test_spread_different_model(client: AdditionalPropertiesClient):
|
|
229
|
+
body = {"knownProp": "abc", "prop": {"state": "ok"}}
|
|
230
|
+
assert await client.spread_different_model.get() == body
|
|
231
|
+
await client.spread_different_model.put(body)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@pytest.mark.asyncio
|
|
235
|
+
async def test_spread_different_model_array(client: AdditionalPropertiesClient):
|
|
236
|
+
body = {"knownProp": "abc", "prop": [{"state": "ok"}, {"state": "ok"}]}
|
|
237
|
+
assert await client.spread_different_model_array.get() == body
|
|
238
|
+
await client.spread_different_model_array.put(body)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@pytest.mark.asyncio
|
|
242
|
+
async def test_spread_different_string(client: AdditionalPropertiesClient):
|
|
243
|
+
body = {"id": 43.125, "prop": "abc"}
|
|
244
|
+
assert await client.spread_different_string.get() == body
|
|
245
|
+
await client.spread_different_string.put(body)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@pytest.mark.asyncio
|
|
249
|
+
async def test_spread_model(client: AdditionalPropertiesClient):
|
|
250
|
+
body = {"knownProp": {"state": "ok"}, "prop": {"state": "ok"}}
|
|
251
|
+
assert await client.spread_model.get() == body
|
|
252
|
+
await client.spread_model.put(body)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@pytest.mark.asyncio
|
|
256
|
+
async def test_spread_model_array(client: AdditionalPropertiesClient):
|
|
257
|
+
body = {
|
|
258
|
+
"knownProp": [{"state": "ok"}, {"state": "ok"}],
|
|
259
|
+
"prop": [{"state": "ok"}, {"state": "ok"}],
|
|
260
|
+
}
|
|
261
|
+
assert await client.spread_model_array.get() == body
|
|
262
|
+
await client.spread_model_array.put(body)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@pytest.mark.asyncio
|
|
266
|
+
async def test_spread_record_discriminated_union(client: AdditionalPropertiesClient):
|
|
267
|
+
body = {
|
|
268
|
+
"name": "abc",
|
|
269
|
+
"prop1": {"fooProp": "abc", "kind": "kind0"},
|
|
270
|
+
"prop2": {
|
|
271
|
+
"end": "2021-01-02T00:00:00Z",
|
|
272
|
+
"kind": "kind1",
|
|
273
|
+
"start": "2021-01-01T00:00:00Z",
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
assert await client.spread_record_discriminated_union.get() == body
|
|
277
|
+
await client.spread_record_discriminated_union.put(body)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
@pytest.mark.asyncio
|
|
281
|
+
async def test_spread_record_non_discriminated_union(
|
|
282
|
+
client: AdditionalPropertiesClient,
|
|
283
|
+
):
|
|
284
|
+
body = {
|
|
285
|
+
"name": "abc",
|
|
286
|
+
"prop1": {"kind": "kind0", "fooProp": "abc"},
|
|
287
|
+
"prop2": {
|
|
288
|
+
"kind": "kind1",
|
|
289
|
+
"start": "2021-01-01T00:00:00Z",
|
|
290
|
+
"end": "2021-01-02T00:00:00Z",
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
assert await client.spread_record_non_discriminated_union.get() == body
|
|
294
|
+
await client.spread_record_non_discriminated_union.put(body)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@pytest.mark.asyncio
|
|
298
|
+
async def test_spread_record_non_discriminated_union2(
|
|
299
|
+
client: AdditionalPropertiesClient,
|
|
300
|
+
):
|
|
301
|
+
body = {
|
|
302
|
+
"name": "abc",
|
|
303
|
+
"prop1": {"kind": "kind1", "start": "2021-01-01T00:00:00Z"},
|
|
304
|
+
"prop2": {
|
|
305
|
+
"kind": "kind1",
|
|
306
|
+
"start": "2021-01-01T00:00:00Z",
|
|
307
|
+
"end": "2021-01-02T00:00:00Z",
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
assert await client.spread_record_non_discriminated_union2.get() == body
|
|
311
|
+
await client.spread_record_non_discriminated_union2.put(body)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
@pytest.mark.asyncio
|
|
315
|
+
async def test_spread_record_non_discriminated_union3(
|
|
316
|
+
client: AdditionalPropertiesClient,
|
|
317
|
+
):
|
|
318
|
+
body = {
|
|
319
|
+
"name": "abc",
|
|
320
|
+
"prop1": [
|
|
321
|
+
{"kind": "kind1", "start": "2021-01-01T00:00:00Z"},
|
|
322
|
+
{"kind": "kind1", "start": "2021-01-01T00:00:00Z"},
|
|
323
|
+
],
|
|
324
|
+
"prop2": {
|
|
325
|
+
"kind": "kind1",
|
|
326
|
+
"start": "2021-01-01T00:00:00Z",
|
|
327
|
+
"end": "2021-01-02T00:00:00Z",
|
|
328
|
+
},
|
|
329
|
+
}
|
|
330
|
+
assert await client.spread_record_non_discriminated_union3.get() == body
|
|
331
|
+
await client.spread_record_non_discriminated_union3.put(body)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@pytest.mark.asyncio
|
|
335
|
+
async def test_spread_record_union(client: AdditionalPropertiesClient):
|
|
336
|
+
body = {"flag": True, "prop1": "abc", "prop2": 43.125}
|
|
337
|
+
assert await client.spread_record_union.get() == body
|
|
338
|
+
await client.spread_record_union.put(body)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
@pytest.mark.asyncio
|
|
342
|
+
async def test_spread_string(client: AdditionalPropertiesClient):
|
|
343
|
+
body = {"name": "SpreadSpringRecord", "prop": "abc"}
|
|
344
|
+
assert await client.spread_string.get() == body
|
|
345
|
+
await client.spread_string.put(body)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@pytest.mark.asyncio
|
|
349
|
+
async def test_spread_float(client: AdditionalPropertiesClient):
|
|
350
|
+
body = {"id": 43.125, "prop": 43.125}
|
|
351
|
+
assert await client.spread_float.get() == body
|
|
352
|
+
await client.spread_float.put(body)
|
package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# cspell: ignore Hdvcmxk
|
|
2
|
+
# -------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
5
|
+
# license information.
|
|
6
|
+
# --------------------------------------------------------------------------
|
|
7
|
+
import json
|
|
8
|
+
import pytest
|
|
9
|
+
from typetest.property.nullable import models
|
|
10
|
+
from typetest.property.nullable.aio import NullableClient
|
|
11
|
+
from typetest.property.nullable._model_base import ( # pylint: disable=protected-access
|
|
12
|
+
SdkJSONEncoder,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
from corehttp.serialization import NULL
|
|
17
|
+
except ImportError:
|
|
18
|
+
from azure.core.serialization import NULL
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture
|
|
22
|
+
async def client():
|
|
23
|
+
async with NullableClient() as client:
|
|
24
|
+
yield client
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.asyncio
|
|
28
|
+
async def test_bytes(client: NullableClient):
|
|
29
|
+
non_null_model = models.BytesProperty(required_property="foo", nullable_property="aGVsbG8sIHdvcmxkIQ==")
|
|
30
|
+
non_model = models.BytesProperty(required_property="foo", nullable_property=NULL)
|
|
31
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
32
|
+
assert await client.bytes.get_non_null() == non_null_model
|
|
33
|
+
assert (await client.bytes.get_null())["nullableProperty"] is None
|
|
34
|
+
await client.bytes.patch_non_null(body=non_null_model)
|
|
35
|
+
await client.bytes.patch_null(body=non_model)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.asyncio
|
|
39
|
+
async def test_collections_byte(client: NullableClient):
|
|
40
|
+
non_null_model = models.CollectionsByteProperty(
|
|
41
|
+
required_property="foo",
|
|
42
|
+
nullable_property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="],
|
|
43
|
+
)
|
|
44
|
+
non_model = models.CollectionsByteProperty(required_property="foo", nullable_property=NULL)
|
|
45
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
46
|
+
assert await client.collections_byte.get_non_null() == non_null_model
|
|
47
|
+
assert (await client.collections_byte.get_null())["nullableProperty"] is None
|
|
48
|
+
await client.collections_byte.patch_non_null(body=non_null_model)
|
|
49
|
+
await client.collections_byte.patch_null(body=non_model)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.mark.asyncio
|
|
53
|
+
async def test_collections_model(client: NullableClient):
|
|
54
|
+
non_null_model = models.CollectionsModelProperty(
|
|
55
|
+
required_property="foo",
|
|
56
|
+
nullable_property=[
|
|
57
|
+
models.InnerModel(property="hello"),
|
|
58
|
+
models.InnerModel(property="world"),
|
|
59
|
+
],
|
|
60
|
+
)
|
|
61
|
+
non_model = models.CollectionsModelProperty(required_property="foo", nullable_property=NULL)
|
|
62
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
63
|
+
assert await client.collections_model.get_non_null() == non_null_model
|
|
64
|
+
assert (await client.collections_model.get_null())["nullableProperty"] is None
|
|
65
|
+
await client.collections_model.patch_non_null(body=non_null_model)
|
|
66
|
+
await client.collections_model.patch_null(body=non_model)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.asyncio
|
|
70
|
+
async def test_collections_string(client: NullableClient):
|
|
71
|
+
non_null_model = models.CollectionsStringProperty(required_property="foo", nullable_property=["hello", "world"])
|
|
72
|
+
non_model = models.CollectionsStringProperty(required_property="foo", nullable_property=NULL)
|
|
73
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
74
|
+
assert await client.collections_string.get_non_null() == non_null_model
|
|
75
|
+
assert (await client.collections_string.get_null())["nullableProperty"] is None
|
|
76
|
+
await client.collections_string.patch_non_null(body=non_null_model)
|
|
77
|
+
await client.collections_string.patch_null(body=non_model)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pytest.mark.asyncio
|
|
81
|
+
async def test_datetime(client: NullableClient):
|
|
82
|
+
non_null_model = models.DatetimeProperty(required_property="foo", nullable_property="2022-08-26T18:38:00Z")
|
|
83
|
+
non_model = models.DatetimeProperty(required_property="foo", nullable_property=NULL)
|
|
84
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
85
|
+
assert await client.datetime.get_non_null() == non_null_model
|
|
86
|
+
assert (await client.datetime.get_null())["nullableProperty"] is None
|
|
87
|
+
await client.datetime.patch_non_null(body=non_null_model)
|
|
88
|
+
await client.datetime.patch_null(body=non_model)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@pytest.mark.asyncio
|
|
92
|
+
async def test_duration(client: NullableClient):
|
|
93
|
+
non_null_model = models.DurationProperty(required_property="foo", nullable_property="P123DT22H14M12.011S")
|
|
94
|
+
non_model = models.DurationProperty(required_property="foo", nullable_property=NULL)
|
|
95
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
96
|
+
assert await client.duration.get_non_null() == non_null_model
|
|
97
|
+
assert (await client.duration.get_null())["nullableProperty"] is None
|
|
98
|
+
await client.duration.patch_non_null(body=non_null_model)
|
|
99
|
+
await client.duration.patch_null(body=non_model)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@pytest.mark.asyncio
|
|
103
|
+
async def test_string(client: NullableClient):
|
|
104
|
+
non_null_model = models.StringProperty(required_property="foo", nullable_property="hello")
|
|
105
|
+
non_model = models.StringProperty(required_property="foo", nullable_property=NULL)
|
|
106
|
+
assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder)
|
|
107
|
+
assert await client.string.get_non_null() == non_null_model
|
|
108
|
+
assert (await client.string.get_null())["nullableProperty"] is None
|
|
109
|
+
await client.string.patch_non_null(body=non_null_model)
|
|
110
|
+
await client.string.patch_null(body=non_model)
|
package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# cspell: ignore Hdvcmxk
|
|
2
|
+
# -------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
5
|
+
# license information.
|
|
6
|
+
# --------------------------------------------------------------------------
|
|
7
|
+
from typing import Any
|
|
8
|
+
import pytest
|
|
9
|
+
from typetest.property.optional import models
|
|
10
|
+
from typetest.property.optional.aio import OptionalClient
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture
|
|
14
|
+
async def client():
|
|
15
|
+
async with OptionalClient() as client:
|
|
16
|
+
yield client
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.mark.asyncio
|
|
20
|
+
async def test_boolean_literal(client):
|
|
21
|
+
body = models.BooleanLiteralProperty(property=True)
|
|
22
|
+
assert await client.boolean_literal.get_all() == body
|
|
23
|
+
assert await client.boolean_literal.get_default() == models.BooleanLiteralProperty()
|
|
24
|
+
await client.boolean_literal.put_all(body)
|
|
25
|
+
await client.boolean_literal.put_default(models.BooleanLiteralProperty())
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.asyncio
|
|
29
|
+
async def test_bytes(client):
|
|
30
|
+
body = models.BytesProperty(property="aGVsbG8sIHdvcmxkIQ==")
|
|
31
|
+
assert await client.bytes.get_all() == body
|
|
32
|
+
assert await client.bytes.get_default() == models.BytesProperty()
|
|
33
|
+
await client.bytes.put_all(body)
|
|
34
|
+
await client.bytes.put_default(models.BytesProperty())
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.mark.asyncio
|
|
38
|
+
async def test_collections_byte(client):
|
|
39
|
+
body = models.CollectionsByteProperty(property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="])
|
|
40
|
+
assert await client.collections_byte.get_all() == body
|
|
41
|
+
assert await client.collections_byte.get_default() == models.CollectionsByteProperty()
|
|
42
|
+
await client.collections_byte.put_all(body)
|
|
43
|
+
await client.collections_byte.put_default(models.CollectionsByteProperty())
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_collections_model(client):
|
|
48
|
+
body = models.CollectionsModelProperty(
|
|
49
|
+
property=[
|
|
50
|
+
models.StringProperty(property="hello"),
|
|
51
|
+
models.StringProperty(property="world"),
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
assert await client.collections_model.get_all() == body
|
|
55
|
+
assert await client.collections_model.get_default() == models.CollectionsModelProperty()
|
|
56
|
+
await client.collections_model.put_all(body)
|
|
57
|
+
await client.collections_model.put_default(models.CollectionsModelProperty())
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@pytest.mark.asyncio
|
|
61
|
+
async def test_datetime(client):
|
|
62
|
+
body = models.DatetimeProperty(property="2022-08-26T18:38:00Z")
|
|
63
|
+
assert await client.datetime.get_all() == body
|
|
64
|
+
assert await client.datetime.get_default() == models.DatetimeProperty()
|
|
65
|
+
await client.datetime.put_all(body)
|
|
66
|
+
await client.datetime.put_default(models.DatetimeProperty())
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.asyncio
|
|
70
|
+
async def test_duration(client):
|
|
71
|
+
body = models.DurationProperty(property="P123DT22H14M12.011S")
|
|
72
|
+
assert await client.duration.get_all() == body
|
|
73
|
+
assert await client.duration.get_default() == models.DurationProperty()
|
|
74
|
+
await client.duration.put_all(body)
|
|
75
|
+
await client.duration.put_default(models.DurationProperty())
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@pytest.mark.asyncio
|
|
79
|
+
async def test_float_literal(client):
|
|
80
|
+
body = models.FloatLiteralProperty(property=1.25)
|
|
81
|
+
assert await client.float_literal.get_all() == body
|
|
82
|
+
assert await client.float_literal.get_default() == models.FloatLiteralProperty()
|
|
83
|
+
await client.float_literal.put_all(body)
|
|
84
|
+
await client.float_literal.put_default(models.FloatLiteralProperty())
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.asyncio
|
|
88
|
+
async def test_int_literal(client):
|
|
89
|
+
body = models.IntLiteralProperty(property=1)
|
|
90
|
+
assert await client.int_literal.get_all() == body
|
|
91
|
+
assert await client.int_literal.get_default() == models.IntLiteralProperty()
|
|
92
|
+
await client.int_literal.put_all(body)
|
|
93
|
+
await client.int_literal.put_default(models.IntLiteralProperty())
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@pytest.mark.asyncio
|
|
97
|
+
async def test_plaindate(client):
|
|
98
|
+
body = models.PlainDateProperty(property="2022-12-12")
|
|
99
|
+
assert await client.plain_date.get_all() == body
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@pytest.mark.asyncio
|
|
103
|
+
async def test_plaindate(client):
|
|
104
|
+
assert await client.plain_date.get_default() == models.PlainDateProperty()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@pytest.mark.asyncio
|
|
108
|
+
async def test_plaindate(client):
|
|
109
|
+
body = models.PlainDateProperty(property="2022-12-12")
|
|
110
|
+
await client.plain_date.put_all(body)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@pytest.mark.asyncio
|
|
114
|
+
async def test_plaindate(client):
|
|
115
|
+
await client.plain_date.put_default(models.PlainDateProperty())
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@pytest.mark.asyncio
|
|
119
|
+
async def test_plaintime(client):
|
|
120
|
+
body = models.PlainTimeProperty(property="13:06:12")
|
|
121
|
+
assert await client.plain_time.get_all() == body
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@pytest.mark.asyncio
|
|
125
|
+
async def test_plaintime(client):
|
|
126
|
+
assert await client.plain_time.get_default() == models.PlainTimeProperty()
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@pytest.mark.asyncio
|
|
130
|
+
async def test_plaintime(client):
|
|
131
|
+
body = models.PlainTimeProperty(property="13:06:12")
|
|
132
|
+
await client.plain_time.put_all(body)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@pytest.mark.asyncio
|
|
136
|
+
async def test_plaintime(client):
|
|
137
|
+
await client.plain_time.put_default(models.PlainTimeProperty())
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@pytest.mark.asyncio
|
|
141
|
+
async def test_required_and_optional(client):
|
|
142
|
+
all_body = {
|
|
143
|
+
"optionalProperty": "hello",
|
|
144
|
+
"requiredProperty": 42,
|
|
145
|
+
}
|
|
146
|
+
required_only_body = {
|
|
147
|
+
"requiredProperty": 42,
|
|
148
|
+
}
|
|
149
|
+
assert await client.required_and_optional.get_all() == all_body
|
|
150
|
+
assert await client.required_and_optional.get_required_only() == required_only_body
|
|
151
|
+
await client.required_and_optional.put_all(all_body)
|
|
152
|
+
await client.required_and_optional.put_required_only(required_only_body)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@pytest.mark.asyncio
|
|
156
|
+
async def test_string(client):
|
|
157
|
+
body = models.StringProperty(property="hello")
|
|
158
|
+
assert await client.string.get_all() == body
|
|
159
|
+
assert await client.string.get_default() == models.StringProperty()
|
|
160
|
+
await client.string.put_all(body)
|
|
161
|
+
await client.string.put_default(models.StringProperty())
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@pytest.mark.asyncio
|
|
165
|
+
async def test_string_literal(client):
|
|
166
|
+
body = models.StringLiteralProperty(property="hello")
|
|
167
|
+
assert await client.string_literal.get_all() == body
|
|
168
|
+
assert await client.string_literal.get_default() == models.StringLiteralProperty()
|
|
169
|
+
await client.string_literal.put_all(body)
|
|
170
|
+
await client.string_literal.put_default(models.StringLiteralProperty())
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@pytest.mark.asyncio
|
|
174
|
+
async def test_union_float_literal(client):
|
|
175
|
+
body = models.UnionFloatLiteralProperty(property=2.375)
|
|
176
|
+
assert await client.union_float_literal.get_all() == body
|
|
177
|
+
assert await client.union_float_literal.get_default() == models.UnionFloatLiteralProperty()
|
|
178
|
+
await client.union_float_literal.put_all(body)
|
|
179
|
+
await client.union_float_literal.put_default(models.UnionFloatLiteralProperty())
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@pytest.mark.asyncio
|
|
183
|
+
async def test_union_int_literal(client):
|
|
184
|
+
body = models.UnionIntLiteralProperty(property=2)
|
|
185
|
+
assert await client.union_int_literal.get_all() == body
|
|
186
|
+
assert await client.union_int_literal.get_default() == models.UnionIntLiteralProperty()
|
|
187
|
+
await client.union_int_literal.put_all(body)
|
|
188
|
+
await client.union_int_literal.put_default(models.UnionIntLiteralProperty())
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@pytest.mark.asyncio
|
|
192
|
+
async def test_union_string_literal(client):
|
|
193
|
+
body = models.UnionStringLiteralProperty(property="world")
|
|
194
|
+
assert await client.union_string_literal.get_all() == body
|
|
195
|
+
assert await client.union_string_literal.get_default() == models.UnionStringLiteralProperty()
|
|
196
|
+
await client.union_string_literal.put_all(body)
|
|
197
|
+
await client.union_string_literal.put_default(models.UnionStringLiteralProperty())
|