@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_slot(self, resource_group):
    plan = self.create_random_name(prefix='slot-test-plan', length=24)
    webapp = self.create_random_name(prefix='slot-test-web', length=24)
    plan_result = self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan)).get_output_in_json()
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp, plan_result['name']))
    slot = 'staging'
    slot2 = 'dev'
    test_git_repo = 'https://github.com/yugangw-msft/azure-site-test'
    test_php_version = '5.6'
    self.cmd('webapp config appsettings set -g {} -n {} --settings s1=v1 --slot-settings s2=v2'.format(resource_group, webapp))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {}'.format(resource_group, webapp, slot), checks=[JMESPathCheck('name', slot)])
    self.cmd('webapp deployment source config -g {} -n {} --repo-url {} --branch {} -s {} --manual-integration'.format(resource_group, webapp, test_git_repo, slot, slot), checks=[JMESPathCheck('repoUrl', test_git_repo), JMESPathCheck('branch', slot)])
    self.cmd('webapp deployment slot swap -g {} -n {} -s {}'.format(resource_group, webapp, slot))
    result = self.cmd('webapp config appsettings list -g {} -n {} -s {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 'WEBSITE_NODE_DEFAULT_VERSION']))
    self.cmd('webapp config set -g {} -n {} --php-version {}'.format(resource_group, webapp, test_php_version))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {} --configuration-source {}'.format(resource_group, webapp, slot2, webapp))
    self.cmd('webapp config show -g {} -n {} --slot {}'.format(resource_group, webapp, slot2), checks=[JMESPathCheck('phpVersion', test_php_version)])
    self.cmd('webapp config appsettings set -g {} -n {} --slot {} --settings s3=v3 --slot-settings s4=v4'.format(resource_group, webapp, slot2), checks=[JMESPathCheck("[?name=='s4']|[0].slotSetting", True), JMESPathCheck("[?name=='s3']|[0].slotSetting", False)])
    self.cmd('webapp config connection-string set -g {} -n {} -t mysql --slot {} --settings c1=connection1 --slot-settings c2=connection2'.format(resource_group, webapp, slot2))
    self.cmd('webapp deployment slot swap -g {} -n {} --slot {} --target-slot {}'.format(resource_group, webapp, slot, slot2))
    result = self.cmd('webapp config appsettings list -g {} -n {} --slot {}'.format(resource_group, webapp, slot2)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 's4', 'WEBSITE_NODE_DEFAULT_VERSION']))
    result = self.cmd('webapp config connection-string list -g {} -n {} --slot {}'.format(resource_group, webapp, slot2)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['c2']))
    result = self.cmd('webapp config appsettings list -g {} -n {} --slot {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertTrue(set(['s3']).issubset(set([x['name'] for x in result])))
    result = self.cmd('webapp config connection-string list -g {} -n {} --slot {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['c1']))
    self.cmd('webapp deployment slot list -g {} -n {}'.format(resource_group, webapp), checks=[JMESPathCheck('length([])', 2), JMESPathCheck("length([?name=='{}'])".format(slot2), 1), JMESPathCheck("length([?name=='{}'])".format(slot), 1)])
    self.cmd('webapp deployment slot delete -g {} -n {} --slot {}'.format(resource_group, webapp, slot))
    self.cmd('webapp delete -g {} -n {} --slot {} --keep-dns-registration --keep-empty-plan --keep-metrics'.format(resource_group, webapp, slot2))
@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_slot(self, resource_group):
    plan = self.create_random_name(prefix='slot-test-plan', length=24)
    webapp = self.create_random_name(prefix='slot-test-web', length=24)
    plan_result = self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan)).get_output_in_json()
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp, plan_result['name']))
    slot = 'staging'
    slot2 = 'dev'
    test_git_repo = 'https://github.com/yugangw-msft/azure-site-test'
    test_php_version = '5.6'
    self.cmd('webapp config appsettings set -g {} -n {} --settings s1=v1 --slot-settings s2=v2'.format(resource_group, webapp))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {}'.format(resource_group, webapp, slot), checks=[JMESPathCheck('name', slot)])
    self.cmd('webapp deployment source config -g {} -n {} --repo-url {} --branch {} -s {} --manual-integration'.format(resource_group, webapp, test_git_repo, slot, slot), checks=[JMESPathCheck('repoUrl', test_git_repo), JMESPathCheck('branch', slot)])
    self.cmd('webapp deployment slot swap -g {} -n {} -s {}'.format(resource_group, webapp, slot))
    result = self.cmd('webapp config appsettings list -g {} -n {} -s {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 'WEBSITE_NODE_DEFAULT_VERSION']))
    self.cmd('webapp config set -g {} -n {} --php-version {}'.format(resource_group, webapp, test_php_version))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {} --configuration-source {}'.format(resource_group, webapp, slot2, webapp))
    self.cmd('webapp config show -g {} -n {} --slot {}'.format(resource_group, webapp, slot2), checks=[JMESPathCheck('phpVersion', test_php_version)])
    self.cmd('webapp config appsettings set -g {} -n {} --slot {} --settings s3=v3 --slot-settings s4=v4'.format(resource_group, webapp, slot2), checks=[JMESPathCheck("[?name=='s4']|[0].slotSetting", True), JMESPathCheck("[?name=='s3']|[0].slotSetting", False)])
    self.cmd('webapp config connection-string set -g {} -n {} -t mysql --slot {} --settings c1=connection1 --slot-settings c2=connection2'.format(resource_group, webapp, slot2))
    self.cmd('webapp deployment slot swap -g {} -n {} --slot {} --target-slot {}'.format(resource_group, webapp, slot, slot2))
    result = self.cmd('webapp config appsettings list -g {} -n {} --slot {}'.format(resource_group, webapp, slot2)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 's4', 'WEBSITE_NODE_DEFAULT_VERSION']))
    result = self.cmd('webapp config connection-string list -g {} -n {} --slot {}'.format(resource_group, webapp, slot2)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['c2']))
    result = self.cmd('webapp config appsettings list -g {} -n {} --slot {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertTrue(set(['s3']).issubset(set([x['name'] for x in result])))
    result = self.cmd('webapp config connection-string list -g {} -n {} --slot {}'.format(resource_group, webapp, slot)).get_output_in_json()
    self.assertEqual(set([x['name'] for x in result]), set(['c1']))
    self.cmd('webapp deployment slot list -g {} -n {}'.format(resource_group, webapp), checks=[JMESPathCheck('length([])', 2), JMESPathCheck("length([?name=='{}'])".format(slot2), 1), JMESPathCheck("length([?name=='{}'])".format(slot), 1)])
    self.cmd('webapp deployment slot delete -g {} -n {} --slot {}'.format(resource_group, webapp, slot))
    self.cmd('webapp delete -g {} -n {} --slot {} --keep-dns-registration --keep-empty-plan --keep-metrics'.format(resource_group, webapp, slot2))