Skip to content

Commit 756b056

Browse files
Fix up some broken tests
1 parent a7027a9 commit 756b056

23 files changed

+17994
-1311
lines changed

src/azure-cli/azure/cli/command_modules/resource/_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import re
77
import json
8+
from azure.core.exceptions import HttpResponseError
89

910
_management_group_pattern = (
1011
r"^\/?providers\/Microsoft.Management\/managementGroups\/(?P<management_group_id>[\w\d_\.\(\)-]+)"
@@ -87,7 +88,10 @@ def _build_preflight_error_message(preflight_error):
8788

8889

8990
def _build_http_response_error_message(http_error):
90-
error_txt = http_error.response.internal_response.text
91+
if not isinstance(http_error, HttpResponseError):
92+
raise TypeError("http_error must be an instance of HttpResponseError")
93+
94+
error_txt = http_error.response.text()
9195

9296
error_info = json.loads(error_txt)['error']
9397
error_details = error_info.pop('details') if 'details' in error_info else []

src/azure-cli/azure/cli/command_modules/resource/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ def load_command_table(self, _):
158158
)
159159

160160
resource_deployment_sdk = CliCommandType(
161-
operations_tmpl='azure.mgmt.resource.resources.operations#DeploymentsOperations.{}',
161+
operations_tmpl='azure.mgmt.resource.deployments.operations#DeploymentsOperations.{}',
162162
client_factory=cf_deployments,
163163
resource_type=ResourceType.MGMT_RESOURCE_DEPLOYMENTS
164164
)
165165

166166
resource_deployment_operation_sdk = CliCommandType(
167-
operations_tmpl='azure.mgmt.resource.resources.operations#DeploymentOperationsOperations.{}',
167+
operations_tmpl='azure.mgmt.resource.deployments.operations#DeploymentOperationsOperations.{}',
168168
client_factory=cf_deployment_operations,
169169
resource_type=ResourceType.MGMT_RESOURCE_DEPLOYMENTS
170170
)

src/azure-cli/azure/cli/command_modules/resource/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def _deploy_arm_template_at_management_group(cmd,
729729
deployment = ScopedDeployment(properties=deployment_properties, location=deployment_location)
730730
try:
731731
validation_poller = mgmt_client.begin_validate_at_management_group_scope(management_group_id,
732-
deployment_name, deployment)
732+
deployment_name, deployment)
733733
except HttpResponseError as err:
734734
err_message = _build_http_response_error_message(err)
735735
raise_subdivision_deployment_error(err_message, err.error.code if err.error else None)
@@ -809,7 +809,7 @@ def _deploy_arm_template_at_tenant_scope(cmd,
809809
deployment = ScopedDeployment(properties=deployment_properties, location=deployment_location)
810810
try:
811811
validation_poller = mgmt_client.begin_validate_at_tenant_scope(deployment_name=deployment_name,
812-
parameters=deployment)
812+
parameters=deployment)
813813
except HttpResponseError as err:
814814
err_message = _build_http_response_error_message(err)
815815
raise_subdivision_deployment_error(err_message, err.error.code if err.error else None)
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
33
"contentVersion": "1.0.0.0",
4-
"parameters": {
5-
"nestedsubId": {
6-
"value": "0b1f6471-1bf0-4dda-aec3-cb9272f09590"
7-
}
8-
}
4+
"parameters": {}
95
}

src/azure-cli/azure/cli/command_modules/resource/tests/latest/management_group_level_template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"targetMG": {
66
"type": "string"
77
},
8-
"nestedsubId": {
8+
"nestedSubId": {
99
"type": "string"
1010
},
1111
"nestedRG": {
@@ -72,7 +72,7 @@
7272
"type": "Microsoft.Resources/resourceGroups",
7373
"name": "[parameters('nestedRG')]",
7474
"apiVersion": "2018-05-01",
75-
"location": "East US 2 EUAP",
75+
"location": "West US",
7676
"properties": {
7777

7878
}

src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_deployment_stack_resource_group.yaml

Lines changed: 3906 additions & 305 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_deployment_stack_subscription.yaml

Lines changed: 3831 additions & 418 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_template_specs.yaml

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interactions:
2929
content-type:
3030
- application/json; charset=utf-8
3131
date:
32-
- Fri, 20 Jun 2025 17:06:53 GMT
32+
- Mon, 23 Jun 2025 13:15:30 GMT
3333
expires:
3434
- '-1'
3535
pragma:
@@ -43,7 +43,7 @@ interactions:
4343
x-ms-failure-cause:
4444
- gateway
4545
x-msedge-ref:
46-
- 'Ref A: C5AAD8346AC3473F8EB606DB451C8611 Ref B: BN1AA2051013017 Ref C: 2025-06-20T17:06:53Z'
46+
- 'Ref A: D628529BCDDC460DBCA3C04ECB6F7AD2 Ref B: BN1AA2051013025 Ref C: 2025-06-23T13:15:30Z'
4747
status:
4848
code: 404
4949
message: Not Found
@@ -77,7 +77,7 @@ interactions:
7777
content-type:
7878
- application/json; charset=utf-8
7979
date:
80-
- Fri, 20 Jun 2025 17:06:53 GMT
80+
- Mon, 23 Jun 2025 13:15:30 GMT
8181
expires:
8282
- '-1'
8383
pragma:
@@ -91,7 +91,7 @@ interactions:
9191
x-ms-failure-cause:
9292
- gateway
9393
x-msedge-ref:
94-
- 'Ref A: 6A76C2457EE249B7A68B2430D3718FE8 Ref B: BN1AA2051013029 Ref C: 2025-06-20T17:06:53Z'
94+
- 'Ref A: E5F1C1BA263C4F7A9FCEF58E7E8CA626 Ref B: BN1AA2051015045 Ref C: 2025-06-23T13:15:30Z'
9595
status:
9696
code: 404
9797
message: Not Found
@@ -121,20 +121,21 @@ interactions:
121121
body:
122122
string: "{\r\n \"location\": \"westus\",\r\n \"tags\": {},\r\n \"properties\":
123123
{\r\n \"description\": \"AzCLI test root template spec\"\r\n },\r\n \"systemData\":
124-
{\r\n \"createdBy\": \"test@example.com\",\r\n \"createdByType\": \"User\",\r\n
125-
\ \"createdAt\": \"2025-06-20T17:06:54.7552142Z\",\r\n \"lastModifiedBy\":
126-
\"test@example.com\",\r\n \"lastModifiedByType\": \"User\",\r\n \"lastModifiedAt\":
127-
\"2025-06-20T17:06:54.7552142Z\"\r\n },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002\",\r\n
124+
{\r\n \"createdBy\": \"anthony.ct.martin@gmail.com\",\r\n \"createdByType\":
125+
\"User\",\r\n \"createdAt\": \"2025-06-23T13:15:32.0669075Z\",\r\n \"lastModifiedBy\":
126+
\"anthony.ct.martin@gmail.com\",\r\n \"lastModifiedByType\": \"User\",\r\n
127+
\ \"lastModifiedAt\": \"2025-06-23T13:15:32.0669075Z\"\r\n },\r\n \"id\":
128+
\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002\",\r\n
128129
\ \"type\": \"Microsoft.Resources/templateSpecs\",\r\n \"name\": \"cli-test-create-template-spec000002\"\r\n}"
129130
headers:
130131
cache-control:
131132
- no-cache
132133
content-length:
133-
- '682'
134+
- '704'
134135
content-type:
135136
- application/json; charset=utf-8
136137
date:
137-
- Fri, 20 Jun 2025 17:06:54 GMT
138+
- Mon, 23 Jun 2025 13:15:31 GMT
138139
expires:
139140
- '-1'
140141
pragma:
@@ -146,13 +147,13 @@ interactions:
146147
x-content-type-options:
147148
- nosniff
148149
x-ms-operation-identifier:
149-
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=83cb6ceb-42ff-4c0f-9239-2afb8f90086a/eastus/a3bfaa15-2469-4028-b54a-14da233fc8a3
150+
- tenantId=3f371d31-f8f9-4ac4-9950-b5c4ff5bbb3d,objectId=880dfe77-3cbb-4d27-b0cf-0052ba153f33/eastus/0b785bcc-fe0a-42d4-9a86-254835f0020b
150151
x-ms-ratelimit-remaining-subscription-global-writes:
151-
- '11999'
152+
- '2999'
152153
x-ms-ratelimit-remaining-subscription-writes:
153-
- '799'
154+
- '199'
154155
x-msedge-ref:
155-
- 'Ref A: 79FE0763406B4D1AA91B4A29CEEA0371 Ref B: BN1AA2051015021 Ref C: 2025-06-20T17:06:54Z'
156+
- 'Ref A: 6C0BF96198A846D5A472521BF3B7239C Ref B: BN1AA2051012037 Ref C: 2025-06-23T13:15:30Z'
156157
status:
157158
code: 201
158159
message: Created
@@ -371,21 +372,22 @@ interactions:
371372
''))]\"\r\n },\r\n \"resources\": [],\r\n \"outputs\": {\r\n
372373
\ \"name\": {\r\n \"type\": \"string\",\r\n \"value\":
373374
\"[toLower(variables('name'))]\"\r\n }\r\n }\r\n }\r\n },\r\n
374-
\ \"systemData\": {\r\n \"createdBy\": \"test@example.com\",\r\n \"createdByType\":
375-
\"User\",\r\n \"createdAt\": \"2025-06-20T17:06:57.1197197Z\",\r\n \"lastModifiedBy\":
376-
\"test@example.com\",\r\n \"lastModifiedByType\": \"User\",\r\n \"lastModifiedAt\":
377-
\"2025-06-20T17:06:57.1197197Z\"\r\n },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002/versions/1.0\",\r\n
375+
\ \"systemData\": {\r\n \"createdBy\": \"anthony.ct.martin@gmail.com\",\r\n
376+
\ \"createdByType\": \"User\",\r\n \"createdAt\": \"2025-06-23T13:15:33.2532932Z\",\r\n
377+
\ \"lastModifiedBy\": \"anthony.ct.martin@gmail.com\",\r\n \"lastModifiedByType\":
378+
\"User\",\r\n \"lastModifiedAt\": \"2025-06-23T13:15:33.2532932Z\"\r\n
379+
\ },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002/versions/1.0\",\r\n
378380
\ \"type\": \"Microsoft.Resources/templateSpecs/versions\",\r\n \"name\":
379381
\"1.0\"\r\n}"
380382
headers:
381383
cache-control:
382384
- no-cache
383385
content-length:
384-
- '10056'
386+
- '10078'
385387
content-type:
386388
- application/json; charset=utf-8
387389
date:
388-
- Fri, 20 Jun 2025 17:06:56 GMT
390+
- Mon, 23 Jun 2025 13:15:33 GMT
389391
expires:
390392
- '-1'
391393
pragma:
@@ -397,14 +399,64 @@ interactions:
397399
x-content-type-options:
398400
- nosniff
399401
x-ms-operation-identifier:
400-
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=83cb6ceb-42ff-4c0f-9239-2afb8f90086a/eastus/94a3503d-fbd2-441e-b76c-dd35bfc406d7
402+
- tenantId=3f371d31-f8f9-4ac4-9950-b5c4ff5bbb3d,objectId=880dfe77-3cbb-4d27-b0cf-0052ba153f33/eastus/e7e0bd1d-b671-45d5-9409-b0ce7d67e5f9
401403
x-ms-ratelimit-remaining-subscription-global-writes:
402-
- '11999'
404+
- '2999'
403405
x-ms-ratelimit-remaining-subscription-writes:
404-
- '799'
406+
- '199'
405407
x-msedge-ref:
406-
- 'Ref A: 2B9305DE0EC84A7AA9A74C3F08241824 Ref B: BN1AA2051014051 Ref C: 2025-06-20T17:06:55Z'
408+
- 'Ref A: A5508F236D894B0C90522549D0A6B294 Ref B: BN1AA2051012019 Ref C: 2025-06-23T13:15:32Z'
407409
status:
408410
code: 201
409411
message: Created
412+
- request:
413+
body: null
414+
headers:
415+
Accept:
416+
- application/json
417+
Accept-Encoding:
418+
- gzip, deflate
419+
CommandName:
420+
- ts delete
421+
Connection:
422+
- keep-alive
423+
Content-Length:
424+
- '0'
425+
ParameterSetName:
426+
- --template-spec --yes
427+
User-Agent:
428+
- AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.1 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.31)
429+
method: DELETE
430+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002?api-version=2022-02-01
431+
response:
432+
body:
433+
string: ''
434+
headers:
435+
cache-control:
436+
- no-cache
437+
content-length:
438+
- '0'
439+
date:
440+
- Mon, 23 Jun 2025 13:15:35 GMT
441+
expires:
442+
- '-1'
443+
pragma:
444+
- no-cache
445+
strict-transport-security:
446+
- max-age=31536000; includeSubDomains
447+
x-cache:
448+
- CONFIG_NOCACHE
449+
x-content-type-options:
450+
- nosniff
451+
x-ms-operation-identifier:
452+
- tenantId=3f371d31-f8f9-4ac4-9950-b5c4ff5bbb3d,objectId=880dfe77-3cbb-4d27-b0cf-0052ba153f33/eastus/d3f421bc-9563-4502-9beb-7ad2c70df903
453+
x-ms-ratelimit-remaining-subscription-deletes:
454+
- '199'
455+
x-ms-ratelimit-remaining-subscription-global-deletes:
456+
- '2999'
457+
x-msedge-ref:
458+
- 'Ref A: CA08CBD56C914612B258CC796EBA419E Ref B: BN1AA2051015019 Ref C: 2025-06-23T13:15:33Z'
459+
status:
460+
code: 200
461+
message: OK
410462
version: 1

0 commit comments

Comments
 (0)