From 78d28eb180dbb47cecd5672b2a809fa4320d9aa3 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 15 Jun 2020 14:39:34 -0400 Subject: [PATCH 1/3] add test to check which models file models are imported from, py3.5 should fail --- .../test_azure_custom_base_uri.py | 10 + test/azure/AcceptanceTests/test_azure_url.py | 10 + test/azure/AcceptanceTests/test_duration.py | 10 + test/azure/AcceptanceTests/test_lro.py | 9 + test/azure/AcceptanceTests/test_paging.py | 254 +++++++++--------- test/azure/AcceptanceTests/test_parameter.py | 10 + test/azure/AcceptanceTests/test_xms.py | 10 + .../test_additional_properties.py | 10 + test/vanilla/AcceptanceTests/test_array.py | 10 + test/vanilla/AcceptanceTests/test_bool.py | 10 + test/vanilla/AcceptanceTests/test_byte.py | 10 + test/vanilla/AcceptanceTests/test_complex.py | 10 + .../AcceptanceTests/test_custom_base_uri.py | 10 + test/vanilla/AcceptanceTests/test_date.py | 10 + test/vanilla/AcceptanceTests/test_datetime.py | 10 + .../AcceptanceTests/test_datetime_rfc.py | 10 + .../AcceptanceTests/test_dictionary.py | 10 + test/vanilla/AcceptanceTests/test_duration.py | 10 + .../AcceptanceTests/test_extensible_enums.py | 10 + test/vanilla/AcceptanceTests/test_file.py | 10 + test/vanilla/AcceptanceTests/test_header.py | 10 + test/vanilla/AcceptanceTests/test_http.py | 10 + test/vanilla/AcceptanceTests/test_integer.py | 10 + .../AcceptanceTests/test_media_types.py | 11 + .../AcceptanceTests/test_model_flattening.py | 10 + .../test_multiple_inheritance.py | 11 + test/vanilla/AcceptanceTests/test_number.py | 11 + .../AcceptanceTests/test_required_optional.py | 10 + .../AcceptanceTests/test_string_tests.py | 10 + test/vanilla/AcceptanceTests/test_time.py | 11 + test/vanilla/AcceptanceTests/test_url.py | 10 + .../AcceptanceTests/test_validation.py | 10 + test/vanilla/AcceptanceTests/test_xml.py | 10 + .../vanilla/AcceptanceTests/test_xms_error.py | 12 +- 34 files changed, 466 insertions(+), 123 deletions(-) diff --git a/test/azure/AcceptanceTests/test_azure_custom_base_uri.py b/test/azure/AcceptanceTests/test_azure_custom_base_uri.py index 6d3147e78bc..20e85ca6702 100644 --- a/test/azure/AcceptanceTests/test_azure_custom_base_uri.py +++ b/test/azure/AcceptanceTests/test_azure_custom_base_uri.py @@ -70,3 +70,13 @@ def test_custom_base_uri_bad_host(self, client): client._config.host = "badhost:3000" with pytest.raises(ServiceRequestError): client.paths.get_empty("local") + + def test_models(self): + from custombaseurl.models import Error + + if sys.version_info >= (3,5): + from custombaseurl.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from custombaseurl.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/azure/AcceptanceTests/test_azure_url.py b/test/azure/AcceptanceTests/test_azure_url.py index 4094f7539e7..045c2b24a00 100644 --- a/test/azure/AcceptanceTests/test_azure_url.py +++ b/test/azure/AcceptanceTests/test_azure_url.py @@ -51,3 +51,13 @@ def test_azure_url(self, credential, authentication_policy): group = client.group.get_sample_resource_group("testgoup101") assert group.name == "testgroup101" assert group.location == "West US" + + def test_models(self): + from subscriptionidapiversion.models import Error + + if sys.version_info >= (3,5): + from subscriptionidapiversion.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from subscriptionidapiversion.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/azure/AcceptanceTests/test_duration.py b/test/azure/AcceptanceTests/test_duration.py index ecdfb16bc89..49935ccbb4f 100644 --- a/test/azure/AcceptanceTests/test_duration.py +++ b/test/azure/AcceptanceTests/test_duration.py @@ -58,3 +58,13 @@ def test_positive_duration(self, client): client.duration.get_positive_duration() delta = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) client.duration.put_positive_duration(delta) + + def test_models(self): + from bodyduration.models import Error + + if sys.version_info >= (3,5): + from bodyduration.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyduration.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/azure/AcceptanceTests/test_lro.py b/test/azure/AcceptanceTests/test_lro.py index d6c84beadd9..8d53d438fe7 100644 --- a/test/azure/AcceptanceTests/test_lro.py +++ b/test/azure/AcceptanceTests/test_lro.py @@ -469,3 +469,12 @@ def test_lro_list(self, client, product): assert product.id == "100" assert product.name == "foo" + def test_models(self): + from lro.models import OperationResult + + if sys.version_info >= (3,5): + from lro.models._models_py3 import OperationResult as OperationResultPy3 + assert OperationResult == OperationResultPy3 + else: + from lro.models._models import OperationResult as OperationResultPy2 + assert OperationResult == OperationResultPy2 diff --git a/test/azure/AcceptanceTests/test_paging.py b/test/azure/AcceptanceTests/test_paging.py index 05f4709ba09..d87fd3fefa2 100644 --- a/test/azure/AcceptanceTests/test_paging.py +++ b/test/azure/AcceptanceTests/test_paging.py @@ -53,125 +53,135 @@ def custom_url_client(credential, authentication_policy): with AutoRestParameterizedHostTestPagingClient(credential, host="host:3000", authentication_policy=authentication_policy) as client: yield client - -def test_get_no_item_name_pages(client): - pages = client.paging.get_no_item_name_pages() - items = [i for i in pages] - assert len(items) == 1 - assert items[0].properties.id == 1 - assert items[0].properties.name == "Product" - -def test_get_null_next_link_name_pages(client): - pages = client.paging.get_null_next_link_name_pages() - items = [i for i in pages] - assert len(items) == 1 - assert items[0].properties.id == 1 - assert items[0].properties.name == "Product" - -def test_get_single_pages_with_cb(client): - def cb(list_of_obj): - for obj in list_of_obj: - obj.marked = True - return list_of_obj - pages = client.paging.get_single_pages(cls=cb) - assert all(obj.marked for obj in pages) - -def test_get_single_pages(client): - pages = client.paging.get_single_pages() - items = [i for i in pages] - assert len(items) == 1 - assert items[0].properties.id == 1 - assert items[0].properties.name == "Product" - -def test_get_multiple_pages(client): - pages = client.paging.get_multiple_pages() - items = [i for i in pages] - assert len(items) == 10 - -def test_query_params(client): - pages = client.paging.get_with_query_params(required_query_parameter='100') - items = [i for i in pages] - assert len(items) == 2 - -def test_get_odata_multiple_pages(client): - pages = client.paging.get_odata_multiple_pages() - items = [i for i in pages] - assert len(items) == 10 - -def test_get_multiple_pages_retry_first(client): - pages = client.paging.get_multiple_pages_retry_first() - items = [i for i in pages] - assert len(items) == 10 - -def test_get_multiple_pages_retry_second(client): - pages = client.paging.get_multiple_pages_retry_second() - items = [i for i in pages] - assert len(items) == 10 - -def test_get_multiple_pages_with_offset(client): - from paging.models import PagingGetMultiplePagesWithOffsetOptions - options = PagingGetMultiplePagesWithOffsetOptions(offset=100) - pages = client.paging.get_multiple_pages_with_offset(paging_get_multiple_pages_with_offset_options=options) - items = [i for i in pages] - assert len(items) == 10 - assert items[-1].properties.id == 110 - - -def test_get_single_pages_failure(client): - pages = client.paging.get_single_pages_failure() - with pytest.raises(HttpResponseError): - list(pages) - -def test_get_multiple_pages_failure(client): - pages = client.paging.get_multiple_pages_failure() - with pytest.raises(HttpResponseError): - list(pages) - -def test_get_multiple_pages_failure_uri(client): - pages = client.paging.get_multiple_pages_failure_uri() - with pytest.raises(HttpResponseError): - list(pages) - -def test_paging_fragment_path(client): - - pages = client.paging.get_multiple_pages_fragment_next_link("1.6", "test_user") - items = [i for i in pages] - assert len(items) == 10 - - with pytest.raises(AttributeError): - # Be sure this method is not generated (Transform work) - client.paging.get_multiple_pages_fragment_next_link_next() # pylint: disable=E1101 - -def test_custom_url_get_pages_partial_url(custom_url_client): - paged = list(custom_url_client.paging.get_pages_partial_url("local")) - - assert len(paged) == 2 - assert paged[0].properties.id == 1 - assert paged[1].properties.id == 2 - -def test_custom_url_get_pages_partial_url_operation(custom_url_client): - paged = list(custom_url_client.paging.get_pages_partial_url_operation("local")) - - assert len(paged) == 2 - assert paged[0].properties.id == 1 - assert paged[1].properties.id == 2 - -def test_get_multiple_pages_lro(client): - """LRO + Paging at the same time. - - Python decides to poll, but not follow paging. Check that at least you get read the first page. - """ - from azure.mgmt.core.polling.arm_polling import ARMPolling - polling = ARMPolling(0, lro_options={'final-state-via': 'location'}) - # FIXME Location should be the default once 1.0.0b2 is out - - poller = client.paging.begin_get_multiple_pages_lro(polling=polling) - page1 = poller.result() - assert len(page1.values) == 1 - assert page1.values[0].properties.id == 1 - assert page1.next_link.endswith("paging/multiple/page/2") - -def test_item_name_with_xms_client_name(client): - pages = client.paging.get_paging_model_with_item_name_with_xms_client_name() - items = [i for i in pages] - assert len(items) == 1 +class TestPaging: + + def test_get_no_item_name_pages(self, client): + pages = client.paging.get_no_item_name_pages() + items = [i for i in pages] + assert len(items) == 1 + assert items[0].properties.id == 1 + assert items[0].properties.name == "Product" + + def test_get_null_next_link_name_pages(self, client): + pages = client.paging.get_null_next_link_name_pages() + items = [i for i in pages] + assert len(items) == 1 + assert items[0].properties.id == 1 + assert items[0].properties.name == "Product" + + def test_get_single_pages_with_cb(self, client): + def cb(list_of_obj): + for obj in list_of_obj: + obj.marked = True + return list_of_obj + pages = client.paging.get_single_pages(cls=cb) + assert all(obj.marked for obj in pages) + + def test_get_single_pages(self, client): + pages = client.paging.get_single_pages() + items = [i for i in pages] + assert len(items) == 1 + assert items[0].properties.id == 1 + assert items[0].properties.name == "Product" + + def test_get_multiple_pages(self, client): + pages = client.paging.get_multiple_pages() + items = [i for i in pages] + assert len(items) == 10 + + def test_query_params(self, client): + pages = client.paging.get_with_query_params(required_query_parameter='100') + items = [i for i in pages] + assert len(items) == 2 + + def test_get_odata_multiple_pages(self, client): + pages = client.paging.get_odata_multiple_pages() + items = [i for i in pages] + assert len(items) == 10 + + def test_get_multiple_pages_retry_first(self, client): + pages = client.paging.get_multiple_pages_retry_first() + items = [i for i in pages] + assert len(items) == 10 + + def test_get_multiple_pages_retry_second(self, client): + pages = client.paging.get_multiple_pages_retry_second() + items = [i for i in pages] + assert len(items) == 10 + + def test_get_multiple_pages_with_offset(self, client): + from paging.models import PagingGetMultiplePagesWithOffsetOptions + options = PagingGetMultiplePagesWithOffsetOptions(offset=100) + pages = client.paging.get_multiple_pages_with_offset(paging_get_multiple_pages_with_offset_options=options) + items = [i for i in pages] + assert len(items) == 10 + assert items[-1].properties.id == 110 + + + def test_get_single_pages_failure(self, client): + pages = client.paging.get_single_pages_failure() + with pytest.raises(HttpResponseError): + list(pages) + + def test_get_multiple_pages_failure(self, client): + pages = client.paging.get_multiple_pages_failure() + with pytest.raises(HttpResponseError): + list(pages) + + def test_get_multiple_pages_failure_uri(self, client): + pages = client.paging.get_multiple_pages_failure_uri() + with pytest.raises(HttpResponseError): + list(pages) + + def test_paging_fragment_path(self, client): + + pages = client.paging.get_multiple_pages_fragment_next_link("1.6", "test_user") + items = [i for i in pages] + assert len(items) == 10 + + with pytest.raises(AttributeError): + # Be sure this method is not generated (Transform work) + client.paging.get_multiple_pages_fragment_next_link_next() # pylint: disable=E1101 + + def test_custom_url_get_pages_partial_url(self, custom_url_client): + paged = list(custom_url_client.paging.get_pages_partial_url("local")) + + assert len(paged) == 2 + assert paged[0].properties.id == 1 + assert paged[1].properties.id == 2 + + def test_custom_url_get_pages_partial_url_operation(self, custom_url_client): + paged = list(custom_url_client.paging.get_pages_partial_url_operation("local")) + + assert len(paged) == 2 + assert paged[0].properties.id == 1 + assert paged[1].properties.id == 2 + + def test_get_multiple_pages_lro(self, client): + """LRO + Paging at the same time. + + Python decides to poll, but not follow paging. Check that at least you get read the first page. + """ + from azure.mgmt.core.polling.arm_polling import ARMPolling + polling = ARMPolling(0, lro_options={'final-state-via': 'location'}) + # FIXME Location should be the default once 1.0.0b2 is out + + poller = client.paging.begin_get_multiple_pages_lro(polling=polling) + page1 = poller.result() + assert len(page1.values) == 1 + assert page1.values[0].properties.id == 1 + assert page1.next_link.endswith("paging/multiple/page/2") + + def test_item_name_with_xms_client_name(self, client): + pages = client.paging.get_paging_model_with_item_name_with_xms_client_name() + items = [i for i in pages] + assert len(items) == 1 + + def test_models(self): + from paging.models import OperationResult + if sys.version_info >= (3,5): + from paging.models._models_py3 import OperationResult as OperationResultPy3 + assert OperationResult == OperationResultPy3 + else: + from paging.models._models import OperationResult as OperationResultPy2 + assert OperationResult == OperationResultPy2 diff --git a/test/azure/AcceptanceTests/test_parameter.py b/test/azure/AcceptanceTests/test_parameter.py index 1bf3e84188b..f305c174c90 100644 --- a/test/azure/AcceptanceTests/test_parameter.py +++ b/test/azure/AcceptanceTests/test_parameter.py @@ -178,3 +178,13 @@ def test_skip_url_encoding(self, azure_client, unencoded_path, unencoded_query): def test_azure_odata(self, azure_client): azure_client.odata.get_with_filter(filter="id gt 5 and name eq 'foo'", top=10, orderby="id") + def test_models(self): + from azureparametergrouping.models import Error + + if sys.version_info >= (3,5): + from azureparametergrouping.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from azureparametergrouping.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 + diff --git a/test/azure/AcceptanceTests/test_xms.py b/test/azure/AcceptanceTests/test_xms.py index 154699840f4..8c85031a059 100644 --- a/test/azure/AcceptanceTests/test_xms.py +++ b/test/azure/AcceptanceTests/test_xms.py @@ -91,3 +91,13 @@ def test_xms_custom_named_request_id_parameter_group(self, client): foo_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0" ) client.header.custom_named_request_id_param_grouping(header_custom_named_request_id_param_grouping_parameters=param_group) + + def test_models(self): + from azurespecialproperties.models import Error + + if sys.version_info >= (3,5): + from azurespecialproperties.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from azurespecialproperties.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_additional_properties.py b/test/vanilla/AcceptanceTests/test_additional_properties.py index f2befdb6778..900063c3e84 100644 --- a/test/vanilla/AcceptanceTests/test_additional_properties.py +++ b/test/vanilla/AcceptanceTests/test_additional_properties.py @@ -147,3 +147,13 @@ def test_create_ap_in_properties_with_ap_string(self, client): output_ap_str_add = client.pets.create_ap_in_properties_with_ap_string(input_ap_str_add) assert output_ap_str_add.additional_properties['color'] == 'red' assert output_ap_str_add.additional_properties1['weight'] == 599 + + def test_models(self): + from additionalproperties.models import Error + + if sys.version_info >= (3,5): + from additionalproperties.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from additionalproperties.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_array.py b/test/vanilla/AcceptanceTests/test_array.py index c35e564d522..d08565dbeb7 100644 --- a/test/vanilla/AcceptanceTests/test_array.py +++ b/test/vanilla/AcceptanceTests/test_array.py @@ -280,3 +280,13 @@ def test_array_enum_valid(self, client): def test_array_string_enum_valid(self, client): array = client.array.get_string_enum_valid() client.array.put_string_enum_valid(array) + + def test_models(self): + from bodyarray.models import Error + + if sys.version_info >= (3,5): + from bodyarray.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyarray.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_bool.py b/test/vanilla/AcceptanceTests/test_bool.py index 5a1d24f1c4c..87a0d91d482 100644 --- a/test/vanilla/AcceptanceTests/test_bool.py +++ b/test/vanilla/AcceptanceTests/test_bool.py @@ -65,3 +65,13 @@ def test_model_put_true(self, client): def test_model_get_invalid(self, client): with pytest.raises(DecodeError): client.bool.get_invalid() + + def test_models(self): + from bodyboolean.models import Error + + if sys.version_info >= (3,5): + from bodyboolean.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyboolean.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_byte.py b/test/vanilla/AcceptanceTests/test_byte.py index c965c15d766..869ba41c44d 100644 --- a/test/vanilla/AcceptanceTests/test_byte.py +++ b/test/vanilla/AcceptanceTests/test_byte.py @@ -61,3 +61,13 @@ def test_get_empty(self, client): def test_get_invalid(self, client): with pytest.raises(DeserializationError): client.byte.get_invalid() + + def test_models(self): + from bodybyte.models import Error + + if sys.version_info >= (3,5): + from bodybyte.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodybyte.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_complex.py b/test/vanilla/AcceptanceTests/test_complex.py index a37007bf0a6..acd27fdd067 100644 --- a/test/vanilla/AcceptanceTests/test_complex.py +++ b/test/vanilla/AcceptanceTests/test_complex.py @@ -460,3 +460,13 @@ def test_polymorphism_get_and_put_missing_discriminator(self, client): dot_salmon = client.polymorphism.get_dot_syntax() assert dot_salmon.fish_type == "DotSalmon" assert dot_salmon.location == "sweden" + + def test_models(self): + from bodycomplex.models import Error + + if sys.version_info >= (3,5): + from bodycomplex.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodycomplex.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_custom_base_uri.py b/test/vanilla/AcceptanceTests/test_custom_base_uri.py index 0a060da1748..c6dfafc719c 100644 --- a/test/vanilla/AcceptanceTests/test_custom_base_uri.py +++ b/test/vanilla/AcceptanceTests/test_custom_base_uri.py @@ -72,3 +72,13 @@ def test_get_empty_from_bad_host(self): def test_more_options(self): with AutoRestParameterizedCustomHostTestClient("test12", "host:3000") as client: client.paths.get_empty("http://lo", "cal", "key1") + + def test_models(self): + from custombaseurl.models import Error + + if sys.version_info >= (3,5): + from custombaseurl.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from custombaseurl.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_date.py b/test/vanilla/AcceptanceTests/test_date.py index 8c0b8c61763..d6c52184b09 100644 --- a/test/vanilla/AcceptanceTests/test_date.py +++ b/test/vanilla/AcceptanceTests/test_date.py @@ -71,3 +71,13 @@ def test_model_get_overflow_date(self, client): def test_model_get_underflow_date(self, client): with pytest.raises(DeserializationError): client.date.get_underflow_date() + + def test_models(self): + from bodydate.models import Error + + if sys.version_info >= (3,5): + from bodydate.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodydate.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_datetime.py b/test/vanilla/AcceptanceTests/test_datetime.py index cc86bb068ee..e876776dd1e 100644 --- a/test/vanilla/AcceptanceTests/test_datetime.py +++ b/test/vanilla/AcceptanceTests/test_datetime.py @@ -120,3 +120,13 @@ def test_put_local_negative_offset_max_date_time(self, client): with pytest.raises(SerializationError): client.datetime.put_local_negative_offset_max_date_time( isodate.parse_datetime("9999-12-31T23:59:59.999999-14:00")) + + def test_models(self): + from bodydatetime.models import Error + + if sys.version_info >= (3,5): + from bodydatetime.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodydatetime.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_datetime_rfc.py b/test/vanilla/AcceptanceTests/test_datetime_rfc.py index 8cddf68cbac..1dbcb729ca5 100644 --- a/test/vanilla/AcceptanceTests/test_datetime_rfc.py +++ b/test/vanilla/AcceptanceTests/test_datetime_rfc.py @@ -73,3 +73,13 @@ def test_utc_min_date_time(self, client): min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") client.datetimerfc1123.get_utc_min_date_time() client.datetimerfc1123.put_utc_min_date_time(min_date) + + def test_models(self): + from bodydatetimerfc1123.models import Error + + if sys.version_info >= (3,5): + from bodydatetimerfc1123.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodydatetimerfc1123.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_dictionary.py b/test/vanilla/AcceptanceTests/test_dictionary.py index cbd338abd47..e93674d0d9d 100644 --- a/test/vanilla/AcceptanceTests/test_dictionary.py +++ b/test/vanilla/AcceptanceTests/test_dictionary.py @@ -304,3 +304,13 @@ def test_get_dictionary_item_null_and_empty(self, client): "2":{"7":"seven","8":"eight","9":"nine"}} dict_result = client.dictionary.get_dictionary_item_empty() assert dict_dict == dict_result + + def test_models(self): + from bodydictionary.models import Error + + if sys.version_info >= (3,5): + from bodydictionary.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodydictionary.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_duration.py b/test/vanilla/AcceptanceTests/test_duration.py index 298efce6794..dd10631aa3b 100644 --- a/test/vanilla/AcceptanceTests/test_duration.py +++ b/test/vanilla/AcceptanceTests/test_duration.py @@ -56,3 +56,13 @@ def test_get_null_and_invalid(self, client): def test_positive_duration(self, client): client.duration.get_positive_duration() client.duration.put_positive_duration(timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11)) + + def test_models(self): + from bodyduration.models import Error + + if sys.version_info >= (3,5): + from bodyduration.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyduration.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_extensible_enums.py b/test/vanilla/AcceptanceTests/test_extensible_enums.py index 94e59c8215d..7753ff6d461 100644 --- a/test/vanilla/AcceptanceTests/test_extensible_enums.py +++ b/test/vanilla/AcceptanceTests/test_extensible_enums.py @@ -72,3 +72,13 @@ def test_add_pet(self, client): assert returned_pet.days_of_week == "Friday" assert returned_pet.int_enum == "3" assert returned_pet.name == "Retriever" + + def test_models(self): + from extensibleenumsswagger.models import Pet + + if sys.version_info >= (3,5): + from extensibleenumsswagger.models._models_py3 import Pet as PetPy3 + assert Pet == PetPy3 + else: + from extensibleenumsswagger.models._models import Pet as PetPy2 + assert Pet == PetPy2 diff --git a/test/vanilla/AcceptanceTests/test_file.py b/test/vanilla/AcceptanceTests/test_file.py index cb44ffd220e..44592572c18 100644 --- a/test/vanilla/AcceptanceTests/test_file.py +++ b/test/vanilla/AcceptanceTests/test_file.py @@ -137,3 +137,13 @@ def test_get_empty_file_with_callback(self, client, callback): file_handle.write(data) assert file_length == 0 + + def test_models(self): + from bodyfile.models import Error + + if sys.version_info >= (3,5): + from bodyfile.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyfile.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_header.py b/test/vanilla/AcceptanceTests/test_header.py index a4109bb3ec6..6d618fef714 100644 --- a/test/vanilla/AcceptanceTests/test_header.py +++ b/test/vanilla/AcceptanceTests/test_header.py @@ -195,3 +195,13 @@ def status_code(pipeline_response, _, headers): custom_headers = {"x-ms-client-request-id": "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} response = client.header.custom_request_id(headers=custom_headers, cls=status_code) assert response == 200 + + def test_models(self): + from header.models import Error + + if sys.version_info >= (3,5): + from header.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from header.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_http.py b/test/vanilla/AcceptanceTests/test_http.py index 7c91f5c5dd5..a701712f433 100644 --- a/test/vanilla/AcceptanceTests/test_http.py +++ b/test/vanilla/AcceptanceTests/test_http.py @@ -417,3 +417,13 @@ def test_success_status_codes_404(self, client): def test_empty_no_content(self, client): self.assert_raises_with_status(requests.codes.bad_request, client.http_failure.get_no_model_empty) + + def test_models(self): + from httpinfrastructure.models import Error + + if sys.version_info >= (3,5): + from httpinfrastructure.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from httpinfrastructure.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_integer.py b/test/vanilla/AcceptanceTests/test_integer.py index d2b344cecb2..9f2ba5a1c77 100644 --- a/test/vanilla/AcceptanceTests/test_integer.py +++ b/test/vanilla/AcceptanceTests/test_integer.py @@ -80,3 +80,13 @@ def test_get_null_and_invalid_unix_time(self, client): with pytest.raises(DecodeError): client.int.get_invalid_unix_time() + + def test_models(self): + from bodyinteger.models import Error + + if sys.version_info >= (3,5): + from bodyinteger.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyinteger.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_media_types.py b/test/vanilla/AcceptanceTests/test_media_types.py index c4dfef2093f..67a309f60f3 100644 --- a/test/vanilla/AcceptanceTests/test_media_types.py +++ b/test/vanilla/AcceptanceTests/test_media_types.py @@ -28,6 +28,7 @@ import pytest import json +import sys @pytest.fixture def client(): @@ -53,3 +54,13 @@ def test_incorrect_content_type(self, client): def test_content_type_with_encoding(self, client): result = client.content_type_with_encoding(input="hello", content_type='text/plain; encoding=UTF-8') assert result == "Nice job sending content type with encoding" + + def test_models(self): + from mediatypes.models import SourcePath + + if sys.version_info >= (3,5): + from mediatypes.models._models_py3 import SourcePath as SourcePathPy3 + assert SourcePath == SourcePathPy3 + else: + from mediatypes.models._models import SourcePath as SourcePathPy2 + assert SourcePath == SourcePathPy2 diff --git a/test/vanilla/AcceptanceTests/test_model_flattening.py b/test/vanilla/AcceptanceTests/test_model_flattening.py index 431a8307b29..0fd477f5c1e 100644 --- a/test/vanilla/AcceptanceTests/test_model_flattening.py +++ b/test/vanilla/AcceptanceTests/test_model_flattening.py @@ -258,3 +258,13 @@ def test_model_flattening_with_grouping(self, client): result = client.put_simple_product_with_grouping(group) result.additional_properties = {} # Not the purpose of this test. This enables the ==. assert result == simple_product + + def test_models(self): + from modelflattening.models import Error + + if sys.version_info >= (3,5): + from modelflattening.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from modelflattening.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_multiple_inheritance.py b/test/vanilla/AcceptanceTests/test_multiple_inheritance.py index 4cafb35f0b5..2b35296c1b6 100644 --- a/test/vanilla/AcceptanceTests/test_multiple_inheritance.py +++ b/test/vanilla/AcceptanceTests/test_multiple_inheritance.py @@ -29,6 +29,7 @@ from multipleinheritance import MultipleInheritanceServiceClient from multipleinheritance.models import * import pytest +import sys @pytest.fixture def client(): @@ -71,3 +72,13 @@ def test_get_kitten(self, client): def test_put_kitten(self, client): result = client.put_kitten(Kitten(name="Kitty", likes_milk=False, meows=True, hisses=False, eats_mice_yet=True)) assert result == "Kitten was correct!" + + def test_models(self): + from multipleinheritance.models import Error + + if sys.version_info >= (3,5): + from multipleinheritance.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from multipleinheritance.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_number.py b/test/vanilla/AcceptanceTests/test_number.py index 166dae9a2d3..96c738059fc 100644 --- a/test/vanilla/AcceptanceTests/test_number.py +++ b/test/vanilla/AcceptanceTests/test_number.py @@ -33,6 +33,7 @@ from decimal import Decimal from datetime import date, datetime, timedelta import os +import pytest from os.path import dirname, pardir, join, realpath from azure.core.exceptions import DecodeError @@ -102,3 +103,13 @@ def test_get_invalid_double(self, client): def test_get_invalid_float(self, client): with pytest.raises(DecodeError): client.number.get_invalid_float() + + def test_models(self): + from bodynumber.models import Error + + if sys.version_info >= (3,5): + from bodynumber.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodynumber.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_required_optional.py b/test/vanilla/AcceptanceTests/test_required_optional.py index be4663e52e4..2d71ee16f80 100644 --- a/test/vanilla/AcceptanceTests/test_required_optional.py +++ b/test/vanilla/AcceptanceTests/test_required_optional.py @@ -125,3 +125,13 @@ def test_post_required_class(self, client): with pytest.raises(ValidationError): client.explicit.post_required_class_property(None) + + def test_models(self): + from requiredoptional.models import Error + + if sys.version_info >= (3,5): + from requiredoptional.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from requiredoptional.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_string_tests.py b/test/vanilla/AcceptanceTests/test_string_tests.py index f492627b258..f87d9253102 100644 --- a/test/vanilla/AcceptanceTests/test_string_tests.py +++ b/test/vanilla/AcceptanceTests/test_string_tests.py @@ -135,3 +135,13 @@ def test_enum_referenced_constant(self, client): def test_patch_file(self): from bodystring.models import PatchAddedModel + + def test_models(self): + from bodystring.models import Error + + if sys.version_info >= (3,5): + from bodystring.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodystring.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_time.py b/test/vanilla/AcceptanceTests/test_time.py index f7a9c7c26a8..fa59f667908 100644 --- a/test/vanilla/AcceptanceTests/test_time.py +++ b/test/vanilla/AcceptanceTests/test_time.py @@ -29,6 +29,7 @@ from bodytime import AutoRestTimeTestService import pytest +import sys @pytest.fixture def client(): @@ -43,3 +44,13 @@ def test_get(self, client): def test_put(self, client): result = client.time.put(datetime.time(8, 7, 56)) assert result == "Nice job posting time" + + def test_models(self): + from bodytime.models import Error + + if sys.version_info >= (3,5): + from bodytime.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodytime.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_url.py b/test/vanilla/AcceptanceTests/test_url.py index 696bb00f0d7..14e38a74f86 100644 --- a/test/vanilla/AcceptanceTests/test_url.py +++ b/test/vanilla/AcceptanceTests/test_url.py @@ -235,3 +235,13 @@ def test_get_local_path_item_query_null(self, client): None, None, ) + + def test_models(self): + from url.models import Error + + if sys.version_info >= (3,5): + from url.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from url.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_validation.py b/test/vanilla/AcceptanceTests/test_validation.py index 78e10e70bf2..9756fed3a06 100644 --- a/test/vanilla/AcceptanceTests/test_validation.py +++ b/test/vanilla/AcceptanceTests/test_validation.py @@ -148,3 +148,13 @@ def test_api_version_validation(self, client): except ValidationError as err: assert err.rule == "pattern" assert err.target == "self.api_version" + + def test_models(self): + from validation.models import Error + + if sys.version_info >= (3,5): + from validation.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from validation.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_xml.py b/test/vanilla/AcceptanceTests/test_xml.py index 3f4a06e57a5..7d00911d3a6 100644 --- a/test/vanilla/AcceptanceTests/test_xml.py +++ b/test/vanilla/AcceptanceTests/test_xml.py @@ -173,3 +173,13 @@ def test_acls(self, client): assert len(acls) == 1 assert acls[0].id == 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=' _assert_with_log(client.xml.put_acls, acls) + + def test_models(self): + from xmlservice.models import Error + + if sys.version_info >= (3,5): + from xmlservice.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from xmlservice.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_xms_error.py b/test/vanilla/AcceptanceTests/test_xms_error.py index b234342e427..f53dede41e6 100644 --- a/test/vanilla/AcceptanceTests/test_xms_error.py +++ b/test/vanilla/AcceptanceTests/test_xms_error.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- import json import pytest +import sys from azure.core.exceptions import HttpResponseError, ResourceNotFoundError @@ -90,4 +91,13 @@ def test_do_something_error(self, client): with pytest.raises(ResourceNotFoundError) as excinfo: client.pet.do_something("fetch") - \ No newline at end of file + + def test_models(self): + from xmserrorresponse.models import Animal + + if sys.version_info >= (3,5): + from xmserrorresponse.models._models_py3 import Animal as AnimalPy3 + assert Animal == AnimalPy3 + else: + from xmserrorresponse.models._models import Animal as AnimalPy2 + assert Animal == AnimalPy2 From 5994c7e6ff09cc8accb5ea5e8b45cb0df197d072 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 15 Jun 2020 14:53:38 -0400 Subject: [PATCH 2/3] switch variable typing to comments for py 3.5 --- .../serializers/model_generic_serializer.py | 6 ++++- .../serializers/model_python3_serializer.py | 4 +--- .../BodyComplex/bodycomplex/models/_models.py | 22 +++++++++---------- .../bodycomplex/models/_models_py3.py | 22 +++++++++---------- .../xmserrorresponse/models/_models.py | 12 +++++----- .../xmserrorresponse/models/_models_py3.py | 12 +++++----- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/autorest/codegen/serializers/model_generic_serializer.py b/autorest/codegen/serializers/model_generic_serializer.py index 0ecbcf62ba6..ad1f4c6a050 100644 --- a/autorest/codegen/serializers/model_generic_serializer.py +++ b/autorest/codegen/serializers/model_generic_serializer.py @@ -30,7 +30,11 @@ def init_args(model: ObjectSchema) -> List[str]: init_args.append(f"self.{prop.name} = None") elif prop.is_discriminator: discriminator_value = f"'{model.discriminator_value}'" if model.discriminator_value else None - init_args.append(f"self.{prop.name} = {discriminator_value}") + if not discriminator_value: + typing = "Optional[str]" + else: + typing = "str" + init_args.append(f"self.{prop.name} = {discriminator_value} # type: {typing}") elif not prop.constant: if prop.required and not prop.schema.default_value: init_args.append(f"self.{prop.name} = kwargs['{prop.name}']") diff --git a/autorest/codegen/serializers/model_python3_serializer.py b/autorest/codegen/serializers/model_python3_serializer.py index d0bfef28243..ef75061b72b 100644 --- a/autorest/codegen/serializers/model_python3_serializer.py +++ b/autorest/codegen/serializers/model_python3_serializer.py @@ -59,13 +59,11 @@ def init_args(model: ObjectSchema) -> List[str]: init_args.append(f"self.{prop.name} = None") elif prop.is_discriminator: discriminator_value = f"'{model.discriminator_value}'" if model.discriminator_value else None - # adding the type ignore because mypy throws an incompatible type error because - # the children have a value for the discriminator, while the parent sets it to None if not discriminator_value: typing = "Optional[str]" else: typing = "str" - init_args.append(f"self.{prop.name}: {typing} = {discriminator_value}") + init_args.append(f"self.{prop.name} = {discriminator_value} # type: {typing}") elif not prop.constant: init_args.append(f"self.{prop.name} = {prop.name}") diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py index d942b8ca368..bd0412f3446 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py @@ -190,7 +190,7 @@ def __init__( **kwargs ): super(Fish, self).__init__(**kwargs) - self.fishtype = None + self.fishtype = None # type: Optional[str] self.species = kwargs.get('species', None) self.length = kwargs['length'] self.siblings = kwargs.get('siblings', None) @@ -242,7 +242,7 @@ def __init__( **kwargs ): super(Shark, self).__init__(**kwargs) - self.fishtype = 'shark' + self.fishtype = 'shark' # type: str self.age = kwargs.get('age', None) self.birthday = kwargs['birthday'] @@ -286,7 +286,7 @@ def __init__( **kwargs ): super(Cookiecuttershark, self).__init__(**kwargs) - self.fishtype = 'cookiecuttershark' + self.fishtype = 'cookiecuttershark' # type: str class Datetimerfc1123Wrapper(msrest.serialization.Model): @@ -434,7 +434,7 @@ def __init__( **kwargs ): super(DotFish, self).__init__(**kwargs) - self.fish_type = None + self.fish_type = None # type: Optional[str] self.species = kwargs.get('species', None) @@ -500,7 +500,7 @@ def __init__( **kwargs ): super(DotSalmon, self).__init__(**kwargs) - self.fish_type = 'DotSalmon' + self.fish_type = 'DotSalmon' # type: str self.location = kwargs.get('location', None) self.iswild = kwargs.get('iswild', None) @@ -642,7 +642,7 @@ def __init__( **kwargs ): super(Goblinshark, self).__init__(**kwargs) - self.fishtype = 'goblin' + self.fishtype = 'goblin' # type: str self.jawsize = kwargs.get('jawsize', None) self.color = kwargs.get('color', "gray") @@ -728,7 +728,7 @@ def __init__( **kwargs ): super(MyBaseType, self).__init__(**kwargs) - self.kind = None + self.kind = None # type: Optional[str] self.prop_b1 = kwargs.get('prop_b1', None) self.prop_bh1 = kwargs.get('prop_bh1', None) @@ -764,7 +764,7 @@ def __init__( **kwargs ): super(MyDerivedType, self).__init__(**kwargs) - self.kind = 'Kind1' + self.kind = 'Kind1' # type: str self.prop_d1 = kwargs.get('prop_d1', None) @@ -842,7 +842,7 @@ def __init__( **kwargs ): super(Salmon, self).__init__(**kwargs) - self.fishtype = 'salmon' + self.fishtype = 'salmon' # type: str self.location = kwargs.get('location', None) self.iswild = kwargs.get('iswild', None) @@ -889,7 +889,7 @@ def __init__( **kwargs ): super(Sawshark, self).__init__(**kwargs) - self.fishtype = 'sawshark' + self.fishtype = 'sawshark' # type: str self.picture = kwargs.get('picture', None) @@ -969,7 +969,7 @@ def __init__( **kwargs ): super(SmartSalmon, self).__init__(**kwargs) - self.fishtype = 'smart_salmon' + self.fishtype = 'smart_salmon' # type: str self.additional_properties = kwargs.get('additional_properties', None) self.college_degree = kwargs.get('college_degree', None) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py index 2be6da764dc..0ea1168c586 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py @@ -218,7 +218,7 @@ def __init__( **kwargs ): super(Fish, self).__init__(**kwargs) - self.fishtype: Optional[str] = None + self.fishtype = None # type: Optional[str] self.species = species self.length = length self.siblings = siblings @@ -276,7 +276,7 @@ def __init__( **kwargs ): super(Shark, self).__init__(species=species, length=length, siblings=siblings, **kwargs) - self.fishtype: str = 'shark' + self.fishtype = 'shark' # type: str self.age = age self.birthday = birthday @@ -326,7 +326,7 @@ def __init__( **kwargs ): super(Cookiecuttershark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) - self.fishtype: str = 'cookiecuttershark' + self.fishtype = 'cookiecuttershark' # type: str class Datetimerfc1123Wrapper(msrest.serialization.Model): @@ -491,7 +491,7 @@ def __init__( **kwargs ): super(DotFish, self).__init__(**kwargs) - self.fish_type: Optional[str] = None + self.fish_type = None # type: Optional[str] self.species = species @@ -566,7 +566,7 @@ def __init__( **kwargs ): super(DotSalmon, self).__init__(species=species, **kwargs) - self.fish_type: str = 'DotSalmon' + self.fish_type = 'DotSalmon' # type: str self.location = location self.iswild = iswild @@ -727,7 +727,7 @@ def __init__( **kwargs ): super(Goblinshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) - self.fishtype: str = 'goblin' + self.fishtype = 'goblin' # type: str self.jawsize = jawsize self.color = color @@ -822,7 +822,7 @@ def __init__( **kwargs ): super(MyBaseType, self).__init__(**kwargs) - self.kind: Optional[str] = None + self.kind = None # type: Optional[str] self.prop_b1 = prop_b1 self.prop_bh1 = prop_bh1 @@ -862,7 +862,7 @@ def __init__( **kwargs ): super(MyDerivedType, self).__init__(prop_b1=prop_b1, prop_bh1=prop_bh1, **kwargs) - self.kind: str = 'Kind1' + self.kind = 'Kind1' # type: str self.prop_d1 = prop_d1 @@ -948,7 +948,7 @@ def __init__( **kwargs ): super(Salmon, self).__init__(species=species, length=length, siblings=siblings, **kwargs) - self.fishtype: str = 'salmon' + self.fishtype = 'salmon' # type: str self.location = location self.iswild = iswild @@ -1002,7 +1002,7 @@ def __init__( **kwargs ): super(Sawshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) - self.fishtype: str = 'sawshark' + self.fishtype = 'sawshark' # type: str self.picture = picture @@ -1096,7 +1096,7 @@ def __init__( **kwargs ): super(SmartSalmon, self).__init__(species=species, length=length, siblings=siblings, location=location, iswild=iswild, **kwargs) - self.fishtype: str = 'smart_salmon' + self.fishtype = 'smart_salmon' # type: str self.additional_properties = additional_properties self.college_degree = college_degree diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py index a5f4a67143d..b51b824b500 100644 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py +++ b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py @@ -84,7 +84,7 @@ def __init__( ): super(NotFoundErrorBase, self).__init__(**kwargs) self.reason = kwargs.get('reason', None) - self.what_not_found = 'NotFoundErrorBase' + self.what_not_found = 'NotFoundErrorBase' # type: str class AnimalNotFound(NotFoundErrorBase): @@ -118,7 +118,7 @@ def __init__( **kwargs ): super(AnimalNotFound, self).__init__(**kwargs) - self.what_not_found = 'AnimalNotFound' + self.what_not_found = 'AnimalNotFound' # type: str self.name = kwargs.get('name', None) @@ -153,7 +153,7 @@ def __init__( **kwargs ): super(LinkNotFound, self).__init__(**kwargs) - self.what_not_found = 'InvalidResourceLink' + self.what_not_found = 'InvalidResourceLink' # type: str self.what_sub_address = kwargs.get('what_sub_address', None) @@ -236,7 +236,7 @@ def __init__( **kwargs ): super(PetActionError, self).__init__(**kwargs) - self.error_type = None + self.error_type = None # type: Optional[str] self.error_message = kwargs.get('error_message', None) @@ -275,7 +275,7 @@ def __init__( **kwargs ): super(PetSadError, self).__init__(**kwargs) - self.error_type = 'PetSadError' + self.error_type = 'PetSadError' # type: str self.reason = kwargs.get('reason', None) @@ -310,5 +310,5 @@ def __init__( **kwargs ): super(PetHungryOrThirstyError, self).__init__(**kwargs) - self.error_type = 'PetHungryOrThirstyError' + self.error_type = 'PetHungryOrThirstyError' # type: str self.hungry_or_thirsty = kwargs.get('hungry_or_thirsty', None) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py index 277ab9aecbc..83a01a62a93 100644 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py +++ b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py @@ -93,7 +93,7 @@ def __init__( ): super(NotFoundErrorBase, self).__init__(some_base_prop=some_base_prop, **kwargs) self.reason = reason - self.what_not_found: str = 'NotFoundErrorBase' + self.what_not_found = 'NotFoundErrorBase' # type: str class AnimalNotFound(NotFoundErrorBase): @@ -131,7 +131,7 @@ def __init__( **kwargs ): super(AnimalNotFound, self).__init__(some_base_prop=some_base_prop, reason=reason, **kwargs) - self.what_not_found: str = 'AnimalNotFound' + self.what_not_found = 'AnimalNotFound' # type: str self.name = name @@ -170,7 +170,7 @@ def __init__( **kwargs ): super(LinkNotFound, self).__init__(some_base_prop=some_base_prop, reason=reason, **kwargs) - self.what_not_found: str = 'InvalidResourceLink' + self.what_not_found = 'InvalidResourceLink' # type: str self.what_sub_address = what_sub_address @@ -259,7 +259,7 @@ def __init__( **kwargs ): super(PetActionError, self).__init__(**kwargs) - self.error_type: Optional[str] = None + self.error_type = None # type: Optional[str] self.error_message = error_message @@ -301,7 +301,7 @@ def __init__( **kwargs ): super(PetSadError, self).__init__(error_message=error_message, **kwargs) - self.error_type: str = 'PetSadError' + self.error_type = 'PetSadError' # type: str self.reason = reason @@ -340,5 +340,5 @@ def __init__( **kwargs ): super(PetHungryOrThirstyError, self).__init__(error_message=error_message, reason=reason, **kwargs) - self.error_type: str = 'PetHungryOrThirstyError' + self.error_type = 'PetHungryOrThirstyError' # type: str self.hungry_or_thirsty = hungry_or_thirsty From 338832b6ba95bcee26c45d4ac9e78c95cd1c8554 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 15 Jun 2020 17:09:23 -0400 Subject: [PATCH 3/3] update changelog --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 517f501d6c4..29e76fd8f8b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,10 @@ Modelerfour version: 4.13.351 `AzureKeyCredentialPolicy`. The value passed in will be the default authentication policy in the client's config, so users using the generated library will use that auth policy unless they pass in a separate one through kwargs #686 +**Bug Fixes** + +- Fix typing for discriminator values in models, so Python 3.5 can import py3 file for models #691 + ### 2020-06-08 - 5.1.0-preview.2 Modelerfour version: 4.13.351