@typespec/http-client-python 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/emitter/code-model.d.ts.map +1 -1
  2. package/dist/emitter/code-model.js +20 -15
  3. package/dist/emitter/code-model.js.map +1 -1
  4. package/dist/emitter/emitter.js +1 -1
  5. package/dist/emitter/emitter.js.map +1 -1
  6. package/dist/emitter/http.d.ts.map +1 -1
  7. package/dist/emitter/http.js +2 -3
  8. package/dist/emitter/http.js.map +1 -1
  9. package/emitter/src/code-model.ts +28 -21
  10. package/emitter/src/emitter.ts +1 -1
  11. package/emitter/src/http.ts +1 -4
  12. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  13. package/eng/scripts/ci/regenerate-common.ts +472 -0
  14. package/eng/scripts/ci/regenerate.ts +41 -437
  15. package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
  16. package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
  17. package/generator/build/lib/pygen/codegen/models/client.py +5 -5
  18. package/generator/build/lib/pygen/codegen/models/credential_types.py +1 -1
  19. package/generator/build/lib/pygen/codegen/models/enum_type.py +1 -1
  20. package/generator/build/lib/pygen/codegen/models/imports.py +2 -3
  21. package/generator/build/lib/pygen/codegen/models/lro_operation.py +1 -1
  22. package/generator/build/lib/pygen/codegen/models/model_type.py +2 -2
  23. package/generator/build/lib/pygen/codegen/models/operation.py +5 -5
  24. package/generator/build/lib/pygen/codegen/models/operation_group.py +1 -1
  25. package/generator/build/lib/pygen/codegen/models/paging_operation.py +2 -2
  26. package/generator/build/lib/pygen/codegen/models/primitive_types.py +1 -1
  27. package/generator/build/lib/pygen/codegen/models/request_builder.py +1 -1
  28. package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +16 -7
  29. package/generator/build/lib/pygen/codegen/serializers/import_serializer.py +4 -31
  30. package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +14 -4
  31. package/generator/build/lib/pygen/preprocess/__init__.py +9 -21
  32. package/generator/build/lib/pygen/preprocess/python_mappings.py +0 -2
  33. package/generator/component-detection-pip-report.json +5 -6
  34. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  35. package/generator/pygen/codegen/models/client.py +5 -5
  36. package/generator/pygen/codegen/models/credential_types.py +1 -1
  37. package/generator/pygen/codegen/models/enum_type.py +1 -1
  38. package/generator/pygen/codegen/models/imports.py +2 -3
  39. package/generator/pygen/codegen/models/lro_operation.py +1 -1
  40. package/generator/pygen/codegen/models/model_type.py +2 -2
  41. package/generator/pygen/codegen/models/operation.py +5 -5
  42. package/generator/pygen/codegen/models/operation_group.py +1 -1
  43. package/generator/pygen/codegen/models/paging_operation.py +2 -2
  44. package/generator/pygen/codegen/models/primitive_types.py +1 -1
  45. package/generator/pygen/codegen/models/request_builder.py +1 -1
  46. package/generator/pygen/codegen/serializers/builder_serializer.py +16 -7
  47. package/generator/pygen/codegen/serializers/import_serializer.py +4 -31
  48. package/generator/pygen/codegen/templates/model_base.py.jinja2 +14 -4
  49. package/generator/pygen/preprocess/__init__.py +9 -21
  50. package/generator/pygen/preprocess/python_mappings.py +0 -2
  51. package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +24 -2
  52. package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_page_async.py +12 -0
  53. package/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +6 -0
  54. package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +22 -2
  55. package/generator/test/azure/mock_api_tests/test_azure_core_page.py +11 -0
  56. package/generator/test/azure/mock_api_tests/test_clear_output_folder.py +9 -0
  57. package/generator/test/azure/mock_api_tests/test_special_words.py +5 -0
  58. package/generator/test/azure/requirements.txt +4 -1
  59. package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +13 -1
  60. package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +6 -1
  61. package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +21 -0
  62. package/generator/test/generic_mock_api_tests/data/image.jpg +0 -0
  63. package/generator/test/generic_mock_api_tests/data/image.png +0 -0
  64. package/generator/test/generic_mock_api_tests/test_authentication.py +11 -1
  65. package/generator/test/generic_mock_api_tests/test_encode_bytes.py +6 -0
  66. package/generator/test/generic_mock_api_tests/test_payload_xml.py +19 -0
  67. package/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +7 -0
  68. package/generator/test/unbranded/mock_api_tests/test_special_words.py +6 -0
  69. package/generator/test/unbranded/mock_api_tests/test_unbranded.py +9 -8
  70. package/generator/test/unbranded/requirements.txt +2 -1
  71. package/generator/test/unittests/test_enums.py +37 -0
  72. package/generator/test/unittests/test_model_base_serialization.py +161 -0
  73. package/generator/test/unittests/test_model_base_xml_serialization.py +244 -2
  74. package/generator/test/unittests/test_name_converter.py +0 -8
  75. package/package.json +39 -39
@@ -527,6 +527,8 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):
527
527
  return self._data.setdefault(key, default)
528
528
 
529
529
  def __eq__(self, other: typing.Any) -> bool:
530
+ if isinstance(other, _MyMutableMapping):
531
+ return self._data == other._data
530
532
  try:
531
533
  other_model = self.__class__(other)
532
534
  except Exception:
@@ -650,6 +652,9 @@ class Model(_MyMutableMapping):
650
652
  if len(items) > 0:
651
653
  existed_attr_keys.append(xml_name)
652
654
  dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
655
+ elif not rf._is_optional:
656
+ existed_attr_keys.append(xml_name)
657
+ dict_to_pass[rf._rest_name] = []
653
658
  continue
654
659
 
655
660
  # text element is primitive type
@@ -928,6 +933,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
928
933
  # is it optional?
929
934
  try:
930
935
  if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
936
+ if rf:
937
+ rf._is_optional = True
931
938
  if len(annotation.__args__) <= 2: # pyright: ignore
932
939
  if_obj_deserializer = _get_deserialize_callable_from_annotation(
933
940
  next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
@@ -1020,16 +1027,20 @@ def _deserialize_with_callable(
1020
1027
  return float(value.text) if value.text else None
1021
1028
  if deserializer is bool:
1022
1029
  return value.text == "true" if value.text else None
1030
+ if deserializer and deserializer in _DESERIALIZE_MAPPING.values():
1031
+ return deserializer(value.text) if value.text else None
1032
+ if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values():
1033
+ return deserializer(value.text) if value.text else None
1023
1034
  if deserializer is None:
1024
1035
  return value
1025
1036
  if deserializer in [int, float, bool]:
1026
1037
  return deserializer(value)
1027
1038
  if isinstance(deserializer, CaseInsensitiveEnumMeta):
1028
1039
  try:
1029
- return deserializer(value)
1040
+ return deserializer(value.text if isinstance(value, ET.Element) else value)
1030
1041
  except ValueError:
1031
1042
  # for unknown value, return raw value
1032
- return value
1043
+ return value.text if isinstance(value, ET.Element) else value
1033
1044
  if isinstance(deserializer, type) and issubclass(deserializer, Model):
1034
1045
  return deserializer._deserialize(value, [])
1035
1046
  return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value)
@@ -1084,9 +1095,7 @@ def _failsafe_deserialize_xml(
1084
1095
  return None
1085
1096
 
1086
1097
 
1087
- {% if code_model.has_padded_model_property %}
1088
1098
  # pylint: disable=too-many-instance-attributes
1089
- {% endif %}
1090
1099
  class _RestField:
1091
1100
  def __init__(
1092
1101
  self,
@@ -1109,6 +1118,7 @@ class _RestField:
1109
1118
  self._is_discriminator = is_discriminator
1110
1119
  self._visibility = visibility
1111
1120
  self._is_model = False
1121
+ self._is_optional = False
1112
1122
  self._default = default
1113
1123
  self._format = format
1114
1124
  self._is_multipart_file_input = is_multipart_file_input
@@ -4,6 +4,7 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  """The preprocessing autorest plugin."""
7
+
7
8
  import copy
8
9
  from typing import Callable, Any, Optional
9
10
 
@@ -21,7 +22,6 @@ from ..utils import (
21
22
  get_body_type_for_description,
22
23
  JSON_REGEXP,
23
24
  KNOWN_TYPES,
24
- update_enum_value,
25
25
  )
26
26
 
27
27
 
@@ -267,30 +267,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
267
267
  add_redefined_builtin_info(property["clientName"], property)
268
268
  if type.get("name"):
269
269
  pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
270
- name = self.pad_reserved_words(type["name"], pad_type, type)
271
- type["name"] = name[0].upper() + name[1:]
270
+ if type["type"] != "enumvalue":
271
+ name = self.pad_reserved_words(type["name"], pad_type, type)
272
+ type["name"] = name[0].upper() + name[1:]
272
273
  type["description"] = update_description(type.get("description", ""), type["name"])
273
274
  type["snakeCaseName"] = to_snake_case(type["name"])
274
275
  if type.get("values"):
275
- # we're enums
276
- values_to_add = []
276
+ # we're enums - enum values are UPPER_CASE so no padding needed for reserved words
277
277
  for value in type["values"]:
278
- padded_name = self.pad_reserved_words(value["name"].lower(), PadType.ENUM_VALUE, value).upper()
279
- if self.version_tolerant:
280
- if padded_name[0] in "0123456789":
281
- padded_name = "ENUM_" + padded_name
282
- value["name"] = padded_name
283
- else:
284
- if value["name"] != padded_name:
285
- values_to_add.append(
286
- update_enum_value(
287
- name=padded_name,
288
- value=value["value"],
289
- description=value["description"],
290
- enum_type=value["enumType"],
291
- )
292
- )
293
- type["values"].extend(values_to_add)
278
+ upper_name = value["name"].upper()
279
+ if upper_name[0] in "0123456789":
280
+ upper_name = "ENUM_" + upper_name
281
+ value["name"] = upper_name
294
282
 
295
283
  # add type for reference
296
284
  for v in HEADERS_CONVERT_IN_METHOD.values():
@@ -56,7 +56,6 @@ class PadType(str, Enum):
56
56
  ENUM_CLASS = "Enum"
57
57
  METHOD = "_method"
58
58
  PARAMETER = "_parameter"
59
- ENUM_VALUE = "_enum"
60
59
  PROPERTY = "_property"
61
60
  OPERATION_GROUP = "Operations"
62
61
 
@@ -183,7 +182,6 @@ RESERVED_WORDS = {
183
182
  PadType.MODEL: ["enum", *_always_reserved],
184
183
  PadType.PROPERTY: ["self", *_always_reserved],
185
184
  PadType.ENUM_CLASS: ["enum", *_always_reserved],
186
- PadType.ENUM_VALUE: ["mro", *_always_reserved],
187
185
  PadType.OPERATION_GROUP: [*_always_reserved],
188
186
  }
189
187
 
@@ -6,10 +6,13 @@
6
6
  import pytest
7
7
  from specs.azure.clientgenerator.core.flattenproperty.aio import FlattenPropertyClient
8
8
  from specs.azure.clientgenerator.core.flattenproperty.models import (
9
- FlattenModel,
9
+ ChildFlattenModel,
10
10
  ChildModel,
11
+ FlattenModel,
12
+ FlattenUnknownModel,
11
13
  NestedFlattenModel,
12
- ChildFlattenModel,
14
+ Solution,
15
+ SolutionProperties,
13
16
  )
14
17
 
15
18
 
@@ -46,6 +49,25 @@ async def test_put_nested_flatten_model(client: FlattenPropertyClient):
46
49
  )
47
50
 
48
51
 
52
+ @pytest.mark.asyncio
53
+ async def test_put_flatten_unknown_model(client: FlattenPropertyClient):
54
+ result = await client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
55
+ assert result.name == "test"
56
+ assert result.properties == {"key1": "value1", "key2": "value2"}
57
+
58
+
59
+ @pytest.mark.asyncio
60
+ async def test_put_flatten_read_only_model(client: FlattenPropertyClient):
61
+ result = await client.put_flatten_read_only_model(Solution(name="foo"))
62
+ assert result == Solution(
63
+ name="foo",
64
+ properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"),
65
+ )
66
+ assert result.solution_id == "solution1"
67
+ assert result.title == "Solution Title"
68
+ assert result.content == "Solution Content"
69
+
70
+
49
71
  @pytest.mark.asyncio # ============test for compatibility ============
50
72
  async def test_dpg_model_common():
51
73
  flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
@@ -66,3 +66,15 @@ async def test_list_with_parameterized_next_link(client: aio.PageClient):
66
66
  assert result[0].name == "User1"
67
67
  assert result[1].id == 2
68
68
  assert result[1].name == "User2"
69
+
70
+
71
+ @pytest.mark.asyncio
72
+ async def test_list_with_relative_next_link(client: aio.PageClient):
73
+ result = [item async for item in client.with_relative_next_link()]
74
+ assert len(result) == 2
75
+ assert result[0].id == 1
76
+ assert result[0].name == "User1"
77
+ assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
78
+ assert result[1].id == 2
79
+ assert result[1].name == "User2"
80
+ assert result[1].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
@@ -63,3 +63,9 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient):
63
63
  @pytest.mark.asyncio
64
64
  async def test_model_properties_with_list(client: SpecialWordsClient):
65
65
  await client.model_properties.with_list(models.ModelWithList(list="ok"))
66
+
67
+
68
+ @pytest.mark.asyncio
69
+ async def test_extensible_strings(client: SpecialWordsClient):
70
+ for enum_value in models.ExtensibleString:
71
+ assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value)
@@ -6,10 +6,13 @@
6
6
  import pytest
7
7
  from specs.azure.clientgenerator.core.flattenproperty import FlattenPropertyClient
8
8
  from specs.azure.clientgenerator.core.flattenproperty.models import (
9
- FlattenModel,
9
+ ChildFlattenModel,
10
10
  ChildModel,
11
+ FlattenModel,
12
+ FlattenUnknownModel,
11
13
  NestedFlattenModel,
12
- ChildFlattenModel,
14
+ Solution,
15
+ SolutionProperties,
13
16
  )
14
17
 
15
18
 
@@ -41,6 +44,23 @@ def test_put_nested_flatten_model(client: FlattenPropertyClient):
41
44
  )
42
45
 
43
46
 
47
+ def test_put_flatten_unknown_model(client: FlattenPropertyClient):
48
+ result = client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
49
+ assert result.name == "test"
50
+ assert result.properties == {"key1": "value1", "key2": "value2"}
51
+
52
+
53
+ def test_put_flatten_read_only_model(client: FlattenPropertyClient):
54
+ result = client.put_flatten_read_only_model(Solution(name="foo"))
55
+ assert result == Solution(
56
+ name="foo",
57
+ properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"),
58
+ )
59
+ assert result.solution_id == "solution1"
60
+ assert result.title == "Solution Title"
61
+ assert result.content == "Solution Content"
62
+
63
+
44
64
  # ============test for compatibility ============
45
65
  def test_dpg_model_common():
46
66
  flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
@@ -58,3 +58,14 @@ def test_list_with_parameterized_next_link(client: PageClient):
58
58
  assert result[0].name == "User1"
59
59
  assert result[1].id == 2
60
60
  assert result[1].name == "User2"
61
+
62
+
63
+ def test_list_with_relative_next_link(client: PageClient):
64
+ result = list(client.with_relative_next_link())
65
+ assert len(result) == 2
66
+ assert result[0].id == 1
67
+ assert result[0].name == "User1"
68
+ assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
69
+ assert result[1].id == 2
70
+ assert result[1].name == "User2"
71
+ assert result[1].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59"
@@ -12,3 +12,12 @@ def test_clear_output_folder():
12
12
  folder = GENERATED_PATH / "authentication-api-key/authentication/apikey/_operations"
13
13
  assert folder.exists(), "Operations folder should exist"
14
14
  assert not (folder / "to_be_deleted.py").exists(), "File to_be_deleted.py should be deleted after regeneration"
15
+
16
+ if (GENERATED_PATH / "generation-subdir").exists():
17
+ assert (GENERATED_PATH / "generation-subdir/generated_tests").exists()
18
+ assert not (GENERATED_PATH / "generation-subdir/generated_tests/to_be_deleted.py").exists()
19
+
20
+ assert (GENERATED_PATH / "generation-subdir/generation/subdir/_generated").exists()
21
+ assert not (GENERATED_PATH / "generation-subdir/generation/subdir/_generated/to_be_deleted.py").exists()
22
+
23
+ assert (GENERATED_PATH / "generation-subdir/generation/subdir/to_be_kept.py").exists()
@@ -56,3 +56,8 @@ def test_model_properties_dict_methods(client: SpecialWordsClient):
56
56
 
57
57
  def test_model_properties_with_list(client: SpecialWordsClient):
58
58
  client.model_properties.with_list(models.ModelWithList(list="ok"))
59
+
60
+
61
+ def test_extensible_strings(client: SpecialWordsClient):
62
+ for enum_value in models.ExtensibleString:
63
+ assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value)
@@ -2,6 +2,7 @@
2
2
  -e ../../
3
3
  azure-mgmt-core==1.6.0
4
4
 
5
+ # === common azure dependencies across repos ===
5
6
  # only for azure
6
7
  -e ./generated/azure-client-generator-core-access
7
8
  -e ./generated/azure-client-generator-core-api-version-header
@@ -55,8 +56,9 @@ azure-mgmt-core==1.6.0
55
56
  -e ./generated/resiliency-srv-driven1
56
57
  -e ./generated/resiliency-srv-driven2
57
58
  -e ./generated/service-multi-service
59
+ # === end common azure dependencies across repos ===
58
60
 
59
- # common test case
61
+ # === common test dependencies across repos ===
60
62
  -e ./generated/authentication-api-key
61
63
  -e ./generated/authentication-http-custom
62
64
  -e ./generated/authentication-noauth-union
@@ -121,3 +123,4 @@ azure-mgmt-core==1.6.0
121
123
  -e ./generated/versioning-renamedfrom
122
124
  -e ./generated/versioning-returntypechangedfrom
123
125
  -e ./generated/versioning-typechangedfrom
126
+ # === end common test dependencies across repos ===
@@ -9,7 +9,7 @@ from authentication.http.custom.aio import CustomClient
9
9
  from authentication.oauth2.aio import OAuth2Client
10
10
  from authentication.union.aio import UnionClient
11
11
  from setuppy.authentication.union.aio import UnionClient as SetuppyUnionClient
12
-
12
+ from authentication.noauth.union.aio import UnionClient as NoauthUnionClient
13
13
 
14
14
  # Utilities functions
15
15
 
@@ -113,6 +113,18 @@ async def test_union_tokenvalid(oauth2_client, union_client_type):
113
113
  await client.valid_token(enforce_https=False)
114
114
 
115
115
 
116
+ @pytest.mark.asyncio
117
+ async def test_noauth_union_valid_no_auth():
118
+ client = NoauthUnionClient()
119
+ await client.valid_no_auth()
120
+
121
+
122
+ @pytest.mark.asyncio
123
+ async def test_noauth_union_valid_token(oauth2_client):
124
+ client = oauth2_client(NoauthUnionClient)
125
+ await client.valid_token(enforce_https=False)
126
+
127
+
116
128
  @pytest.mark.asyncio
117
129
  async def test_http_custom_valid(http_custom_client):
118
130
  client = http_custom_client()
@@ -13,7 +13,6 @@ from encode.bytes.models import (
13
13
  Base64urlArrayBytesProperty,
14
14
  )
15
15
 
16
-
17
16
  FILE_FOLDER = Path(__file__).parent.parent
18
17
 
19
18
 
@@ -98,6 +97,12 @@ async def test_header(client: BytesClient):
98
97
  )
99
98
 
100
99
 
100
+ @pytest.fixture
101
+ def png_data() -> bytes:
102
+ with open(str(FILE_FOLDER / "data/image.png"), "rb") as file_in:
103
+ return file_in.read()
104
+
105
+
101
106
  @pytest.mark.asyncio
102
107
  async def test_request_body(client: BytesClient, png_data: bytes):
103
108
  await client.request_body.default(
@@ -3,6 +3,7 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
+ import datetime
6
7
  import pytest
7
8
  from payload.xml.aio import XmlClient
8
9
  from payload.xml.models import (
@@ -18,6 +19,8 @@ from payload.xml.models import (
18
19
  ModelWithText,
19
20
  ModelWithDictionary,
20
21
  ModelWithEncodedNames,
22
+ ModelWithEnum,
23
+ ModelWithDatetime,
21
24
  )
22
25
 
23
26
 
@@ -119,6 +122,24 @@ async def test_model_with_encoded_names(client: XmlClient):
119
122
  await client.model_with_encoded_names_value.put(model)
120
123
 
121
124
 
125
+ @pytest.mark.asyncio
126
+ async def test_model_with_enum(client: XmlClient):
127
+ model = ModelWithEnum(status="success")
128
+ assert await client.model_with_enum_value.get() == model
129
+ await client.model_with_enum_value.put(model)
130
+
131
+
132
+ @pytest.mark.asyncio
133
+ async def test_model_with_datetime(client: XmlClient):
134
+ model = ModelWithDatetime(
135
+ rfc3339=datetime.datetime(2022, 8, 26, 18, 38, 0, tzinfo=datetime.timezone.utc),
136
+ rfc7231=datetime.datetime(2022, 8, 26, 14, 38, 0, tzinfo=datetime.timezone.utc),
137
+ )
138
+ result = await client.model_with_datetime_value.get()
139
+ assert result.rfc3339 == model.rfc3339
140
+ assert result.rfc7231 == model.rfc7231
141
+
142
+
122
143
  @pytest.mark.asyncio
123
144
  async def test_xml_error_value(client: XmlClient, core_library):
124
145
  with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
@@ -8,9 +8,9 @@ from authentication.apikey import ApiKeyClient
8
8
  from authentication.oauth2 import OAuth2Client
9
9
  from authentication.union import UnionClient
10
10
  from setuppy.authentication.union import UnionClient as SetuppyUnionClient
11
+ from authentication.noauth.union import UnionClient as NoauthUnionClient
11
12
  from authentication.http.custom import CustomClient
12
13
 
13
-
14
14
  # Utilities functions
15
15
 
16
16
 
@@ -107,6 +107,16 @@ def test_union_tokenvalid(oauth2_client, union_client_type):
107
107
  client.valid_token(enforce_https=False)
108
108
 
109
109
 
110
+ def test_noauth_union_valid_no_auth():
111
+ client = NoauthUnionClient()
112
+ client.valid_no_auth()
113
+
114
+
115
+ def test_noauth_union_valid_token(oauth2_client):
116
+ client = oauth2_client(NoauthUnionClient)
117
+ client.valid_token(enforce_https=False)
118
+
119
+
110
120
  def test_http_custom_valid(http_custom_client):
111
121
  client = http_custom_client()
112
122
  client.valid()
@@ -95,6 +95,12 @@ def test_header(client: BytesClient):
95
95
  )
96
96
 
97
97
 
98
+ @pytest.fixture
99
+ def png_data() -> bytes:
100
+ with open(str(FILE_FOLDER / "data/image.png"), "rb") as file_in:
101
+ return file_in.read()
102
+
103
+
98
104
  def test_request_body(client: BytesClient, png_data: bytes):
99
105
  client.request_body.default(
100
106
  value=png_data,
@@ -3,6 +3,7 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
+ import datetime
6
7
  import pytest
7
8
  from payload.xml import XmlClient
8
9
  from payload.xml.models import (
@@ -18,6 +19,8 @@ from payload.xml.models import (
18
19
  ModelWithText,
19
20
  ModelWithDictionary,
20
21
  ModelWithEncodedNames,
22
+ ModelWithEnum,
23
+ ModelWithDatetime,
21
24
  )
22
25
 
23
26
 
@@ -107,6 +110,22 @@ def test_model_with_encoded_names(client: XmlClient):
107
110
  client.model_with_encoded_names_value.put(model)
108
111
 
109
112
 
113
+ def test_model_with_enum(client: XmlClient):
114
+ model = ModelWithEnum(status="success")
115
+ assert client.model_with_enum_value.get() == model
116
+ client.model_with_enum_value.put(model)
117
+
118
+
119
+ def test_model_with_datetime(client: XmlClient):
120
+ model = ModelWithDatetime(
121
+ rfc3339=datetime.datetime(2022, 8, 26, 18, 38, 0, tzinfo=datetime.timezone.utc),
122
+ rfc7231=datetime.datetime(2022, 8, 26, 14, 38, 0, tzinfo=datetime.timezone.utc),
123
+ )
124
+ result = client.model_with_datetime_value.get()
125
+ assert result.rfc3339 == model.rfc3339
126
+ assert result.rfc7231 == model.rfc7231
127
+
128
+
110
129
  def test_xml_error_value(client: XmlClient, core_library):
111
130
  with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
112
131
  client.xml_error_value.get()
@@ -7,6 +7,7 @@ import pytest
7
7
  from specialwords.aio import SpecialWordsClient
8
8
  from specialwords.models import models
9
9
  from specialwords.modelproperties import models as model_properties_models
10
+ from specialwords.extensiblestrings import models as extensible_strings_models
10
11
 
11
12
 
12
13
  @pytest.fixture
@@ -64,3 +65,9 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient):
64
65
  @pytest.mark.asyncio
65
66
  async def test_model_properties_with_list(client: SpecialWordsClient):
66
67
  await client.model_properties.with_list(model_properties_models.ModelWithList(list="ok"))
68
+
69
+
70
+ @pytest.mark.asyncio
71
+ async def test_extensible_strings(client: SpecialWordsClient):
72
+ for enum_value in extensible_strings_models.ExtensibleString:
73
+ assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value)
@@ -7,6 +7,7 @@ import pytest
7
7
  from specialwords import SpecialWordsClient
8
8
  from specialwords.models import models
9
9
  from specialwords.modelproperties import models as model_properties_models
10
+ from specialwords.extensiblestrings import models as extensible_strings_models
10
11
 
11
12
 
12
13
  @pytest.fixture
@@ -58,3 +59,8 @@ def test_model_properties_dict_methods(client: SpecialWordsClient):
58
59
 
59
60
  def test_model_properties_with_list(client: SpecialWordsClient):
60
61
  client.model_properties.with_list(model_properties_models.ModelWithList(list="ok"))
62
+
63
+
64
+ def test_extensible_strings(client: SpecialWordsClient):
65
+ for enum_value in extensible_strings_models.ExtensibleString:
66
+ assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value)
@@ -54,11 +54,12 @@ def test_sensitive_word():
54
54
  check_folder = (Path(os.path.dirname(__file__)) / "../generated").resolve()
55
55
  assert [] == check_sensitive_word(check_folder, "azure")
56
56
  # after update spector, it shall also equal to []
57
- assert sorted(
58
- [
59
- "authentication-oauth2",
60
- "authentication-noauth-union",
61
- "authentication-union",
62
- "setuppy-authentication-union",
63
- ]
64
- ) == sorted(check_sensitive_word(check_folder, "microsoft"))
57
+ expected = [
58
+ "authentication-oauth2",
59
+ "authentication-noauth-union",
60
+ "authentication-union",
61
+ "setuppy-authentication-union",
62
+ ]
63
+ if (check_folder / "generation-subdir").exists():
64
+ expected.append("generation-subdir")
65
+ assert sorted(expected) == sorted(check_sensitive_word(check_folder, "microsoft"))
@@ -1,7 +1,7 @@
1
1
  -r ../dev_requirements.txt
2
2
  -e ../../
3
3
 
4
- # common test case
4
+ # === common test dependencies across repos ===
5
5
  -e ./generated/authentication-api-key
6
6
  -e ./generated/authentication-http-custom
7
7
  -e ./generated/authentication-noauth-union
@@ -66,3 +66,4 @@
66
66
  -e ./generated/versioning-renamedfrom
67
67
  -e ./generated/versioning-returntypechangedfrom
68
68
  -e ./generated/versioning-typechangedfrom
69
+ # === end common test dependencies across repos ===
@@ -4,6 +4,7 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  from enum import Enum, EnumMeta
7
+ from specialwords.extensiblestrings import models as extensible_strings_models
7
8
 
8
9
 
9
10
  class _CaseInsensitiveEnumMeta(EnumMeta):
@@ -50,3 +51,39 @@ def test_find():
50
51
  def test_join():
51
52
  assert EnumsWithCallableNames.JOIN == "join"
52
53
  assert callable(EnumsWithCallableNames.join)
54
+
55
+
56
+ def test_extensible_strings_enum_with_special_words():
57
+ assert extensible_strings_models.ExtensibleString.AND == "and"
58
+ assert extensible_strings_models.ExtensibleString.AS == "as"
59
+ assert extensible_strings_models.ExtensibleString.ASSERT == "assert"
60
+ assert extensible_strings_models.ExtensibleString.ASYNC == "async"
61
+ assert extensible_strings_models.ExtensibleString.AWAIT == "await"
62
+ assert extensible_strings_models.ExtensibleString.BREAK == "break"
63
+ assert extensible_strings_models.ExtensibleString.CLASS == "class"
64
+ assert extensible_strings_models.ExtensibleString.CONSTRUCTOR == "constructor"
65
+ assert extensible_strings_models.ExtensibleString.CONTINUE == "continue"
66
+ assert extensible_strings_models.ExtensibleString.DEF == "def"
67
+ assert extensible_strings_models.ExtensibleString.DEL == "del"
68
+ assert extensible_strings_models.ExtensibleString.ELIF == "elif"
69
+ assert extensible_strings_models.ExtensibleString.ELSE == "else"
70
+ assert extensible_strings_models.ExtensibleString.EXCEPT == "except"
71
+ assert extensible_strings_models.ExtensibleString.EXEC == "exec"
72
+ assert extensible_strings_models.ExtensibleString.FINALLY == "finally"
73
+ assert extensible_strings_models.ExtensibleString.FOR == "for"
74
+ assert extensible_strings_models.ExtensibleString.FROM == "from"
75
+ assert extensible_strings_models.ExtensibleString.GLOBAL == "global"
76
+ assert extensible_strings_models.ExtensibleString.IF == "if"
77
+ assert extensible_strings_models.ExtensibleString.IMPORT == "import"
78
+ assert extensible_strings_models.ExtensibleString.IN == "in"
79
+ assert extensible_strings_models.ExtensibleString.IS == "is"
80
+ assert extensible_strings_models.ExtensibleString.LAMBDA == "lambda"
81
+ assert extensible_strings_models.ExtensibleString.NOT == "not"
82
+ assert extensible_strings_models.ExtensibleString.OR == "or"
83
+ assert extensible_strings_models.ExtensibleString.PASS == "pass"
84
+ assert extensible_strings_models.ExtensibleString.RAISE == "raise"
85
+ assert extensible_strings_models.ExtensibleString.RETURN == "return"
86
+ assert extensible_strings_models.ExtensibleString.TRY == "try"
87
+ assert extensible_strings_models.ExtensibleString.WHILE == "while"
88
+ assert extensible_strings_models.ExtensibleString.WITH == "with"
89
+ assert extensible_strings_models.ExtensibleString.YIELD == "yield"