Skip to content

Commit

Permalink
test: enable test for import-from-apim (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackchoey authored Jun 14, 2024
1 parent 51dd403 commit f16122a
Show file tree
Hide file tree
Showing 16 changed files with 4,907 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
class List(AAZCommand):
"""Lists Azure API Center services within an Azure subscription.
There is a known issue that listing all resources under a subscription does not work. Please list resources by resource group.
:example: List services in resource group
az apic list -g contoso-resources
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

TEST_REGION = "eastus"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interactions:
Accept-Encoding:
- gzip, deflate
CommandName:
- apic service create
- apic create
Connection:
- keep-alive
ParameterSetName:
Expand All @@ -18,16 +18,16 @@ interactions:
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clirg000001?api-version=2022-09-01
response:
body:
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"}}'
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"}}'
headers:
cache-control:
- no-cache
content-length:
- '355'
- '361'
content-type:
- application/json; charset=utf-8
date:
- Thu, 25 Apr 2024 05:47:05 GMT
- Thu, 13 Jun 2024 08:07:50 GMT
expires:
- '-1'
pragma:
Expand All @@ -38,24 +38,26 @@ interactions:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-reads:
- '3749'
x-msedge-ref:
- 'Ref A: FE43C70CE25C4A45A1D2A1F80B75D642 Ref B: MAA201060515053 Ref C: 2024-04-25T05:47:05Z'
- 'Ref A: BC701B122A3D472194FF75EF62232C56 Ref B: MAA201060514049 Ref C: 2024-06-13T08:07:50Z'
status:
code: 200
message: OK
- request:
body: '{"location": "eastus"}'
body: '{"location": "centralindia"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- apic service create
- apic create
Connection:
- keep-alive
Content-Length:
- '22'
- '28'
Content-Type:
- application/json
ParameterSetName:
Expand All @@ -66,18 +68,18 @@ interactions:
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002?api-version=2024-03-01
response:
body:
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"}}'
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"}}'
headers:
api-supported-versions:
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
cache-control:
- no-cache
content-length:
- '460'
- '372'
content-type:
- application/json; charset=utf-8
date:
- Thu, 25 Apr 2024 05:47:09 GMT
- Thu, 13 Jun 2024 08:07:53 GMT
expires:
- '-1'
pragma:
Expand All @@ -90,10 +92,12 @@ interactions:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-writes:
- '2999'
x-ms-ratelimit-remaining-subscription-writes:
- '1198'
- '199'
x-msedge-ref:
- 'Ref A: FCC75A00C6FC415899D258A5FA326F29 Ref B: MAA201060513053 Ref C: 2024-04-25T05:47:07Z'
- 'Ref A: 3145C9CB6D424A84B7BCAEF728947F23 Ref B: MAA201060515051 Ref C: 2024-06-13T08:07:51Z'
x-powered-by:
- ASP.NET
status:
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer
from .utils import ApicServicePreparer, ApicApiPreparer, ApicMetadataPreparer
from .constants import TEST_REGION

class ApiCommandsTests(ScenarioTest):

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
def test_api_create(self):
self.kwargs.update({
Expand All @@ -23,7 +24,7 @@ def test_api_create(self):
self.check('externalDocumentation', [])
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicMetadataPreparer()
def test_api_create_with_all_optional_params(self, metadata_name):
Expand All @@ -46,7 +47,7 @@ def test_api_create_with_all_optional_params(self, metadata_name):
self.check('summary', 'summary')
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
def test_api_show(self):
Expand All @@ -59,7 +60,7 @@ def test_api_show(self):
self.check('externalDocumentation', [])
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer(parameter_name='api_id1')
@ApicApiPreparer(parameter_name='api_id2')
Expand All @@ -70,7 +71,7 @@ def test_api_list(self, api_id1, api_id2):
self.check('@[1].name', api_id2)
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer(parameter_name='api_id1')
@ApicApiPreparer(parameter_name='api_id2')
Expand All @@ -83,15 +84,15 @@ def test_api_list_with_all_optional_params(self, api_id1):
self.check('@[0].name', api_id1),
])

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

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
@ApicMetadataPreparer()
Expand All @@ -113,14 +114,14 @@ def test_api_update_with_all_optional_params(self, metadata_name):
self.check('summary', 'summary')
])

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

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
def test_examples_create_api(self):
self.kwargs.update({
Expand All @@ -132,7 +133,7 @@ def test_examples_create_api(self):
self.check('title', 'Echo API'),
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicMetadataPreparer()
def test_examples_create_api_with_custom_properties(self, metadata_name):
Expand All @@ -147,14 +148,14 @@ def test_examples_create_api_with_custom_properties(self, metadata_name):
self.check('customProperties.{}'.format(metadata_name), True),
])

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

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer(parameter_name='api_id1')
@ApicApiPreparer(parameter_name='api_id2')
Expand All @@ -165,7 +166,7 @@ def test_examples_list_apis(self, api_id1, api_id2):
self.check('@[1].name', api_id2)
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
def test_examples_show_api_details(self):
Expand All @@ -175,15 +176,15 @@ def test_examples_show_api_details(self):
self.check('title', 'Echo API'),
])

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

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
@ApicMetadataPreparer()
Expand All @@ -195,7 +196,7 @@ def test_examples_update_custom_properties(self, metadata_name):
self.check('customProperties.{}'.format(metadata_name), True),
])

@ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32)
@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer(parameter_name='api_id1')
@ApicApiPreparer(parameter_name='api_id2')
Expand Down
Loading

0 comments on commit f16122a

Please sign in to comment.