diff --git a/src/plugins/azgenerator/TemplateAzureCliActions.ts b/src/plugins/azgenerator/TemplateAzureCliActions.ts index 602c1791d..88c16aa52 100644 --- a/src/plugins/azgenerator/TemplateAzureCliActions.ts +++ b/src/plugins/azgenerator/TemplateAzureCliActions.ts @@ -84,8 +84,6 @@ function GetAction(model: CodeModelAz, actionName: string, param: Parameter, key } else { output.push(" namespace." + model.Parameter_MapsTo(param) + " = action"); } - - output.push(""); output.push(""); output.push(" def get_action(self, values, option_string): # pylint: disable=no-self-use"); output.push(" try:"); diff --git a/src/plugins/azgenerator/TemplateAzureCliCustom.ts b/src/plugins/azgenerator/TemplateAzureCliCustom.ts index 348ed23d8..b0ee6cf33 100644 --- a/src/plugins/azgenerator/TemplateAzureCliCustom.ts +++ b/src/plugins/azgenerator/TemplateAzureCliCustom.ts @@ -167,9 +167,9 @@ function GetSingleCommandDef(model: CodeModelAz, required: any, originalOperatio let call = "def " + updatedMethodName + "("; let indent = " ".repeat(call.length); if (needGeneric) { - call += "instance, cmd"; + call += "instance"; } else { - call += "cmd, client"; + call += "client"; } output.push(call); diff --git a/src/plugins/azgenerator/TemplateAzureCliInit.ts b/src/plugins/azgenerator/TemplateAzureCliInit.ts index 7198ddfda..b8d36383d 100644 --- a/src/plugins/azgenerator/TemplateAzureCliInit.ts +++ b/src/plugins/azgenerator/TemplateAzureCliInit.ts @@ -5,6 +5,7 @@ import { CodeModelAz } from "./CodeModelAz" import { HeaderGenerator } from "./Header"; +import { ToMultiLine } from "../../utils/helper" export function GenerateAzureCliInit(model: CodeModelAz) : string[] { let header: HeaderGenerator = new HeaderGenerator(); @@ -22,9 +23,8 @@ export function GenerateAzureCliInit(model: CodeModelAz) : string[] { output.push(" " + model.Extension_NameUnderscored + "_custom = CliCommandType("); output.push(" operations_tmpl='azext_" + model.Extension_NameUnderscored + ".custom#{}',"); output.push(" client_factory=cf_" + model.Extension_NameUnderscored + ")"); - let pfx = " super(" + model.Extension_NameClass + "CommandsLoader, self).__init__("; - output.push(pfx + "cli_ctx=cli_ctx,"); - output.push(" ".repeat(pfx.length) + "custom_command_type=" + model.Extension_NameUnderscored + "_custom)"); + output.push(` parent = super(${model.Extension_NameClass}CommandsLoader, self)`); + ToMultiLine(` parent.__init__(cli_ctx=cli_ctx, custom_command_type=${model.Extension_NameUnderscored}_custom)`, output); output.push(""); output.push(" def load_command_table(self, args):"); output.push(" from azext_" + model.Extension_NameUnderscored + ".generated.commands import load_command_table"); diff --git a/src/plugins/azgenerator/TemplateAzureCliParams.ts b/src/plugins/azgenerator/TemplateAzureCliParams.ts index b7b6303b3..7c0029b2f 100644 --- a/src/plugins/azgenerator/TemplateAzureCliParams.ts +++ b/src/plugins/azgenerator/TemplateAzureCliParams.ts @@ -13,7 +13,7 @@ import { isNullOrUndefined, isArray } from "util"; let hasActions: boolean = false; let hasBoolean: boolean = false; let hasEnum: boolean = false; -let hasJson: boolean = true; +let hasJson: boolean = false; let hasResourceGroup: boolean = false; let hasLocation = false; let hasLocationValidator = false; diff --git a/src/plugins/azgenerator/TemplateAzureCliTestInit.ts b/src/plugins/azgenerator/TemplateAzureCliTestInit.ts index c997e3524..191cf6514 100644 --- a/src/plugins/azgenerator/TemplateAzureCliTestInit.ts +++ b/src/plugins/azgenerator/TemplateAzureCliTestInit.ts @@ -22,6 +22,8 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] { output.push("import os"); output.push("import sys"); output.push("import traceback"); + output.push("from azure.core.exceptions import AzureError"); + output.push("from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError"); output.push(""); output.push(""); output.push("__path__ = __import__('pkgutil').extend_path(__path__, __name__)"); @@ -57,7 +59,7 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] { output.push(' print("running {}()...".format(func.__name__))'); output.push(' try:'); output.push(' return func_to_call(*args, **kwargs)'); - output.push(' except BaseException as e:'); + output.push(' except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e:'); output.push(' print("--------------------------------------")'); output.push(' print("step exception: ", e)'); output.push(' print("--------------------------------------", file=sys.stderr)'); @@ -67,8 +69,7 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] { output.push(''); output.push(' if inspect.isclass(func):'); output.push(' return get_func_to_call()'); - output.push(' else:'); - output.push(' return wrapper'); + output.push(' return wrapper'); output.push(''); output.push(''); output.push('def raise_if():'); diff --git a/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts b/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts index 6aa2ffc63..86a3ccb53 100644 --- a/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts +++ b/src/plugins/azgenerator/TemplateAzureCliTestPrepare.ts @@ -7,8 +7,8 @@ export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { output.push(""); output.push("import os"); output.push("from datetime import datetime"); - output.push("from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer"); output.push("from azure_devtools.scenario_tests import SingleValueReplacer"); + output.push("from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer"); output.push("from azure.cli.testsdk.exceptions import CliTestError"); output.push("from azure.cli.testsdk.reverse_dependency import get_dummy_cli"); output.push(""); @@ -38,7 +38,7 @@ export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { output.push(" self.resource_group_key = resource_group_key"); output.push(" self.dev_setting_name = os.environ.get(dev_setting_name, None)"); output.push(""); - output.push(" def create_resource(self, name, **kwargs):"); + output.push(" def create_resource(self, name, **_):"); output.push(" if self.dev_setting_name:"); output.push(" return {self.parameter_name: self.dev_setting_name, }"); output.push(""); @@ -61,50 +61,46 @@ export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { output.push(" self.test_class_instance.kwargs[self.key] = name"); output.push(" return {self.parameter_name: name}"); output.push(""); - output.push(" def remove_resource(self, name, **kwargs):"); + output.push(" def remove_resource(self, name, **_):"); output.push(" # delete vnet if test is being recorded and if the vnet is not a dev rg"); output.push(" if not self.dev_setting_name:"); output.push(" self.live_only_execute("); - output.push(" self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name))"); + output.push(" self.cli_ctx,"); + output.push(" 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name))"); output.push(""); output.push(""); output.push("class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer):"); output.push(" def __init__(self, name_prefix='clitest.vn',"); output.push(" parameter_name='subnet',"); - output.push(" resource_group_name=None,"); output.push(" resource_group_key=KEY_RESOURCE_GROUP,"); - output.push(" vnet_name=None,"); output.push(" vnet_key=KEY_VIRTUAL_NETWORK,"); output.push(" address_prefixes=\"11.0.0.0/24\","); output.push(" dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME',"); - output.push(" random_name_length=24, key=KEY_VNET_SUBNET):"); + output.push(" key=KEY_VNET_SUBNET):"); output.push(" if ' ' in name_prefix:"); output.push(" raise CliTestError("); output.push(" 'Error: Space character in name prefix \\'%s\\'' % name_prefix)"); - output.push(" super(VnetSubnetPreparer, self).__init__("); - output.push(" name_prefix, random_name_length)"); + output.push(" super(VnetSubnetPreparer, self).__init__(name_prefix, 15)"); output.push(" self.cli_ctx = get_dummy_cli()"); output.push(" self.parameter_name = parameter_name"); output.push(" self.key = key"); - output.push(" self.resource_group_name = resource_group_name"); - output.push(" self.resource_group_key = resource_group_key"); - output.push(" self.vnet_name = vnet_name"); - output.push(" self.vnet_key = vnet_key"); + output.push(" self.resource_group = [resource_group_key, None]"); + output.push(" self.vnet = [vnet_key, None]"); output.push(" self.address_prefixes = address_prefixes"); output.push(" self.dev_setting_name = os.environ.get(dev_setting_name, None)"); output.push(""); - output.push(" def create_resource(self, name, **kwargs):"); + output.push(" def create_resource(self, name, **_):"); output.push(" if self.dev_setting_name:"); output.push(" return {self.parameter_name: self.dev_setting_name, }"); output.push(""); - output.push(" if not self.resource_group_name:"); - output.push(" self.resource_group_name = self.test_class_instance.kwargs.get("); - output.push(" self.resource_group_key)"); - output.push(" if not self.resource_group_name:"); + output.push(" if not self.resource_group[1]:"); + output.push(" self.resource_group[1] = self.test_class_instance.kwargs.get("); + output.push(" self.resource_group[0])"); + output.push(" if not self.resource_group[1]:"); output.push(" raise CliTestError(\"Error: No resource group configured!\")"); - output.push(" if not self.vnet_name:"); - output.push(" self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key)"); - output.push(" if not self.vnet_name:"); + output.push(" if not self.vnet[1]:"); + output.push(" self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0])"); + output.push(" if not self.vnet[1]:"); output.push(" raise CliTestError(\"Error: No vnet configured!\")"); output.push(""); // output.push(" # tags = {'product': 'azurecli', 'cause': 'automation',"); @@ -122,7 +118,7 @@ export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { output.push(" self.test_class_instance.kwargs[self.key] = 'default'"); output.push(" return {self.parameter_name: name}"); output.push(""); - output.push(" def remove_resource(self, name, **kwargs):"); + output.push(" def remove_resource(self, name, **_):"); output.push(" pass"); // output.push(" # delete vnet if test is being recorded and if the vnet is not a dev rg"); // output.push(" if not self.dev_setting_name:"); @@ -132,55 +128,51 @@ export function GenerateAzureCliTestPrepare(model: CodeModelAz): string[] { // output.push(" name, self.resource_group_name,"); // output.push(" self.vnet_name))"); output.push(""); + output.push(""); output.push("class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer):"); output.push(" def __init__(self, name_prefix='clitest.nic',"); output.push(" parameter_name='subnet',"); - output.push(" resource_group_name=None,"); output.push(" resource_group_key=KEY_RESOURCE_GROUP,"); - output.push(" vnet_name=None,"); output.push(" vnet_key=KEY_VIRTUAL_NETWORK,"); output.push(" dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME',"); - output.push(" random_name_length=15, key=KEY_VNET_NIC):"); + output.push(" key=KEY_VNET_NIC):"); output.push(" if ' ' in name_prefix:"); output.push(" raise CliTestError("); output.push(" 'Error: Space character in name prefix \\'%s\\'' % name_prefix)"); - output.push(" super(VnetNicPreparer, self).__init__("); - output.push(" name_prefix, random_name_length)"); + output.push(" super(VnetNicPreparer, self).__init__(name_prefix, 15)"); output.push(" self.cli_ctx = get_dummy_cli()"); output.push(" self.parameter_name = parameter_name"); output.push(" self.key = key"); - output.push(" self.resource_group_name = resource_group_name"); - output.push(" self.resource_group_key = resource_group_key"); - output.push(" self.vnet_name = vnet_name"); - output.push(" self.vnet_key = vnet_key"); + output.push(" self.resource_group = [resource_group_key, None]"); + output.push(" self.vnet = [vnet_key, None]"); output.push(" self.dev_setting_name = os.environ.get(dev_setting_name, None)"); output.push(""); - output.push(" def create_resource(self, name, **kwargs):"); + output.push(" def create_resource(self, name, **_):"); output.push(" if self.dev_setting_name:"); output.push(" return {self.parameter_name: self.dev_setting_name, }"); output.push(""); - output.push(" if not self.resource_group_name:"); - output.push(" self.resource_group_name = self.test_class_instance.kwargs.get("); - output.push(" self.resource_group_key)"); - output.push(" if not self.resource_group_name:"); + output.push(" if not self.resource_group[1]:"); + output.push(" self.resource_group[1] = self.test_class_instance.kwargs.get("); + output.push(" self.resource_group[0])"); + output.push(" if not self.resource_group[1]:"); output.push(" raise CliTestError(\"Error: No resource group configured!\")"); - output.push(" if not self.vnet_name:"); - output.push(" self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key)"); - output.push(" if not self.vnet_name:"); + output.push(" if not self.vnet[1]:"); + output.push(" self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0])"); + output.push(" if not self.vnet[1]:"); output.push(" raise CliTestError(\"Error: No vnet configured!\")"); output.push(""); output.push(" template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default '"); output.push(" self.live_only_execute(self.cli_ctx, template.format("); - output.push(" self.resource_group_name, name, self.vnet_name))"); + output.push(" self.resource_group[1], name, self.vnet[1]))"); output.push(""); output.push(" self.test_class_instance.kwargs[self.key] = name"); output.push(" return {self.parameter_name: name}"); output.push(""); - output.push(" def remove_resource(self, name, **kwargs):"); + output.push(" def remove_resource(self, name, **_):"); output.push(" if not self.dev_setting_name:"); output.push(" self.live_only_execute("); output.push(" self.cli_ctx,"); - output.push(" 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group_name))"); + output.push(" 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1]))"); output.push(""); return output; } diff --git a/src/plugins/azgenerator/TemplateAzureCliValidators.ts b/src/plugins/azgenerator/TemplateAzureCliValidators.ts index 2f15c75a6..c33433bbb 100644 --- a/src/plugins/azgenerator/TemplateAzureCliValidators.ts +++ b/src/plugins/azgenerator/TemplateAzureCliValidators.ts @@ -10,8 +10,6 @@ export function GenerateAzureCliValidators(model: CodeModelAz) : string[] { let header: HeaderGenerator = new HeaderGenerator(); var output: string[] = header.getLines(); - output.push(""); - output.push(""); output.push(""); return output; diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/__init__.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/__init__.py index d2740c05b..b2beb8a4a 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/__init__.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/__init__.py @@ -20,8 +20,8 @@ def __init__(self, cli_ctx=None): attestation_custom = CliCommandType( operations_tmpl='azext_attestation.custom#{}', client_factory=cf_attestation) - super(AttestationManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=attestation_custom) + parent = super(AttestationManagementClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=attestation_custom) def load_command_table(self, args): from azext_attestation.generated.commands import load_command_table diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_params.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_params.py index bacbe05ec..6843aebd3 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_params.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_params.py @@ -10,7 +10,6 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from knack.arguments import CLIArgumentType from azure.cli.core.commands.parameters import ( tags_type, resource_group_name_type, diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_validators.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_validators.py index a042a9ab7..e5ac78386 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_validators.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/_validators.py @@ -7,5 +7,3 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- - - diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/action.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/action.py index 2b6352ea9..aa2eb0f64 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/action.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/action.py @@ -19,7 +19,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddPolicySigningCertificatesKeys, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py index 1b5288dad..dc5294103 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/generated/custom.py @@ -10,7 +10,7 @@ # pylint: disable=too-many-lines -def attestation_create_provider(cmd, client, +def attestation_create_provider(client, resource_group_name, provider_name, location, @@ -25,25 +25,25 @@ def attestation_create_provider(cmd, client, keys=policy_signing_certificates_keys) -def attestation_list_operation(cmd, client): +def attestation_list_operation(client): return client.list() -def attestation_attestation_provider_provider_list(cmd, client, +def attestation_attestation_provider_provider_list(client, resource_group_name=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name) return client.list() -def attestation_attestation_provider_show(cmd, client, +def attestation_attestation_provider_show(client, resource_group_name, provider_name): return client.get(resource_group_name=resource_group_name, provider_name=provider_name) -def attestation_attestation_provider_update(cmd, client, +def attestation_attestation_provider_update(client, resource_group_name, provider_name, tags=None): @@ -52,7 +52,7 @@ def attestation_attestation_provider_update(cmd, client, tags=tags) -def attestation_attestation_provider_delete(cmd, client, +def attestation_attestation_provider_delete(client, resource_group_name, provider_name): return client.delete(resource_group_name=resource_group_name, diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/__init__.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/__init__.py index 9da5edeae..5f8f1fd97 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/__init__.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/__init__.py @@ -12,6 +12,8 @@ import os import sys import traceback +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError __path__ = __import__('pkgutil').extend_path(__path__, __name__) @@ -47,7 +49,7 @@ def wrapper(*args, **kwargs): print("running {}()...".format(func.__name__)) try: return func_to_call(*args, **kwargs) - except BaseException as e: + except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e: print("--------------------------------------") print("step exception: ", e) print("--------------------------------------", file=sys.stderr) @@ -57,8 +59,7 @@ def wrapper(*args, **kwargs): if inspect.isclass(func): return get_func_to_call() - else: - return wrapper + return wrapper def raise_if(): diff --git a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/latest/preparers.py b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/latest/preparers.py index dee98b61f..4702355b2 100644 --- a/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/latest/preparers.py +++ b/src/test/scenarios/attestation/output/src/attestation/azext_attestation/tests/latest/preparers.py @@ -10,8 +10,8 @@ import os from datetime import datetime -from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure.cli.testsdk.exceptions import CliTestError from azure.cli.testsdk.reverse_dependency import get_dummy_cli @@ -41,7 +41,7 @@ def __init__(self, name_prefix='clitest.vn', self.resource_group_key = resource_group_key self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } @@ -64,104 +64,96 @@ def create_resource(self, name, **kwargs): self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): # delete vnet if test is being recorded and if the vnet is not a dev rg if not self.dev_setting_name: self.live_only_execute( - self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.vn', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, address_prefixes="11.0.0.0/24", dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', - random_name_length=24, key=KEY_VNET_SUBNET): + key=KEY_VNET_SUBNET): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetSubnetPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.address_prefixes = address_prefixes self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") self.test_class_instance.kwargs[self.key] = 'default' return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): pass + class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.nic', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', - random_name_length=15, key=KEY_VNET_NIC): + key=KEY_VNET_NIC): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetNicPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetNicPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' self.live_only_execute(self.cli_ctx, template.format( - self.resource_group_name, name, self.vnet_name)) + self.resource_group[1], name, self.vnet[1])) self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): if not self.dev_setting_name: self.live_only_execute( self.cli_ctx, - 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1])) diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/__init__.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/__init__.py index 40a4ac168..2c1895a7e 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/__init__.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/__init__.py @@ -20,8 +20,8 @@ def __init__(self, cli_ctx=None): datafactory_custom = CliCommandType( operations_tmpl='azext_datafactory.custom#{}', client_factory=cf_datafactory) - super(DFAZManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=datafactory_custom) + parent = super(DFAZManagementClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=datafactory_custom) def load_command_table(self, args): from azext_datafactory.generated.commands import load_command_table diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_validators.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_validators.py index a042a9ab7..e5ac78386 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_validators.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/_validators.py @@ -7,5 +7,3 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- - - diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py index f801d012a..1f9f97936 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/action.py @@ -19,7 +19,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) namespace.factory_vsts_configuration = action - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -55,7 +54,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) namespace.factory_git_hub_configuration = action - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -89,7 +87,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) namespace.fake_identity = action - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py index db4a9dfd3..775a3cce6 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/generated/custom.py @@ -14,14 +14,14 @@ from azure.cli.core.util import sdk_no_wait -def datafactory_list(cmd, client, +def datafactory_list(client, resource_group_name=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name) return client.list() -def datafactory_show(cmd, client, +def datafactory_show(client, resource_group_name, factory_name, if_none_match=None): @@ -30,7 +30,7 @@ def datafactory_show(cmd, client, if_none_match=if_none_match) -def datafactory_create(cmd, client, +def datafactory_create(client, resource_group_name, factory_name, if_match=None, @@ -59,7 +59,7 @@ def datafactory_create(cmd, client, zones=zones) -def datafactory_update(cmd, client, +def datafactory_update(client, resource_group_name, factory_name, tags=None): @@ -69,14 +69,14 @@ def datafactory_update(cmd, client, identity=None) -def datafactory_delete(cmd, client, +def datafactory_delete(client, resource_group_name, factory_name): return client.delete(resource_group_name=resource_group_name, factory_name=factory_name) -def datafactory_configure_factory_repo(cmd, client, +def datafactory_configure_factory_repo(client, location_id, factory_resource_id=None, factory_vsts_configuration=None, @@ -95,7 +95,7 @@ def datafactory_configure_factory_repo(cmd, client, repo_configuration=repo_configuration) -def datafactory_get_data_plane_access(cmd, client, +def datafactory_get_data_plane_access(client, resource_group_name, factory_name, permissions=None, @@ -112,7 +112,7 @@ def datafactory_get_data_plane_access(cmd, client, expire_time=expire_time) -def datafactory_get_git_hub_access_token(cmd, client, +def datafactory_get_git_hub_access_token(client, resource_group_name, factory_name, git_hub_access_code, @@ -125,14 +125,14 @@ def datafactory_get_git_hub_access_token(cmd, client, git_hub_access_token_base_url=git_hub_access_token_base_url) -def datafactory_trigger_list(cmd, client, +def datafactory_trigger_list(client, resource_group_name, factory_name): return client.list_by_factory(resource_group_name=resource_group_name, factory_name=factory_name) -def datafactory_trigger_show(cmd, client, +def datafactory_trigger_show(client, resource_group_name, factory_name, trigger_name, @@ -143,7 +143,7 @@ def datafactory_trigger_show(cmd, client, if_none_match=if_none_match) -def datafactory_trigger_create(cmd, client, +def datafactory_trigger_create(client, resource_group_name, factory_name, trigger_name, @@ -158,7 +158,7 @@ def datafactory_trigger_create(cmd, client, properties=properties) -def datafactory_trigger_update(instance, cmd, +def datafactory_trigger_update(instance, resource_group_name, factory_name, trigger_name, @@ -166,7 +166,7 @@ def datafactory_trigger_update(instance, cmd, return instance -def datafactory_trigger_delete(cmd, client, +def datafactory_trigger_delete(client, resource_group_name, factory_name, trigger_name): @@ -175,7 +175,7 @@ def datafactory_trigger_delete(cmd, client, trigger_name=trigger_name) -def datafactory_trigger_get_event_subscription_status(cmd, client, +def datafactory_trigger_get_event_subscription_status(client, resource_group_name, factory_name, trigger_name): @@ -184,7 +184,7 @@ def datafactory_trigger_get_event_subscription_status(cmd, client, trigger_name=trigger_name) -def datafactory_trigger_query_by_factory(cmd, client, +def datafactory_trigger_query_by_factory(client, resource_group_name, factory_name, continuation_token=None, @@ -195,7 +195,7 @@ def datafactory_trigger_query_by_factory(cmd, client, parent_trigger_name=parent_trigger_name) -def datafactory_trigger_start(cmd, client, +def datafactory_trigger_start(client, resource_group_name, factory_name, trigger_name, @@ -207,7 +207,7 @@ def datafactory_trigger_start(cmd, client, trigger_name=trigger_name) -def datafactory_trigger_stop(cmd, client, +def datafactory_trigger_stop(client, resource_group_name, factory_name, trigger_name, @@ -219,7 +219,7 @@ def datafactory_trigger_stop(cmd, client, trigger_name=trigger_name) -def datafactory_trigger_subscribe_to_event(cmd, client, +def datafactory_trigger_subscribe_to_event(client, resource_group_name, factory_name, trigger_name, @@ -231,7 +231,7 @@ def datafactory_trigger_subscribe_to_event(cmd, client, trigger_name=trigger_name) -def datafactory_trigger_unsubscribe_from_event(cmd, client, +def datafactory_trigger_unsubscribe_from_event(client, resource_group_name, factory_name, trigger_name, @@ -243,14 +243,14 @@ def datafactory_trigger_unsubscribe_from_event(cmd, client, trigger_name=trigger_name) -def datafactory_integration_runtime_list(cmd, client, +def datafactory_integration_runtime_list(client, resource_group_name, factory_name): return client.list_by_factory(resource_group_name=resource_group_name, factory_name=factory_name) -def datafactory_integration_runtime_show(cmd, client, +def datafactory_integration_runtime_show(client, resource_group_name, factory_name, integration_runtime_name, @@ -261,7 +261,7 @@ def datafactory_integration_runtime_show(cmd, client, if_none_match=if_none_match) -def datafactory_integration_runtime_linked_integration_runtime_create(cmd, client, +def datafactory_integration_runtime_linked_integration_runtime_create(client, resource_group_name, factory_name, integration_runtime_name, @@ -278,7 +278,7 @@ def datafactory_integration_runtime_linked_integration_runtime_create(cmd, clien data_factory_location=data_factory_location) -def datafactory_integration_runtime_managed_create(cmd, client, +def datafactory_integration_runtime_managed_create(client, resource_group_name, factory_name, integration_runtime_name, @@ -302,7 +302,7 @@ def datafactory_integration_runtime_managed_create(cmd, client, properties=properties) -def datafactory_integration_runtime_self_hosted_create(cmd, client, +def datafactory_integration_runtime_self_hosted_create(client, resource_group_name, factory_name, integration_runtime_name, @@ -322,7 +322,7 @@ def datafactory_integration_runtime_self_hosted_create(cmd, client, properties=properties) -def datafactory_integration_runtime_update(cmd, client, +def datafactory_integration_runtime_update(client, resource_group_name, factory_name, integration_runtime_name, @@ -335,7 +335,7 @@ def datafactory_integration_runtime_update(cmd, client, update_delay_offset=update_delay_offset) -def datafactory_integration_runtime_delete(cmd, client, +def datafactory_integration_runtime_delete(client, resource_group_name, factory_name, integration_runtime_name): @@ -344,7 +344,7 @@ def datafactory_integration_runtime_delete(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_get_connection_info(cmd, client, +def datafactory_integration_runtime_get_connection_info(client, resource_group_name, factory_name, integration_runtime_name): @@ -353,7 +353,7 @@ def datafactory_integration_runtime_get_connection_info(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_get_monitoring_data(cmd, client, +def datafactory_integration_runtime_get_monitoring_data(client, resource_group_name, factory_name, integration_runtime_name): @@ -362,7 +362,7 @@ def datafactory_integration_runtime_get_monitoring_data(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_get_status(cmd, client, +def datafactory_integration_runtime_get_status(client, resource_group_name, factory_name, integration_runtime_name): @@ -371,7 +371,7 @@ def datafactory_integration_runtime_get_status(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_list_auth_key(cmd, client, +def datafactory_integration_runtime_list_auth_key(client, resource_group_name, factory_name, integration_runtime_name): @@ -380,7 +380,7 @@ def datafactory_integration_runtime_list_auth_key(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_regenerate_auth_key(cmd, client, +def datafactory_integration_runtime_regenerate_auth_key(client, resource_group_name, factory_name, integration_runtime_name, @@ -391,7 +391,7 @@ def datafactory_integration_runtime_regenerate_auth_key(cmd, client, key_name=key_name) -def datafactory_integration_runtime_remove_link(cmd, client, +def datafactory_integration_runtime_remove_link(client, resource_group_name, factory_name, integration_runtime_name, @@ -402,7 +402,7 @@ def datafactory_integration_runtime_remove_link(cmd, client, linked_factory_name=linked_factory_name) -def datafactory_integration_runtime_start(cmd, client, +def datafactory_integration_runtime_start(client, resource_group_name, factory_name, integration_runtime_name, @@ -414,7 +414,7 @@ def datafactory_integration_runtime_start(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_stop(cmd, client, +def datafactory_integration_runtime_stop(client, resource_group_name, factory_name, integration_runtime_name, @@ -426,7 +426,7 @@ def datafactory_integration_runtime_stop(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_sync_credentials(cmd, client, +def datafactory_integration_runtime_sync_credentials(client, resource_group_name, factory_name, integration_runtime_name): @@ -435,7 +435,7 @@ def datafactory_integration_runtime_sync_credentials(cmd, client, integration_runtime_name=integration_runtime_name) -def datafactory_integration_runtime_upgrade(cmd, client, +def datafactory_integration_runtime_upgrade(client, resource_group_name, factory_name, integration_runtime_name): diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/__init__.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/__init__.py index 9da5edeae..5f8f1fd97 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/__init__.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/__init__.py @@ -12,6 +12,8 @@ import os import sys import traceback +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError __path__ = __import__('pkgutil').extend_path(__path__, __name__) @@ -47,7 +49,7 @@ def wrapper(*args, **kwargs): print("running {}()...".format(func.__name__)) try: return func_to_call(*args, **kwargs) - except BaseException as e: + except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e: print("--------------------------------------") print("step exception: ", e) print("--------------------------------------", file=sys.stderr) @@ -57,8 +59,7 @@ def wrapper(*args, **kwargs): if inspect.isclass(func): return get_func_to_call() - else: - return wrapper + return wrapper def raise_if(): diff --git a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/latest/preparers.py b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/latest/preparers.py index dee98b61f..4702355b2 100644 --- a/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/latest/preparers.py +++ b/src/test/scenarios/datafactory/output/src/datafactory/azext_datafactory/tests/latest/preparers.py @@ -10,8 +10,8 @@ import os from datetime import datetime -from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure.cli.testsdk.exceptions import CliTestError from azure.cli.testsdk.reverse_dependency import get_dummy_cli @@ -41,7 +41,7 @@ def __init__(self, name_prefix='clitest.vn', self.resource_group_key = resource_group_key self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } @@ -64,104 +64,96 @@ def create_resource(self, name, **kwargs): self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): # delete vnet if test is being recorded and if the vnet is not a dev rg if not self.dev_setting_name: self.live_only_execute( - self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.vn', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, address_prefixes="11.0.0.0/24", dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', - random_name_length=24, key=KEY_VNET_SUBNET): + key=KEY_VNET_SUBNET): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetSubnetPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.address_prefixes = address_prefixes self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") self.test_class_instance.kwargs[self.key] = 'default' return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): pass + class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.nic', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', - random_name_length=15, key=KEY_VNET_NIC): + key=KEY_VNET_NIC): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetNicPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetNicPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' self.live_only_execute(self.cli_ctx, template.format( - self.resource_group_name, name, self.vnet_name)) + self.resource_group[1], name, self.vnet[1])) self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): if not self.dev_setting_name: self.live_only_execute( self.cli_ctx, - 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1])) diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/__init__.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/__init__.py index 49379fb3a..4a4218c04 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/__init__.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/__init__.py @@ -20,8 +20,8 @@ def __init__(self, cli_ctx=None): managed_network_custom = CliCommandType( operations_tmpl='azext_managed_network.custom#{}', client_factory=cf_managed_network) - super(ManagedNetworkManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=managed_network_custom) + parent = super(ManagedNetworkManagementClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=managed_network_custom) def load_command_table(self, args): from azext_managed_network.generated.commands import load_command_table diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/_validators.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/_validators.py index a042a9ab7..e5ac78386 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/_validators.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/_validators.py @@ -7,5 +7,3 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- - - diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/action.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/action.py index a9f39c75f..f60c1d264 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/action.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/action.py @@ -19,7 +19,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddSubscriptions, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -42,7 +41,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddVirtualNetworks, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -65,7 +63,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddSubnets, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -88,7 +85,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) namespace.hub = action - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -111,7 +107,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddSpokes, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) @@ -134,7 +129,6 @@ def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) super(AddMesh, self).__call__(parser, namespace, action, option_string) - def get_action(self, values, option_string): # pylint: disable=no-self-use try: properties = defaultdict(list) diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py index dac335d28..28fa774e0 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/generated/custom.py @@ -13,7 +13,7 @@ from azure.cli.core.util import sdk_no_wait -def managed_network_mn_list(cmd, client, +def managed_network_mn_list(client, resource_group_name=None, top=None, skiptoken=None): @@ -25,7 +25,7 @@ def managed_network_mn_list(cmd, client, skiptoken=skiptoken) -def managed_network_mn_create(cmd, client, +def managed_network_mn_create(client, resource_group_name, managed_network_name, location, @@ -40,7 +40,7 @@ def managed_network_mn_create(cmd, client, properties=properties) -def managed_network_mn_update(cmd, client, +def managed_network_mn_update(client, resource_group_name, managed_network_name, tags=None): @@ -49,33 +49,33 @@ def managed_network_mn_update(cmd, client, tags=tags) -def managed_network_mn_delete(cmd, client, +def managed_network_mn_delete(client, resource_group_name, managed_network_name): return client.begin_delete(resource_group_name=resource_group_name, managed_network_name=managed_network_name) -def managed_network_mn_get_modify(cmd, client, +def managed_network_mn_get_modify(client, resource_group_name, managed_network_name): return client.get_modify(resource_group_name=resource_group_name, managed_network_name=managed_network_name) -def managed_network_mn_scope_assignment_list(cmd, client, +def managed_network_mn_scope_assignment_list(client, scope): return client.list(scope=scope) -def managed_network_mn_scope_assignment_show(cmd, client, +def managed_network_mn_scope_assignment_show(client, scope, scope_assignment_name): return client.get(scope=scope, scope_assignment_name=scope_assignment_name) -def managed_network_mn_scope_assignment_create(cmd, client, +def managed_network_mn_scope_assignment_create(client, scope, scope_assignment_name, location, @@ -86,7 +86,7 @@ def managed_network_mn_scope_assignment_create(cmd, client, assigned_managed_network=assigned_managed_network) -def managed_network_mn_scope_assignment_update(cmd, client, +def managed_network_mn_scope_assignment_update(client, scope, scope_assignment_name, location, @@ -97,14 +97,14 @@ def managed_network_mn_scope_assignment_update(cmd, client, assigned_managed_network=assigned_managed_network) -def managed_network_mn_scope_assignment_delete(cmd, client, +def managed_network_mn_scope_assignment_delete(client, scope, scope_assignment_name): return client.delete(scope=scope, scope_assignment_name=scope_assignment_name) -def managed_network_mn_group_list(cmd, client, +def managed_network_mn_group_list(client, resource_group_name, managed_network_name, top=None, @@ -115,7 +115,7 @@ def managed_network_mn_group_list(cmd, client, skiptoken=skiptoken) -def managed_network_mn_group_show(cmd, client, +def managed_network_mn_group_show(client, resource_group_name, managed_network_name, group_name): @@ -124,7 +124,7 @@ def managed_network_mn_group_show(cmd, client, managed_network_group_name=group_name) -def managed_network_mn_group_create(cmd, client, +def managed_network_mn_group_create(client, resource_group_name, managed_network_name, group_name, @@ -148,7 +148,7 @@ def managed_network_mn_group_create(cmd, client, subnets=subnets) -def managed_network_mn_group_update(cmd, client, +def managed_network_mn_group_update(client, resource_group_name, managed_network_name, group_name, @@ -172,7 +172,7 @@ def managed_network_mn_group_update(cmd, client, subnets=subnets) -def managed_network_mn_group_delete(cmd, client, +def managed_network_mn_group_delete(client, resource_group_name, managed_network_name, group_name, @@ -184,7 +184,7 @@ def managed_network_mn_group_delete(cmd, client, managed_network_group_name=group_name) -def managed_network_managed_network_peering_policy_list(cmd, client, +def managed_network_managed_network_peering_policy_list(client, resource_group_name, managed_network_name, top=None, @@ -195,7 +195,7 @@ def managed_network_managed_network_peering_policy_list(cmd, client, skiptoken=skiptoken) -def managed_network_managed_network_peering_policy_show(cmd, client, +def managed_network_managed_network_peering_policy_show(client, resource_group_name, managed_network_name, policy_name): @@ -204,7 +204,7 @@ def managed_network_managed_network_peering_policy_show(cmd, client, managed_network_peering_policy_name=policy_name) -def managed_network_managed_network_peering_policy_hub_and_spoke_topology_create(cmd, client, +def managed_network_managed_network_peering_policy_hub_and_spoke_topology_create(client, resource_group_name, managed_network_name, policy_name, @@ -227,7 +227,7 @@ def managed_network_managed_network_peering_policy_hub_and_spoke_topology_create properties=properties) -def managed_network_managed_network_peering_policy_hub_and_spoke_topology_update(instance, cmd, +def managed_network_managed_network_peering_policy_hub_and_spoke_topology_update(instance, resource_group_name, managed_network_name, policy_name, @@ -243,7 +243,7 @@ def managed_network_managed_network_peering_policy_hub_and_spoke_topology_update return instance -def managed_network_managed_network_peering_policy_mesh_topology_create(cmd, client, +def managed_network_managed_network_peering_policy_mesh_topology_create(client, resource_group_name, managed_network_name, policy_name, @@ -266,7 +266,7 @@ def managed_network_managed_network_peering_policy_mesh_topology_create(cmd, cli properties=properties) -def managed_network_managed_network_peering_policy_mesh_topology_update(instance, cmd, +def managed_network_managed_network_peering_policy_mesh_topology_update(instance, resource_group_name, managed_network_name, policy_name, @@ -282,7 +282,7 @@ def managed_network_managed_network_peering_policy_mesh_topology_update(instance return instance -def managed_network_managed_network_peering_policy_delete(cmd, client, +def managed_network_managed_network_peering_policy_delete(client, resource_group_name, managed_network_name, policy_name, diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/__init__.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/__init__.py index 9da5edeae..5f8f1fd97 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/__init__.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/__init__.py @@ -12,6 +12,8 @@ import os import sys import traceback +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError __path__ = __import__('pkgutil').extend_path(__path__, __name__) @@ -47,7 +49,7 @@ def wrapper(*args, **kwargs): print("running {}()...".format(func.__name__)) try: return func_to_call(*args, **kwargs) - except BaseException as e: + except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e: print("--------------------------------------") print("step exception: ", e) print("--------------------------------------", file=sys.stderr) @@ -57,8 +59,7 @@ def wrapper(*args, **kwargs): if inspect.isclass(func): return get_func_to_call() - else: - return wrapper + return wrapper def raise_if(): diff --git a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/latest/preparers.py b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/latest/preparers.py index dee98b61f..4702355b2 100644 --- a/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/latest/preparers.py +++ b/src/test/scenarios/managed-network/output/src/managed-network/azext_managed_network/tests/latest/preparers.py @@ -10,8 +10,8 @@ import os from datetime import datetime -from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer from azure.cli.testsdk.exceptions import CliTestError from azure.cli.testsdk.reverse_dependency import get_dummy_cli @@ -41,7 +41,7 @@ def __init__(self, name_prefix='clitest.vn', self.resource_group_key = resource_group_key self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } @@ -64,104 +64,96 @@ def create_resource(self, name, **kwargs): self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): # delete vnet if test is being recorded and if the vnet is not a dev rg if not self.dev_setting_name: self.live_only_execute( - self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.vn', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, address_prefixes="11.0.0.0/24", dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', - random_name_length=24, key=KEY_VNET_SUBNET): + key=KEY_VNET_SUBNET): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetSubnetPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.address_prefixes = address_prefixes self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") self.test_class_instance.kwargs[self.key] = 'default' return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): pass + class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): def __init__(self, name_prefix='clitest.nic', parameter_name='subnet', - resource_group_name=None, resource_group_key=KEY_RESOURCE_GROUP, - vnet_name=None, vnet_key=KEY_VIRTUAL_NETWORK, dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', - random_name_length=15, key=KEY_VNET_NIC): + key=KEY_VNET_NIC): if ' ' in name_prefix: raise CliTestError( 'Error: Space character in name prefix \'%s\'' % name_prefix) - super(VnetNicPreparer, self).__init__( - name_prefix, random_name_length) + super(VnetNicPreparer, self).__init__(name_prefix, 15) self.cli_ctx = get_dummy_cli() self.parameter_name = parameter_name self.key = key - self.resource_group_name = resource_group_name - self.resource_group_key = resource_group_key - self.vnet_name = vnet_name - self.vnet_key = vnet_key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] self.dev_setting_name = os.environ.get(dev_setting_name, None) - def create_resource(self, name, **kwargs): + def create_resource(self, name, **_): if self.dev_setting_name: return {self.parameter_name: self.dev_setting_name, } - if not self.resource_group_name: - self.resource_group_name = self.test_class_instance.kwargs.get( - self.resource_group_key) - if not self.resource_group_name: + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: raise CliTestError("Error: No resource group configured!") - if not self.vnet_name: - self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) - if not self.vnet_name: + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: raise CliTestError("Error: No vnet configured!") template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' self.live_only_execute(self.cli_ctx, template.format( - self.resource_group_name, name, self.vnet_name)) + self.resource_group[1], name, self.vnet[1])) self.test_class_instance.kwargs[self.key] = name return {self.parameter_name: name} - def remove_resource(self, name, **kwargs): + def remove_resource(self, name, **_): if not self.dev_setting_name: self.live_only_execute( self.cli_ctx, - 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1]))