@typespec/http-client-python 0.28.0 → 0.28.2

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 (28) hide show
  1. package/dist/emitter/code-model.d.ts.map +1 -1
  2. package/dist/emitter/code-model.js +2 -1
  3. package/dist/emitter/code-model.js.map +1 -1
  4. package/emitter/src/code-model.ts +2 -1
  5. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  6. package/eng/scripts/Build-Packages.ps1 +1 -1
  7. package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
  8. package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
  9. package/eng/scripts/setup/package_manager.py +2 -2
  10. package/generator/build/lib/pygen/codegen/models/operation.py +9 -8
  11. package/generator/build/lib/pygen/codegen/models/parameter.py +10 -4
  12. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  13. package/generator/pygen/codegen/models/operation.py +9 -8
  14. package/generator/pygen/codegen/models/parameter.py +10 -4
  15. package/generator/test/azure/mock_api_tests/asynctests/test_client_naming_async.py +5 -5
  16. package/generator/test/azure/mock_api_tests/asynctests/test_client_structure_async.py +13 -11
  17. package/generator/test/azure/mock_api_tests/asynctests/test_client_structure_clientoperationgroup_async.py +6 -4
  18. package/generator/test/azure/mock_api_tests/test_client_naming.py +5 -5
  19. package/generator/test/azure/mock_api_tests/test_client_structure.py +12 -9
  20. package/generator/test/azure/mock_api_tests/test_client_structure_clientoperationgroup.py +7 -4
  21. package/generator/test/azure/requirements.txt +0 -1
  22. package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +7 -0
  23. package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +1 -0
  24. package/generator/test/generic_mock_api_tests/test_payload_pageable.py +6 -0
  25. package/generator/test/generic_mock_api_tests/test_payload_xml.py +1 -0
  26. package/package.json +12 -12
  27. package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py +0 -111
  28. package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py +0 -107
@@ -77,7 +77,7 @@ finally {
77
77
  }
78
78
 
79
79
  if ($PublishType -eq "internal") {
80
- $feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry"
80
+ $feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry"
81
81
 
82
82
  $overrides = @{
83
83
  "@typespec/http-client-python" = "$feedUrl/@typespec/http-client-python/-/http-client-python-$emitterVersion.tgz"
@@ -25,7 +25,7 @@ def _check_command_available(command: str) -> bool:
25
25
  try:
26
26
  subprocess.run([command, "--version"], capture_output=True, check=True)
27
27
  return True
28
- except (subprocess.CalledProcessError, FileNotFoundError):
28
+ except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
29
29
  return False
30
30
 
31
31
 
@@ -50,7 +50,7 @@ def detect_package_manager() -> str:
50
50
  try:
51
51
  subprocess.run([sys.executable, "-m", "pip", "--version"], capture_output=True, check=True)
52
52
  return "python -m pip"
53
- except (subprocess.CalledProcessError, FileNotFoundError):
53
+ except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
54
54
  pass
55
55
 
56
56
  raise PackageManagerNotFoundError("No suitable package manager found. Please install either uv or pip.")
@@ -449,21 +449,22 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
449
449
  file_import.add_import("json", ImportType.STDLIB)
450
450
  if self.enable_import_deserialize_xml:
451
451
  file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
452
- elif self.need_deserialize:
452
+ if any(
453
+ r.type
454
+ and not isinstance(r.type, BinaryIteratorType)
455
+ and not xml_serializable(str(r.default_content_type))
456
+ for r in self.responses
457
+ ):
453
458
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
454
459
  if self.default_error_deserialization(serialize_namespace) or self.non_default_errors:
455
- xml_non_default_errors = any(
456
- xml_serializable(str(e.default_content_type)) for e in self.non_default_errors
457
- )
458
460
  try:
459
461
  default_error = next(e for e in self.exceptions if "default" in e.status_codes and e.type)
460
462
  except StopIteration:
461
463
  default_error = None
462
- if xml_non_default_errors or (
463
- default_error and xml_serializable(str(default_error.default_content_type))
464
- ):
464
+ all_errors = list(self.non_default_errors) + ([default_error] if default_error else [])
465
+ if any(xml_serializable(str(e.default_content_type)) for e in all_errors):
465
466
  file_import.add_submodule_import(relative_path, "_failsafe_deserialize_xml", ImportType.LOCAL)
466
- else:
467
+ if any(not xml_serializable(str(e.default_content_type)) for e in all_errors):
467
468
  file_import.add_submodule_import(relative_path, "_failsafe_deserialize", ImportType.LOCAL)
468
469
  return file_import
469
470
 
@@ -109,10 +109,16 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
109
109
  if type_description:
110
110
  base_description = add_to_description(base_description, type_description)
111
111
  if self.optional and isinstance(self.type, ConstantType):
112
- base_description = add_to_description(
113
- base_description,
114
- f"Known values are {self.get_declaration()} and None.",
115
- )
112
+ if self.is_api_version:
113
+ base_description = add_to_description(
114
+ base_description,
115
+ f"Known values are {self.get_declaration()}.",
116
+ )
117
+ else:
118
+ base_description = add_to_description(
119
+ base_description,
120
+ f"Known values are {self.get_declaration()} and None.",
121
+ )
116
122
  if not (self.optional or self.client_default_value):
117
123
  base_description = add_to_description(base_description, "Required.")
118
124
  if self.client_default_value is not None:
@@ -449,21 +449,22 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
449
449
  file_import.add_import("json", ImportType.STDLIB)
450
450
  if self.enable_import_deserialize_xml:
451
451
  file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
452
- elif self.need_deserialize:
452
+ if any(
453
+ r.type
454
+ and not isinstance(r.type, BinaryIteratorType)
455
+ and not xml_serializable(str(r.default_content_type))
456
+ for r in self.responses
457
+ ):
453
458
  file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
454
459
  if self.default_error_deserialization(serialize_namespace) or self.non_default_errors:
455
- xml_non_default_errors = any(
456
- xml_serializable(str(e.default_content_type)) for e in self.non_default_errors
457
- )
458
460
  try:
459
461
  default_error = next(e for e in self.exceptions if "default" in e.status_codes and e.type)
460
462
  except StopIteration:
461
463
  default_error = None
462
- if xml_non_default_errors or (
463
- default_error and xml_serializable(str(default_error.default_content_type))
464
- ):
464
+ all_errors = list(self.non_default_errors) + ([default_error] if default_error else [])
465
+ if any(xml_serializable(str(e.default_content_type)) for e in all_errors):
465
466
  file_import.add_submodule_import(relative_path, "_failsafe_deserialize_xml", ImportType.LOCAL)
466
- else:
467
+ if any(not xml_serializable(str(e.default_content_type)) for e in all_errors):
467
468
  file_import.add_submodule_import(relative_path, "_failsafe_deserialize", ImportType.LOCAL)
468
469
  return file_import
469
470
 
@@ -109,10 +109,16 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
109
109
  if type_description:
110
110
  base_description = add_to_description(base_description, type_description)
111
111
  if self.optional and isinstance(self.type, ConstantType):
112
- base_description = add_to_description(
113
- base_description,
114
- f"Known values are {self.get_declaration()} and None.",
115
- )
112
+ if self.is_api_version:
113
+ base_description = add_to_description(
114
+ base_description,
115
+ f"Known values are {self.get_declaration()}.",
116
+ )
117
+ else:
118
+ base_description = add_to_description(
119
+ base_description,
120
+ f"Known values are {self.get_declaration()} and None.",
121
+ )
116
122
  if not (self.optional or self.client_default_value):
117
123
  base_description = add_to_description(base_description, "Required.")
118
124
  if self.client_default_value is not None:
@@ -16,17 +16,17 @@ async def client():
16
16
 
17
17
  @pytest.mark.asyncio
18
18
  async def test_client(client: NamingClient):
19
- await client.client(models.ClientNameModel(client_name=True))
19
+ await client.property.client(models.ClientNameModel(client_name=True))
20
20
 
21
21
 
22
22
  @pytest.mark.asyncio
23
23
  async def test_language(client: NamingClient):
24
- await client.language(models.LanguageClientNameModel(python_name=True))
24
+ await client.property.language(models.LanguageClientNameModel(python_name=True))
25
25
 
26
26
 
27
27
  @pytest.mark.asyncio
28
28
  async def test_compatible_with_encoded_name(client: NamingClient):
29
- await client.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
29
+ await client.property.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
30
30
 
31
31
 
32
32
  @pytest.mark.asyncio
@@ -41,12 +41,12 @@ async def test_parameter(client: NamingClient):
41
41
 
42
42
  @pytest.mark.asyncio
43
43
  async def test_header_request(client: NamingClient):
44
- await client.request(client_name="true")
44
+ await client.header.request(client_name="true")
45
45
 
46
46
 
47
47
  @pytest.mark.asyncio
48
48
  async def test_header_response(client: NamingClient):
49
- assert (await client.response(cls=lambda x, y, z: z))["default-name"] == "true"
49
+ assert (await client.header.response(cls=lambda x, y, z: z))["default-name"] == "true"
50
50
 
51
51
 
52
52
  @pytest.mark.asyncio
@@ -38,6 +38,7 @@ async def test_structure_multiclient():
38
38
  await client_b.renamed_six()
39
39
 
40
40
 
41
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
41
42
  @pytest.mark.asyncio
42
43
  async def test_structure_renamed_operation():
43
44
  client = RenamedOperationClient(endpoint="http://localhost:3000", client=ClientType.RENAMED_OPERATION)
@@ -45,18 +46,19 @@ async def test_structure_renamed_operation():
45
46
  await client.renamed_three()
46
47
  await client.renamed_five()
47
48
 
48
- await client.group.renamed_two()
49
- await client.group.renamed_four()
50
- await client.group.renamed_six()
49
+ await client.renamed_two()
50
+ await client.renamed_four()
51
+ await client.renamed_six()
51
52
 
52
53
 
54
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
53
55
  @pytest.mark.asyncio
54
56
  async def test_structure_two_operation_group():
55
- client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.RENAMED_OPERATION)
56
- await client.group1.one()
57
- await client.group1.three()
58
- await client.group1.four()
59
-
60
- await client.group2.two()
61
- await client.group2.five()
62
- await client.group2.six()
57
+ client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.TWO_OPERATION_GROUP)
58
+ await client.one()
59
+ await client.three()
60
+ await client.four()
61
+
62
+ await client.two()
63
+ await client.five()
64
+ await client.six()
@@ -8,22 +8,24 @@ from client.structure.clientoperationgroup.models import ClientType
8
8
  from client.structure.clientoperationgroup.aio import FirstClient, SecondClient
9
9
 
10
10
 
11
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
11
12
  @pytest.mark.asyncio
12
13
  async def test_first_client_operations():
13
14
  client = FirstClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
14
15
 
15
16
  await client.one()
16
17
 
17
- await client.group3.two()
18
- await client.group3.three()
18
+ await client.two()
19
+ await client.three()
19
20
 
20
- await client.group4.four()
21
+ await client.four()
21
22
 
22
23
 
24
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
23
25
  @pytest.mark.asyncio
24
26
  async def test_second_client_operations():
25
27
  client = SecondClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
26
28
 
27
29
  await client.five()
28
30
 
29
- await client.group5.six()
31
+ await client.six()
@@ -14,15 +14,15 @@ def client():
14
14
 
15
15
 
16
16
  def test_client(client: NamingClient):
17
- client.client(models.ClientNameModel(client_name=True))
17
+ client.property.client(models.ClientNameModel(client_name=True))
18
18
 
19
19
 
20
20
  def test_language(client: NamingClient):
21
- client.language(models.LanguageClientNameModel(python_name=True))
21
+ client.property.language(models.LanguageClientNameModel(python_name=True))
22
22
 
23
23
 
24
24
  def test_compatible_with_encoded_name(client: NamingClient):
25
- client.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
25
+ client.property.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
26
26
 
27
27
 
28
28
  def test_operation(client: NamingClient):
@@ -34,11 +34,11 @@ def test_parameter(client: NamingClient):
34
34
 
35
35
 
36
36
  def test_header_request(client: NamingClient):
37
- client.request(client_name="true")
37
+ client.header.request(client_name="true")
38
38
 
39
39
 
40
40
  def test_header_response(client: NamingClient):
41
- assert client.response(cls=lambda x, y, z: z)["default-name"] == "true"
41
+ assert client.header.response(cls=lambda x, y, z: z)["default-name"] == "true"
42
42
 
43
43
 
44
44
  def test_model_client(client: NamingClient):
@@ -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 pytest
6
7
  from client.structure.service.models import ClientType
7
8
  from client.structure.service import ServiceClient
8
9
  from client.structure.multiclient import ClientAClient, ClientBClient
@@ -35,23 +36,25 @@ def test_structure_multiclient():
35
36
  client_b.renamed_six()
36
37
 
37
38
 
39
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
38
40
  def test_structure_renamed_operation():
39
41
  client = RenamedOperationClient(endpoint="http://localhost:3000", client=ClientType.RENAMED_OPERATION)
40
42
  client.renamed_one()
41
43
  client.renamed_three()
42
44
  client.renamed_five()
43
45
 
44
- client.group.renamed_two()
45
- client.group.renamed_four()
46
- client.group.renamed_six()
46
+ client.renamed_two()
47
+ client.renamed_four()
48
+ client.renamed_six()
47
49
 
48
50
 
51
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
49
52
  def test_structure_two_operation_group():
50
53
  client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.TWO_OPERATION_GROUP)
51
- client.group1.one()
52
- client.group1.three()
53
- client.group1.four()
54
+ client.one()
55
+ client.three()
56
+ client.four()
54
57
 
55
- client.group2.two()
56
- client.group2.five()
57
- client.group2.six()
58
+ client.two()
59
+ client.five()
60
+ client.six()
@@ -3,24 +3,27 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
+ import pytest
6
7
  from client.structure.clientoperationgroup.models import ClientType
7
8
  from client.structure.clientoperationgroup import FirstClient, SecondClient
8
9
 
9
10
 
11
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
10
12
  def test_first_client_operations():
11
13
  client = FirstClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
12
14
 
13
15
  client.one()
14
16
 
15
- client.group3.two()
16
- client.group3.three()
17
+ client.two()
18
+ client.three()
17
19
 
18
- client.group4.four()
20
+ client.four()
19
21
 
20
22
 
23
+ @pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
21
24
  def test_second_client_operations():
22
25
  client = SecondClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
23
26
 
24
27
  client.five()
25
28
 
26
- client.group5.six()
29
+ client.six()
@@ -40,7 +40,6 @@ azure-mgmt-core==1.6.0
40
40
  -e ./generated/azure-resource-manager-resources
41
41
  -e ./generated/azure-resource-manager-method-subscription-id
42
42
  -e ./generated/azure-resource-manager-multi-service
43
- -e ./generated/azure-resource-manager-multi-service-older-versions
44
43
  -e ./generated/azure-resource-manager-multi-service-shared-models
45
44
  -e ./generated/azure-versioning-previewversion
46
45
  -e ./generated/client-namespace
@@ -5,6 +5,7 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import pytest
7
7
  from payload.pageable.aio import PageableClient
8
+ from payload.pageable.serverdrivenpagination.alternateinitialverb.models import Filter
8
9
 
9
10
 
10
11
  @pytest.fixture
@@ -125,3 +126,9 @@ async def test_xml_pagination_list_with_continuation(client: PageableClient):
125
126
  async def test_xml_pagination_list_with_next_link(client: PageableClient):
126
127
  result = [p async for p in client.xml_pagination.list_with_next_link()]
127
128
  assert_result(result)
129
+
130
+
131
+ @pytest.mark.asyncio
132
+ async def test_alternate_initial_verb_post(client: PageableClient):
133
+ result = [p async for p in client.server_driven_pagination.alternate_initial_verb.post(Filter(filter="foo eq bar"))]
134
+ assert_result(result)
@@ -138,6 +138,7 @@ async def test_model_with_datetime(client: XmlClient):
138
138
  result = await client.model_with_datetime_value.get()
139
139
  assert result.rfc3339 == model.rfc3339
140
140
  assert result.rfc7231 == model.rfc7231
141
+ await client.model_with_datetime_value.put(model)
141
142
 
142
143
 
143
144
  @pytest.mark.asyncio
@@ -5,6 +5,7 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import pytest
7
7
  from payload.pageable import PageableClient
8
+ from payload.pageable.serverdrivenpagination.alternateinitialverb.models import Filter
8
9
 
9
10
 
10
11
  @pytest.fixture
@@ -91,3 +92,8 @@ def test_xml_pagination_list_with_continuation(client: PageableClient):
91
92
  def test_xml_pagination_list_with_next_link(client: PageableClient):
92
93
  result = list(client.xml_pagination.list_with_next_link())
93
94
  assert_result(result)
95
+
96
+
97
+ def test_alternate_initial_verb_post(client: PageableClient):
98
+ result = list(client.server_driven_pagination.alternate_initial_verb.post(Filter(filter="foo eq bar")))
99
+ assert_result(result)
@@ -124,6 +124,7 @@ def test_model_with_datetime(client: XmlClient):
124
124
  result = client.model_with_datetime_value.get()
125
125
  assert result.rfc3339 == model.rfc3339
126
126
  assert result.rfc7231 == model.rfc7231
127
+ client.model_with_datetime_value.put(model)
127
128
 
128
129
 
129
130
  def test_xml_error_value(client: XmlClient, core_library):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-python",
3
- "version": "0.28.0",
3
+ "version": "0.28.2",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://typespec.io",
@@ -54,11 +54,11 @@
54
54
  "emitter"
55
55
  ],
56
56
  "peerDependencies": {
57
- "@azure-tools/typespec-autorest": ">=0.66.0 <1.0.0",
58
- "@azure-tools/typespec-azure-core": ">=0.66.0 <1.0.0",
57
+ "@azure-tools/typespec-autorest": ">=0.66.1 <1.0.0",
58
+ "@azure-tools/typespec-azure-core": ">=0.66.1 <1.0.0",
59
59
  "@azure-tools/typespec-azure-resource-manager": ">=0.66.0 <1.0.0",
60
- "@azure-tools/typespec-azure-rulesets": ">=0.65.1 <1.0.0",
61
- "@azure-tools/typespec-client-generator-core": ">=0.66.1 <1.0.0",
60
+ "@azure-tools/typespec-azure-rulesets": ">=0.66.0 <1.0.0",
61
+ "@azure-tools/typespec-client-generator-core": ">=0.66.4 <1.0.0",
62
62
  "@typespec/compiler": "^1.10.0",
63
63
  "@typespec/http": "^1.10.0",
64
64
  "@typespec/openapi": "^1.10.0",
@@ -77,12 +77,12 @@
77
77
  "tsx": "^4.21.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@azure-tools/typespec-autorest": "~0.66.0",
81
- "@azure-tools/typespec-azure-core": "~0.66.0",
80
+ "@azure-tools/typespec-autorest": "~0.66.1",
81
+ "@azure-tools/typespec-azure-core": "~0.66.1",
82
82
  "@azure-tools/typespec-azure-resource-manager": "~0.66.0",
83
- "@azure-tools/typespec-azure-rulesets": "~0.65.1",
84
- "@azure-tools/typespec-client-generator-core": "~0.66.1",
85
- "@azure-tools/azure-http-specs": "0.1.0-alpha.38",
83
+ "@azure-tools/typespec-azure-rulesets": "~0.66.0",
84
+ "@azure-tools/typespec-client-generator-core": "~0.66.4",
85
+ "@azure-tools/azure-http-specs": "0.1.0-alpha.39-dev.4",
86
86
  "@typespec/compiler": "^1.10.0",
87
87
  "@typespec/http": "^1.10.0",
88
88
  "@typespec/openapi": "^1.10.0",
@@ -90,11 +90,11 @@
90
90
  "@typespec/versioning": "~0.80.0",
91
91
  "@typespec/events": "~0.80.0",
92
92
  "@typespec/spector": "0.1.0-alpha.24",
93
- "@typespec/spec-api": "0.1.0-alpha.13",
93
+ "@typespec/spec-api": "0.1.0-alpha.14-dev.1",
94
94
  "@typespec/sse": "~0.80.0",
95
95
  "@typespec/streams": "~0.80.0",
96
96
  "@typespec/xml": "~0.80.0",
97
- "@typespec/http-specs": "0.1.0-alpha.34",
97
+ "@typespec/http-specs": "0.1.0-alpha.35",
98
98
  "@types/js-yaml": "~4.0.5",
99
99
  "@types/node": "~25.0.2",
100
100
  "@types/semver": "7.5.8",
@@ -1,111 +0,0 @@
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.multiserviceolderversions.combined.aio import CombinedClient
8
- from azure.resourcemanager.multiserviceolderversions.combined.models import (
9
- VirtualMachine,
10
- Disk,
11
- VirtualMachineProperties,
12
- DiskProperties,
13
- )
14
-
15
-
16
- @pytest.fixture
17
- async def client(credential, authentication_policy):
18
- """Create a Combined async client for testing."""
19
- return CombinedClient(
20
- credential=credential,
21
- subscription_id="00000000-0000-0000-0000-000000000000",
22
- base_url="http://localhost:3000",
23
- authentication_policy=authentication_policy,
24
- polling_interval=0.1,
25
- )
26
-
27
-
28
- @pytest.mark.asyncio
29
- async def test_virtual_machines_get(client):
30
- """Test getting a virtual machine."""
31
- resource_group_name = "test-rg"
32
- vm_name = "vm-old1"
33
-
34
- result = await client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name)
35
-
36
- assert result is not None
37
- assert isinstance(result, VirtualMachine)
38
- assert result.name == vm_name
39
- assert result.location == "eastus"
40
- assert result.properties is not None
41
- assert result.properties.provisioning_state == "Succeeded"
42
- assert result.properties.size == "Standard_D2s_v3"
43
-
44
-
45
- @pytest.mark.asyncio
46
- async def test_virtual_machines_create_or_update(client):
47
- """Test creating or updating a virtual machine."""
48
- resource_group_name = "test-rg"
49
- vm_name = "vm-old1"
50
-
51
- vm_resource = VirtualMachine(
52
- location="eastus",
53
- properties=VirtualMachineProperties(size="Standard_D2s_v3"),
54
- )
55
-
56
- poller = await client.virtual_machines.begin_create_or_update(
57
- resource_group_name=resource_group_name,
58
- vm_name=vm_name,
59
- resource=vm_resource,
60
- )
61
-
62
- result = await poller.result()
63
- assert result is not None
64
- assert isinstance(result, VirtualMachine)
65
- assert result.location == "eastus"
66
- assert result.properties is not None
67
- assert result.properties.provisioning_state == "Succeeded"
68
- assert result.properties.size == "Standard_D2s_v3"
69
-
70
-
71
- @pytest.mark.asyncio
72
- async def test_disks_get(client):
73
- """Test getting a disk."""
74
- resource_group_name = "test-rg"
75
- disk_name = "disk-old1"
76
-
77
- result = await client.disks.get(resource_group_name=resource_group_name, disk_name=disk_name)
78
-
79
- assert result is not None
80
- assert isinstance(result, Disk)
81
- assert result.name == disk_name
82
- assert result.location == "eastus"
83
- assert result.properties is not None
84
- assert result.properties.provisioning_state == "Succeeded"
85
- assert result.properties.disk_size_gb == 128
86
-
87
-
88
- @pytest.mark.asyncio
89
- async def test_disks_create_or_update(client):
90
- """Test creating or updating a disk."""
91
- resource_group_name = "test-rg"
92
- disk_name = "disk-old1"
93
-
94
- disk_resource = Disk(
95
- location="eastus",
96
- properties=DiskProperties(disk_size_gb=128),
97
- )
98
-
99
- poller = await client.disks.begin_create_or_update(
100
- resource_group_name=resource_group_name,
101
- disk_name=disk_name,
102
- resource=disk_resource,
103
- )
104
-
105
- result = await poller.result()
106
- assert result is not None
107
- assert isinstance(result, Disk)
108
- assert result.location == "eastus"
109
- assert result.properties is not None
110
- assert result.properties.provisioning_state == "Succeeded"
111
- assert result.properties.disk_size_gb == 128