Azure / autorest.az

Azure CLI Code Generator
MIT License
22 stars 20 forks source link

Ask for "one example, one test case" #782

Closed qwordy closed 3 years ago

qwordy commented 3 years ago

Autorest version: 1.7.3 All examples in swagger are in one test case. I suggest generating one test case for one example. If all testing code is in one test case, I need to run all code even if I make a tiny change. Similar issue, https://github.com/Azure/autorest.az/issues/518.

# Testcase: Scenario
@try_manual
def call_scenario(test, rg):
    setup_scenario(test, rg)
    step_create(test, rg, checks=[
        test.check("name", "{myCloudService}", case_sensitive=False),
        test.check("location", "westus", case_sensitive=False),
        test.check("configuration", "{{ServiceConfiguration}}", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].name", "contosolb", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].name",
                   "contosofe", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].properties.publ"
                   "icIPAddress.id", "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/"
                   "publicIPAddresses/contosopublicip", case_sensitive=False),
        test.check("packageUrl", "{{PackageUrl}}", case_sensitive=False),
        test.check("upgradeMode", "Auto", case_sensitive=False),
    ])
    step_create2(test, rg, checks=[
        test.check("name", "{myCloudService}", case_sensitive=False),
        test.check("location", "westus", case_sensitive=False),
        test.check("configuration", "{{ServiceConfiguration}}", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].name", "myLoadBalancer", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].name", "myfe",
                   case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].properties.publ"
                   "icIPAddress.id", "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/"
                   "publicIPAddresses/myPublicIP", case_sensitive=False),
        test.check("packageUrl", "{{PackageUrl}}", case_sensitive=False),
        test.check("roleProfile.roles[0].name", "ContosoFrontend", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.name", "Standard_D1_v2", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.capacity", 1),
        test.check("roleProfile.roles[0].sku.tier", "Standard", case_sensitive=False),
        test.check("upgradeMode", "Auto", case_sensitive=False),
    ])
    step_create3(test, rg, checks=[
        test.check("name", "{myCloudService}", case_sensitive=False),
        test.check("location", "westus", case_sensitive=False),
        test.check("configuration", "{{ServiceConfiguration}}", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].name", "contosolb", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].name",
                   "contosofe", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].properties.publ"
                   "icIPAddress.id", "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/"
                   "publicIPAddresses/contosopublicip", case_sensitive=False),
        test.check("packageUrl", "{{PackageUrl}}", case_sensitive=False),
        test.check("roleProfile.roles[0].name", "ContosoFrontend", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.name", "Standard_D1_v2", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.capacity", 1),
        test.check("roleProfile.roles[0].sku.tier", "Standard", case_sensitive=False),
        test.check("upgradeMode", "Auto", case_sensitive=False),
        test.check("osProfile.secrets[0].sourceVault.id", "/subscriptions/{subscription_id}/resourceGroups/{rg}/provide"
                   "rs/Microsoft.KeyVault/vaults/{{keyvault-name}}", case_sensitive=False),
        test.check("osProfile.secrets[0].vaultCertificates[0].certificateUrl", "https://{{keyvault-name}}.vault.azure.n"
                   "et:443/secrets/ContosoCertificate/{{secret-id}}", case_sensitive=False),
    ])
    step_create4(test, rg, checks=[
        test.check("name", "{myCloudService}", case_sensitive=False),
        test.check("location", "westus", case_sensitive=False),
        test.check("configuration", "{{ServiceConfiguration}}", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].name", "contosolb", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].name",
                   "contosofe", case_sensitive=False),
        test.check("networkProfile.loadBalancerConfigurations[0].properties.frontendIPConfigurations[0].properties.publ"
                   "icIPAddress.id", "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/"
                   "publicIPAddresses/contosopublicip", case_sensitive=False),
        test.check("packageUrl", "{{PackageUrl}}", case_sensitive=False),
        test.check("roleProfile.roles[0].name", "ContosoFrontend", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.name", "Standard_D1_v2", case_sensitive=False),
        test.check("roleProfile.roles[0].sku.capacity", 1),
        test.check("roleProfile.roles[0].sku.tier", "Standard", case_sensitive=False),
        test.check("upgradeMode", "Auto", case_sensitive=False),
    ])
    cleanup_scenario(test, rg)
changlong-liu commented 3 years ago

test scenario can be configured in cli.md/az.md following https://github.com/Azure/autorest.az/blob/master/doc/04-scenario-test-configuration.md#mutli-testcase-scenario

qwordy commented 3 years ago

@changlong-liu Thanks. I will try it. I read the document. testcase should be test case.

changlong-liu commented 3 years ago

Thanks @qwordy , will correct to 'test case' in coming PR.