@typespec/http-client-python 0.6.9 → 0.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/emitter/emitter.d.ts.map +1 -1
  2. package/dist/emitter/emitter.js +6 -2
  3. package/dist/emitter/emitter.js.map +1 -1
  4. package/emitter/src/emitter.ts +9 -5
  5. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  6. package/eng/scripts/ci/dev_requirements.txt +11 -0
  7. package/eng/scripts/ci/regenerate.ts +5 -1
  8. package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
  9. package/eng/scripts/setup/build_pygen_wheel.py +1 -1
  10. package/eng/scripts/setup/install.py +2 -2
  11. package/eng/scripts/setup/run_tsp.py +1 -1
  12. package/generator/build/lib/pygen/black.py +13 -2
  13. package/generator/build/lib/pygen/codegen/models/client.py +0 -8
  14. package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +18 -33
  15. package/generator/build/lib/pygen/codegen/serializers/model_serializer.py +1 -7
  16. package/generator/build/lib/pygen/codegen/templates/client.py.jinja2 +1 -1
  17. package/generator/build/lib/pygen/codegen/templates/macros.jinja2 +2 -5
  18. package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +2 -4
  19. package/generator/build/lib/pygen/codegen/templates/model_msrest.py.jinja2 +2 -6
  20. package/generator/build/lib/pygen/codegen/templates/operation_tools.jinja2 +0 -3
  21. package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +1 -1
  22. package/generator/component-detection-pip-report.json +6 -3
  23. package/generator/dev_requirements.txt +1 -11
  24. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  25. package/generator/pygen/black.py +13 -2
  26. package/generator/pygen/codegen/models/client.py +0 -8
  27. package/generator/pygen/codegen/serializers/builder_serializer.py +18 -33
  28. package/generator/pygen/codegen/serializers/model_serializer.py +1 -7
  29. package/generator/pygen/codegen/templates/client.py.jinja2 +1 -1
  30. package/generator/pygen/codegen/templates/macros.jinja2 +2 -5
  31. package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +2 -4
  32. package/generator/pygen/codegen/templates/model_msrest.py.jinja2 +2 -6
  33. package/generator/pygen/codegen/templates/operation_tools.jinja2 +0 -3
  34. package/generator/pygen/codegen/templates/serialization.py.jinja2 +1 -1
  35. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +92 -0
  36. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_resource_async.py +199 -3
  37. package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +80 -0
  38. package/generator/test/azure/mock_api_tests/test_azure_arm_resource.py +187 -3
  39. package/generator/test/azure/requirements.txt +2 -9
  40. package/generator/test/azure/tox.ini +2 -2
  41. package/generator/test/dev_requirements.txt +4 -0
  42. package/generator/test/unbranded/requirements.txt +1 -10
  43. package/generator/test/unbranded/tox.ini +2 -2
  44. package/package.json +33 -31
@@ -60,8 +60,19 @@ class BlackScriptPlugin(Plugin):
60
60
  except:
61
61
  _LOGGER.error("Error: failed to format %s", file)
62
62
  raise
63
- if len(file_content.splitlines()) > 1000 and "pylint: disable=too-many-lines" not in file_content:
64
- file_content = "# pylint: disable=too-many-lines\n" + file_content
63
+ pylint_disables = []
64
+ lines = file_content.splitlines()
65
+ if len(lines) > 0:
66
+ if "line-too-long" not in lines[0] and any(len(line) > 120 for line in lines):
67
+ pylint_disables.extend(["line-too-long", "useless-suppression"])
68
+ if "too-many-lines" not in lines[0] and len(lines) > 1000:
69
+ pylint_disables.append("too-many-lines")
70
+ if pylint_disables:
71
+ file_content = (
72
+ "\n".join([lines[0] + ",".join([""] + pylint_disables)] + lines[1:])
73
+ if "pylint: disable=" in lines[0]
74
+ else f"# pylint: disable={','.join(pylint_disables)}\n" + file_content
75
+ )
65
76
  self.write_file(file, file_content)
66
77
 
67
78
 
@@ -161,14 +161,6 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
161
161
  retval = add_to_pylint_disable(retval, "name-too-long")
162
162
  return retval
163
163
 
164
- @property
165
- def url_pylint_disable(self) -> str:
166
- # if the url is too long
167
- retval = ""
168
- if len(self.url) > 85:
169
- retval = add_to_pylint_disable(retval, "line-too-long")
170
- return retval
171
-
172
164
  @property
173
165
  def filename(self) -> str:
174
166
  """Name of the file for the client"""
@@ -498,11 +498,7 @@ class RequestBuilderSerializer(_BuilderBaseSerializer[RequestBuilderType]):
498
498
  url_value = _escape_str(builder.url)
499
499
  else:
500
500
  url_value = f'kwargs.pop("template_url", {_escape_str(builder.url)})'
501
- result = "_url = " + url_value
502
- # there will be always 4 spaces before the url
503
- if len(result) + 4 > 120:
504
- return result + " # pylint: disable=line-too-long"
505
- return result
501
+ return "_url = " + url_value
506
502
 
507
503
 
508
504
  ############################## NORMAL OPERATIONS ##############################
@@ -1005,7 +1001,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1005
1001
  retval.extend(deserialize_code)
1006
1002
  return retval
1007
1003
 
1008
- def handle_error_response(self, builder: OperationType) -> List[str]: # pylint: disable=too-many-statements, too-many-branches
1004
+ def handle_error_response( # pylint: disable=too-many-statements, too-many-branches
1005
+ self, builder: OperationType
1006
+ ) -> List[str]:
1009
1007
  async_await = "await " if self.async_mode else ""
1010
1008
  retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"]
1011
1009
  response_read = [
@@ -1042,34 +1040,23 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1042
1040
  )
1043
1041
  # add build-in error type
1044
1042
  # TODO: we should decide whether need to this wrapper for customized error type
1045
- if status_code == 401:
1046
- retval.append(
1047
- " raise ClientAuthenticationError(response=response{}{})".format(
1048
- error_model,
1049
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1050
- )
1051
- )
1052
- elif status_code == 404:
1053
- retval.append(
1054
- " raise ResourceNotFoundError(response=response{}{})".format(
1055
- error_model,
1056
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1057
- )
1058
- )
1059
- elif status_code == 409:
1060
- retval.append(
1061
- " raise ResourceExistsError(response=response{}{})".format(
1062
- error_model,
1063
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1064
- )
1065
- )
1066
- elif status_code == 304:
1043
+ status_code_error_map = {
1044
+ 401: "ClientAuthenticationError",
1045
+ 404: "ResourceNotFoundError",
1046
+ 409: "ResourceExistsError",
1047
+ 304: "ResourceNotModifiedError",
1048
+ }
1049
+ if status_code in status_code_error_map:
1067
1050
  retval.append(
1068
- " raise ResourceNotModifiedError(response=response{}{})".format(
1051
+ " raise {}(response=response{}{})".format(
1052
+ status_code_error_map[cast(int, status_code)],
1069
1053
  error_model,
1070
1054
  (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1071
1055
  )
1072
1056
  )
1057
+ condition = "if"
1058
+ else:
1059
+ condition = "elif"
1073
1060
  # ranged status code only exist in typespec and will not have multiple status codes
1074
1061
  else:
1075
1062
  retval.append(
@@ -1084,15 +1071,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1084
1071
  f" error = _failsafe_deserialize_xml({type_annotation}, response.text())"
1085
1072
  )
1086
1073
  else:
1087
- retval.append(
1088
- f" error = _failsafe_deserialize({type_annotation}, response.json())"
1089
- )
1074
+ retval.append(f" error = _failsafe_deserialize({type_annotation}, response.json())")
1090
1075
  else:
1091
1076
  retval.append(
1092
1077
  f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
1093
1078
  "pipeline_response)"
1094
1079
  )
1095
- condition = "elif"
1080
+ condition = "elif"
1096
1081
  # default error handling
1097
1082
  if builder.default_error_deserialization and self.code_model.options["models_mode"]:
1098
1083
  error_model = ", model=error"
@@ -325,13 +325,7 @@ class DpgModelSerializer(_ModelSerializer):
325
325
  )
326
326
  type_annotation = prop.type_annotation(serialize_namespace=self.serialize_namespace)
327
327
  generated_code = f'{prop.client_name}: {type_annotation} = {field}({", ".join(args)})'
328
- # there is 4 spaces indentation so original line length limit 120 - 4 = 116
329
- pylint_disable = (
330
- " # pylint: disable=line-too-long"
331
- if len(generated_code) <= 116 < (len(generated_code) + len(type_ignore))
332
- else ""
333
- )
334
- return f"{generated_code}{type_ignore}{pylint_disable}"
328
+ return f"{generated_code}{type_ignore}"
335
329
 
336
330
  def initialize_properties(self, model: ModelType) -> List[str]:
337
331
  init_args = []
@@ -7,7 +7,7 @@
7
7
  super().__init__()
8
8
  {% endif %}
9
9
  {% if client.has_parameterized_host %}
10
- {{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}{{ client.url_pylint_disable }}
10
+ {{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}
11
11
  {% endif %}
12
12
  {{ serializer.initialize_config() }}
13
13
  {{ op_tools.serialize(serializer.initialize_pipeline_client(async_mode)) | indent(8) }}
@@ -2,11 +2,8 @@
2
2
  {% set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) %}
3
3
  {% set list_result = original_result.split('\n') %}
4
4
  {% for line in list_result %}
5
+ {% set prefix = "" if loop.index == 1 else " " %}
5
6
  {% set suffix = suffix_string if list_result | length == loop.index %}
6
- {% if line | length > 120 %}
7
- {{ line + " # pylint: disable=line-too-long" }}{{ suffix }}
8
- {% else %}
9
- {{ line }}{{ suffix }}
10
- {% endif %}
7
+ {{ prefix }}{{ line }}{{ suffix }}
11
8
  {% endfor %}
12
9
  {% endmacro %}
@@ -22,9 +22,7 @@
22
22
  {% if model.properties != None %}
23
23
  {% for p in model.properties %}
24
24
  {% for line in serializer.variable_documentation_string(p) %}
25
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
26
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
27
- {% endfor %}
25
+ {{ macros.wrap_model_string(line, '\n ') -}}
28
26
  {% endfor %}
29
27
  {% endfor %}
30
28
  {% endif %}
@@ -37,7 +35,7 @@
37
35
  {{ serializer.declare_property(p) }}
38
36
  {% set prop_description = p.description(is_operation_file=False).replace('"', '\\"') %}
39
37
  {% if prop_description %}
40
- """{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
38
+ """{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
41
39
  {% endif %}
42
40
  {% endfor %}
43
41
 
@@ -21,9 +21,7 @@
21
21
  {% if model.properties != None %}
22
22
  {% for p in model.properties %}
23
23
  {% for line in serializer.variable_documentation_string(p) %}
24
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
25
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
26
- {% endfor %}
24
+ {{ macros.wrap_model_string(line, '\n ') -}}
27
25
  {% endfor %}
28
26
  {% endfor %}
29
27
  {% endif %}
@@ -75,9 +73,7 @@
75
73
  {% for p in model.properties %}
76
74
  {% if p.is_input %}
77
75
  {% for line in serializer.input_documentation_string(p) %}
78
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
79
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
80
- {% endfor %}
76
+ {{ macros.wrap_model_string(line, '\n ') -}}
81
77
  {% endfor %}
82
78
  {% endif %}
83
79
  {% endfor %}
@@ -12,9 +12,6 @@
12
12
  {% for description in serializer.description_and_summary(builder) %}
13
13
  {% if description %}
14
14
  {% set description = wrap_string(description, wrapstring='\n') %}
15
- {% if (serializer.line_too_long(example_template) or ns.line_too_long) and loop.first %}
16
- # pylint: disable=line-too-long
17
- {% endif %}
18
15
  {{ '"""' + description if loop.first else description }}
19
16
  {% else %}
20
17
 
@@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
1360
1360
  # Iter and wrapped, should have found one node only (the wrap one)
1361
1361
  if len(children) != 1:
1362
1362
  raise DeserializationError(
1363
- "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long
1363
+ "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format(
1364
1364
  xml_name
1365
1365
  )
1366
1366
  )
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "1",
3
- "pip_version": "24.3.1",
3
+ "pip_version": "25.0.1",
4
4
  "install": [
5
5
  {
6
6
  "download_info": {
@@ -30,6 +30,9 @@
30
30
  "management"
31
31
  ],
32
32
  "author_email": "Python Packaging Authority <distutils-sig@python.org>",
33
+ "license_file": [
34
+ "LICENSE"
35
+ ],
33
36
  "classifier": [
34
37
  "Development Status :: 5 - Production/Stable",
35
38
  "Intended Audience :: Developers",
@@ -123,9 +126,9 @@
123
126
  "implementation_version": "3.8.10",
124
127
  "os_name": "posix",
125
128
  "platform_machine": "x86_64",
126
- "platform_release": "5.15.0-1078-azure",
129
+ "platform_release": "5.15.0-1079-azure",
127
130
  "platform_system": "Linux",
128
- "platform_version": "#87~20.04.1-Ubuntu SMP Wed Dec 18 20:14:54 UTC 2024",
131
+ "platform_version": "#88~20.04.1-Ubuntu SMP Fri Jan 17 18:28:29 UTC 2025",
129
132
  "python_full_version": "3.8.10",
130
133
  "platform_python_implementation": "CPython",
131
134
  "python_version": "3.8",
@@ -1,12 +1,2 @@
1
1
  -e ./generator
2
- pyright==1.1.391
3
- pylint==3.2.7
4
- tox==4.16.0
5
- mypy==1.14.1
6
- colorama==0.4.6
7
- debugpy==1.8.2
8
- pytest==8.3.2
9
- coverage==7.6.1
10
- black==24.8.0
11
- ptvsd==4.3.2
12
- types-PyYAML==6.0.12.8
2
+ -r ../eng/scripts/ci/dev_requirements.txt
@@ -60,8 +60,19 @@ class BlackScriptPlugin(Plugin):
60
60
  except:
61
61
  _LOGGER.error("Error: failed to format %s", file)
62
62
  raise
63
- if len(file_content.splitlines()) > 1000 and "pylint: disable=too-many-lines" not in file_content:
64
- file_content = "# pylint: disable=too-many-lines\n" + file_content
63
+ pylint_disables = []
64
+ lines = file_content.splitlines()
65
+ if len(lines) > 0:
66
+ if "line-too-long" not in lines[0] and any(len(line) > 120 for line in lines):
67
+ pylint_disables.extend(["line-too-long", "useless-suppression"])
68
+ if "too-many-lines" not in lines[0] and len(lines) > 1000:
69
+ pylint_disables.append("too-many-lines")
70
+ if pylint_disables:
71
+ file_content = (
72
+ "\n".join([lines[0] + ",".join([""] + pylint_disables)] + lines[1:])
73
+ if "pylint: disable=" in lines[0]
74
+ else f"# pylint: disable={','.join(pylint_disables)}\n" + file_content
75
+ )
65
76
  self.write_file(file, file_content)
66
77
 
67
78
 
@@ -161,14 +161,6 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
161
161
  retval = add_to_pylint_disable(retval, "name-too-long")
162
162
  return retval
163
163
 
164
- @property
165
- def url_pylint_disable(self) -> str:
166
- # if the url is too long
167
- retval = ""
168
- if len(self.url) > 85:
169
- retval = add_to_pylint_disable(retval, "line-too-long")
170
- return retval
171
-
172
164
  @property
173
165
  def filename(self) -> str:
174
166
  """Name of the file for the client"""
@@ -498,11 +498,7 @@ class RequestBuilderSerializer(_BuilderBaseSerializer[RequestBuilderType]):
498
498
  url_value = _escape_str(builder.url)
499
499
  else:
500
500
  url_value = f'kwargs.pop("template_url", {_escape_str(builder.url)})'
501
- result = "_url = " + url_value
502
- # there will be always 4 spaces before the url
503
- if len(result) + 4 > 120:
504
- return result + " # pylint: disable=line-too-long"
505
- return result
501
+ return "_url = " + url_value
506
502
 
507
503
 
508
504
  ############################## NORMAL OPERATIONS ##############################
@@ -1005,7 +1001,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1005
1001
  retval.extend(deserialize_code)
1006
1002
  return retval
1007
1003
 
1008
- def handle_error_response(self, builder: OperationType) -> List[str]: # pylint: disable=too-many-statements, too-many-branches
1004
+ def handle_error_response( # pylint: disable=too-many-statements, too-many-branches
1005
+ self, builder: OperationType
1006
+ ) -> List[str]:
1009
1007
  async_await = "await " if self.async_mode else ""
1010
1008
  retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"]
1011
1009
  response_read = [
@@ -1042,34 +1040,23 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1042
1040
  )
1043
1041
  # add build-in error type
1044
1042
  # TODO: we should decide whether need to this wrapper for customized error type
1045
- if status_code == 401:
1046
- retval.append(
1047
- " raise ClientAuthenticationError(response=response{}{})".format(
1048
- error_model,
1049
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1050
- )
1051
- )
1052
- elif status_code == 404:
1053
- retval.append(
1054
- " raise ResourceNotFoundError(response=response{}{})".format(
1055
- error_model,
1056
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1057
- )
1058
- )
1059
- elif status_code == 409:
1060
- retval.append(
1061
- " raise ResourceExistsError(response=response{}{})".format(
1062
- error_model,
1063
- (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1064
- )
1065
- )
1066
- elif status_code == 304:
1043
+ status_code_error_map = {
1044
+ 401: "ClientAuthenticationError",
1045
+ 404: "ResourceNotFoundError",
1046
+ 409: "ResourceExistsError",
1047
+ 304: "ResourceNotModifiedError",
1048
+ }
1049
+ if status_code in status_code_error_map:
1067
1050
  retval.append(
1068
- " raise ResourceNotModifiedError(response=response{}{})".format(
1051
+ " raise {}(response=response{}{})".format(
1052
+ status_code_error_map[cast(int, status_code)],
1069
1053
  error_model,
1070
1054
  (", error_format=ARMErrorFormat" if self.code_model.options["azure_arm"] else ""),
1071
1055
  )
1072
1056
  )
1057
+ condition = "if"
1058
+ else:
1059
+ condition = "elif"
1073
1060
  # ranged status code only exist in typespec and will not have multiple status codes
1074
1061
  else:
1075
1062
  retval.append(
@@ -1084,15 +1071,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
1084
1071
  f" error = _failsafe_deserialize_xml({type_annotation}, response.text())"
1085
1072
  )
1086
1073
  else:
1087
- retval.append(
1088
- f" error = _failsafe_deserialize({type_annotation}, response.json())"
1089
- )
1074
+ retval.append(f" error = _failsafe_deserialize({type_annotation}, response.json())")
1090
1075
  else:
1091
1076
  retval.append(
1092
1077
  f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
1093
1078
  "pipeline_response)"
1094
1079
  )
1095
- condition = "elif"
1080
+ condition = "elif"
1096
1081
  # default error handling
1097
1082
  if builder.default_error_deserialization and self.code_model.options["models_mode"]:
1098
1083
  error_model = ", model=error"
@@ -325,13 +325,7 @@ class DpgModelSerializer(_ModelSerializer):
325
325
  )
326
326
  type_annotation = prop.type_annotation(serialize_namespace=self.serialize_namespace)
327
327
  generated_code = f'{prop.client_name}: {type_annotation} = {field}({", ".join(args)})'
328
- # there is 4 spaces indentation so original line length limit 120 - 4 = 116
329
- pylint_disable = (
330
- " # pylint: disable=line-too-long"
331
- if len(generated_code) <= 116 < (len(generated_code) + len(type_ignore))
332
- else ""
333
- )
334
- return f"{generated_code}{type_ignore}{pylint_disable}"
328
+ return f"{generated_code}{type_ignore}"
335
329
 
336
330
  def initialize_properties(self, model: ModelType) -> List[str]:
337
331
  init_args = []
@@ -7,7 +7,7 @@
7
7
  super().__init__()
8
8
  {% endif %}
9
9
  {% if client.has_parameterized_host %}
10
- {{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}{{ client.url_pylint_disable }}
10
+ {{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}
11
11
  {% endif %}
12
12
  {{ serializer.initialize_config() }}
13
13
  {{ op_tools.serialize(serializer.initialize_pipeline_client(async_mode)) | indent(8) }}
@@ -2,11 +2,8 @@
2
2
  {% set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) %}
3
3
  {% set list_result = original_result.split('\n') %}
4
4
  {% for line in list_result %}
5
+ {% set prefix = "" if loop.index == 1 else " " %}
5
6
  {% set suffix = suffix_string if list_result | length == loop.index %}
6
- {% if line | length > 120 %}
7
- {{ line + " # pylint: disable=line-too-long" }}{{ suffix }}
8
- {% else %}
9
- {{ line }}{{ suffix }}
10
- {% endif %}
7
+ {{ prefix }}{{ line }}{{ suffix }}
11
8
  {% endfor %}
12
9
  {% endmacro %}
@@ -22,9 +22,7 @@
22
22
  {% if model.properties != None %}
23
23
  {% for p in model.properties %}
24
24
  {% for line in serializer.variable_documentation_string(p) %}
25
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
26
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
27
- {% endfor %}
25
+ {{ macros.wrap_model_string(line, '\n ') -}}
28
26
  {% endfor %}
29
27
  {% endfor %}
30
28
  {% endif %}
@@ -37,7 +35,7 @@
37
35
  {{ serializer.declare_property(p) }}
38
36
  {% set prop_description = p.description(is_operation_file=False).replace('"', '\\"') %}
39
37
  {% if prop_description %}
40
- """{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
38
+ """{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
41
39
  {% endif %}
42
40
  {% endfor %}
43
41
 
@@ -21,9 +21,7 @@
21
21
  {% if model.properties != None %}
22
22
  {% for p in model.properties %}
23
23
  {% for line in serializer.variable_documentation_string(p) %}
24
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
25
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
26
- {% endfor %}
24
+ {{ macros.wrap_model_string(line, '\n ') -}}
27
25
  {% endfor %}
28
26
  {% endfor %}
29
27
  {% endif %}
@@ -75,9 +73,7 @@
75
73
  {% for p in model.properties %}
76
74
  {% if p.is_input %}
77
75
  {% for line in serializer.input_documentation_string(p) %}
78
- {% for doc_string in line.replace('\n', '\n ').split('\n') %}
79
- {{ macros.wrap_model_string(doc_string, '\n ') -}}
80
- {% endfor %}
76
+ {{ macros.wrap_model_string(line, '\n ') -}}
81
77
  {% endfor %}
82
78
  {% endif %}
83
79
  {% endfor %}
@@ -12,9 +12,6 @@
12
12
  {% for description in serializer.description_and_summary(builder) %}
13
13
  {% if description %}
14
14
  {% set description = wrap_string(description, wrapstring='\n') %}
15
- {% if (serializer.line_too_long(example_template) or ns.line_too_long) and loop.first %}
16
- # pylint: disable=line-too-long
17
- {% endif %}
18
15
  {{ '"""' + description if loop.first else description }}
19
16
  {% else %}
20
17
 
@@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
1360
1360
  # Iter and wrapped, should have found one node only (the wrap one)
1361
1361
  if len(children) != 1:
1362
1362
  raise DeserializationError(
1363
- "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long
1363
+ "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format(
1364
1364
  xml_name
1365
1365
  )
1366
1366
  )
@@ -0,0 +1,92 @@
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 azure.resourcemanager.operationtemplates.aio import OperationTemplatesClient
8
+ from azure.resourcemanager.operationtemplates import models
9
+
10
+ SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000"
11
+ RESOURCE_GROUP_NAME = "test-rg"
12
+
13
+
14
+ @pytest.fixture
15
+ async def client(credential, authentication_policy):
16
+ async with OperationTemplatesClient(
17
+ credential,
18
+ SUBSCRIPTION_ID,
19
+ "http://localhost:3000",
20
+ authentication_policy=authentication_policy,
21
+ ) as client:
22
+ yield client
23
+
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_check_name_availability_check_global(client):
27
+ result = await client.check_name_availability.check_global(
28
+ body=models.CheckNameAvailabilityRequest(name="checkName", type="Microsoft.Web/site")
29
+ )
30
+ assert result.name_available == False
31
+ assert result.reason == models.CheckNameAvailabilityReason.ALREADY_EXISTS
32
+ assert result.message == "Hostname 'checkName' already exists. Please select a different name."
33
+
34
+
35
+ @pytest.mark.asyncio
36
+ async def test_check_name_availability_check_local(client):
37
+ result = await client.check_name_availability.check_local(
38
+ location="westus",
39
+ body=models.CheckNameAvailabilityRequest(name="checkName", type="Microsoft.Web/site"),
40
+ )
41
+ assert result.name_available == False
42
+ assert result.reason == models.CheckNameAvailabilityReason.ALREADY_EXISTS
43
+ assert result.message == "Hostname 'checkName' already exists. Please select a different name."
44
+
45
+
46
+ @pytest.mark.asyncio
47
+ async def test_operations_list(client):
48
+ result = client.operations.list()
49
+ assert result
50
+
51
+
52
+ @pytest.mark.asyncio
53
+ async def test_lro_begin_create_or_replace(client):
54
+ result = await (
55
+ await client.lro.begin_create_or_replace(
56
+ resource_group_name=RESOURCE_GROUP_NAME,
57
+ order_name="order1",
58
+ resource=models.Order(
59
+ location="eastus",
60
+ properties=models.OrderProperties(product_id="product1", amount=1),
61
+ ),
62
+ )
63
+ ).result()
64
+ assert result.name == "order1"
65
+ assert (
66
+ result.id
67
+ == "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1"
68
+ )
69
+ assert result.type == "Azure.ResourceManager.Resources/orders"
70
+ assert result.location == "eastus"
71
+ assert result.system_data.created_by == "AzureSDK"
72
+
73
+
74
+ @pytest.mark.asyncio
75
+ async def test_lro_begin_export(client):
76
+ await (
77
+ await client.lro.begin_export(
78
+ resource_group_name=RESOURCE_GROUP_NAME,
79
+ order_name="order1",
80
+ body=models.ExportRequest(format="csv"),
81
+ )
82
+ ).result()
83
+
84
+
85
+ @pytest.mark.asyncio
86
+ async def test_lro_begin_delete(client):
87
+ await (
88
+ await client.lro.begin_delete(
89
+ resource_group_name=RESOURCE_GROUP_NAME,
90
+ order_name="order1",
91
+ )
92
+ ).result()