Skip to content

Commit f16122a

Browse files
authored
test: enable test for import-from-apim (#54)
1 parent 51dd403 commit f16122a

16 files changed

+4907
-243
lines changed

src/apic-extension/azext_apic_extension/aaz/latest/apic/_list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
class List(AAZCommand):
1818
"""Lists Azure API Center services within an Azure subscription.
1919
20+
There is a known issue that listing all resources under a subscription does not work. Please list resources by resource group.
21+
2022
:example: List services in resource group
2123
az apic list -g contoso-resources
2224
"""
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
TEST_REGION = "eastus"

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_create_service.yaml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interactions:
77
Accept-Encoding:
88
- gzip, deflate
99
CommandName:
10-
- apic service create
10+
- apic create
1111
Connection:
1212
- keep-alive
1313
ParameterSetName:
@@ -18,16 +18,16 @@ interactions:
1818
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clirg000001?api-version=2022-09-01
1919
response:
2020
body:
21-
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001","name":"clirg000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"product":"azurecli","cause":"automation","test":"test_create_service","date":"2024-04-25T05:46:56Z","module":"apic-extension"},"properties":{"provisioningState":"Succeeded"}}'
21+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001","name":"clirg000001","type":"Microsoft.Resources/resourceGroups","location":"centralindia","tags":{"product":"azurecli","cause":"automation","test":"test_create_service","date":"2024-06-13T08:07:58Z","module":"apic-extension"},"properties":{"provisioningState":"Succeeded"}}'
2222
headers:
2323
cache-control:
2424
- no-cache
2525
content-length:
26-
- '355'
26+
- '361'
2727
content-type:
2828
- application/json; charset=utf-8
2929
date:
30-
- Thu, 25 Apr 2024 05:47:05 GMT
30+
- Thu, 13 Jun 2024 08:07:50 GMT
3131
expires:
3232
- '-1'
3333
pragma:
@@ -38,24 +38,26 @@ interactions:
3838
- CONFIG_NOCACHE
3939
x-content-type-options:
4040
- nosniff
41+
x-ms-ratelimit-remaining-subscription-global-reads:
42+
- '3749'
4143
x-msedge-ref:
42-
- 'Ref A: FE43C70CE25C4A45A1D2A1F80B75D642 Ref B: MAA201060515053 Ref C: 2024-04-25T05:47:05Z'
44+
- 'Ref A: BC701B122A3D472194FF75EF62232C56 Ref B: MAA201060514049 Ref C: 2024-06-13T08:07:50Z'
4345
status:
4446
code: 200
4547
message: OK
4648
- request:
47-
body: '{"location": "eastus"}'
49+
body: '{"location": "centralindia"}'
4850
headers:
4951
Accept:
5052
- application/json
5153
Accept-Encoding:
5254
- gzip, deflate
5355
CommandName:
54-
- apic service create
56+
- apic create
5557
Connection:
5658
- keep-alive
5759
Content-Length:
58-
- '22'
60+
- '28'
5961
Content-Type:
6062
- application/json
6163
ParameterSetName:
@@ -66,18 +68,18 @@ interactions:
6668
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002?api-version=2024-03-01
6769
response:
6870
body:
69-
string: '{"type":"Microsoft.ApiCenter/services","location":"eastus","sku":{"name":"None"},"properties":{"dataApiHostname":"cli000002.data.eastus.azure-apicenter.ms","provisioningState":"InProgress"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002","name":"cli000002","tags":{},"systemData":{"createdAt":"2024-04-25T05:47:09.4451661Z","lastModifiedAt":"2024-04-25T05:47:09.4451443Z"}}'
71+
string: '{"type":"Microsoft.ApiCenter/services","location":"centralindia","sku":{"name":"Free"},"properties":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002","name":"cli000002","tags":{},"systemData":{"createdAt":"2024-06-13T08:07:53.041409Z","lastModifiedAt":"2024-06-13T08:07:53.0413999Z"}}'
7072
headers:
7173
api-supported-versions:
7274
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
7375
cache-control:
7476
- no-cache
7577
content-length:
76-
- '460'
78+
- '372'
7779
content-type:
7880
- application/json; charset=utf-8
7981
date:
80-
- Thu, 25 Apr 2024 05:47:09 GMT
82+
- Thu, 13 Jun 2024 08:07:53 GMT
8183
expires:
8284
- '-1'
8385
pragma:
@@ -90,10 +92,12 @@ interactions:
9092
- CONFIG_NOCACHE
9193
x-content-type-options:
9294
- nosniff
95+
x-ms-ratelimit-remaining-subscription-global-writes:
96+
- '2999'
9397
x-ms-ratelimit-remaining-subscription-writes:
94-
- '1198'
98+
- '199'
9599
x-msedge-ref:
96-
- 'Ref A: FCC75A00C6FC415899D258A5FA326F29 Ref B: MAA201060513053 Ref C: 2024-04-25T05:47:07Z'
100+
- 'Ref A: 3145C9CB6D424A84B7BCAEF728947F23 Ref B: MAA201060515051 Ref C: 2024-06-13T08:07:51Z'
97101
x-powered-by:
98102
- ASP.NET
99103
status:

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_examples_import_all_apis_from_apim.yaml

Lines changed: 1201 additions & 0 deletions
Large diffs are not rendered by default.

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_examples_import_selected_apis_from_apim.yaml

Lines changed: 1098 additions & 0 deletions
Large diffs are not rendered by default.

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_import_from_apim.yaml

Lines changed: 1151 additions & 0 deletions
Large diffs are not rendered by default.

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_import_from_apim_for_multiple_apis.yaml

Lines changed: 1152 additions & 0 deletions
Large diffs are not rendered by default.

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_import_from_apim_for_one_api.yaml

Lines changed: 151 additions & 107 deletions
Large diffs are not rendered by default.

src/apic-extension/azext_apic_extension/tests/latest/test_api_commands.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer
77
from .utils import ApicServicePreparer, ApicApiPreparer, ApicMetadataPreparer
8+
from .constants import TEST_REGION
89

910
class ApiCommandsTests(ScenarioTest):
1011

11-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
12+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
1213
@ApicServicePreparer()
1314
def test_api_create(self):
1415
self.kwargs.update({
@@ -23,7 +24,7 @@ def test_api_create(self):
2324
self.check('externalDocumentation', [])
2425
])
2526

26-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
27+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
2728
@ApicServicePreparer()
2829
@ApicMetadataPreparer()
2930
def test_api_create_with_all_optional_params(self, metadata_name):
@@ -46,7 +47,7 @@ def test_api_create_with_all_optional_params(self, metadata_name):
4647
self.check('summary', 'summary')
4748
])
4849

49-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
50+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
5051
@ApicServicePreparer()
5152
@ApicApiPreparer()
5253
def test_api_show(self):
@@ -59,7 +60,7 @@ def test_api_show(self):
5960
self.check('externalDocumentation', [])
6061
])
6162

62-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
63+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
6364
@ApicServicePreparer()
6465
@ApicApiPreparer(parameter_name='api_id1')
6566
@ApicApiPreparer(parameter_name='api_id2')
@@ -70,7 +71,7 @@ def test_api_list(self, api_id1, api_id2):
7071
self.check('@[1].name', api_id2)
7172
])
7273

73-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
74+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
7475
@ApicServicePreparer()
7576
@ApicApiPreparer(parameter_name='api_id1')
7677
@ApicApiPreparer(parameter_name='api_id2')
@@ -83,15 +84,15 @@ def test_api_list_with_all_optional_params(self, api_id1):
8384
self.check('@[0].name', api_id1),
8485
])
8586

86-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
87+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
8788
@ApicServicePreparer()
8889
@ApicApiPreparer()
8990
def test_api_update(self):
9091
self.cmd('az apic api update -g {rg} -n {s} --api-id {api} --title "Echo API 2"', checks=[
9192
self.check('title', 'Echo API 2'),
9293
])
9394

94-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
95+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
9596
@ApicServicePreparer()
9697
@ApicApiPreparer()
9798
@ApicMetadataPreparer()
@@ -113,14 +114,14 @@ def test_api_update_with_all_optional_params(self, metadata_name):
113114
self.check('summary', 'summary')
114115
])
115116

116-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
117+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
117118
@ApicServicePreparer()
118119
@ApicApiPreparer()
119120
def test_api_delete(self):
120121
self.cmd('az apic api delete -g {rg} -n {s} --api-id {api} --yes')
121122
self.cmd('az apic api show -g {rg} -n {s} --api-id {api}', expect_failure=True)
122123

123-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
124+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
124125
@ApicServicePreparer()
125126
def test_examples_create_api(self):
126127
self.kwargs.update({
@@ -132,7 +133,7 @@ def test_examples_create_api(self):
132133
self.check('title', 'Echo API'),
133134
])
134135

135-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
136+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
136137
@ApicServicePreparer()
137138
@ApicMetadataPreparer()
138139
def test_examples_create_api_with_custom_properties(self, metadata_name):
@@ -147,14 +148,14 @@ def test_examples_create_api_with_custom_properties(self, metadata_name):
147148
self.check('customProperties.{}'.format(metadata_name), True),
148149
])
149150

150-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
151+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
151152
@ApicServicePreparer()
152153
@ApicApiPreparer()
153154
def test_examples_delete_api(self):
154155
self.cmd('az apic api delete -g {rg} -n {s} --api-id {api} --yes')
155156
self.cmd('az apic api show -g {rg} -n {s} --api-id {api}', expect_failure=True)
156157

157-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
158+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
158159
@ApicServicePreparer()
159160
@ApicApiPreparer(parameter_name='api_id1')
160161
@ApicApiPreparer(parameter_name='api_id2')
@@ -165,7 +166,7 @@ def test_examples_list_apis(self, api_id1, api_id2):
165166
self.check('@[1].name', api_id2)
166167
])
167168

168-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
169+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
169170
@ApicServicePreparer()
170171
@ApicApiPreparer()
171172
def test_examples_show_api_details(self):
@@ -175,15 +176,15 @@ def test_examples_show_api_details(self):
175176
self.check('title', 'Echo API'),
176177
])
177178

178-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
179+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
179180
@ApicServicePreparer()
180181
@ApicApiPreparer()
181182
def test_examples_update_api(self):
182183
self.cmd('az apic api update -g {rg} -n {s} --api-id {api} --summary "Basic REST API service"', checks=[
183184
self.check('summary', 'Basic REST API service'),
184185
])
185186

186-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
187+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
187188
@ApicServicePreparer()
188189
@ApicApiPreparer()
189190
@ApicMetadataPreparer()
@@ -195,7 +196,7 @@ def test_examples_update_custom_properties(self, metadata_name):
195196
self.check('customProperties.{}'.format(metadata_name), True),
196197
])
197198

198-
@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
199+
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
199200
@ApicServicePreparer()
200201
@ApicApiPreparer(parameter_name='api_id1')
201202
@ApicApiPreparer(parameter_name='api_id2')

0 commit comments

Comments
 (0)