@ResourceGroupPreparer(name_prefix='cli_test_webapp_json', location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_update_webapp_settings_thru_json(self, resource_group):
    webapp_name = self.create_random_name('webapp-config-test', 40)
    plan_name = self.create_random_name('webapp-config-plan', 40)
    (_, settings_file) = tempfile.mkstemp()
    with open(settings_file, 'w+') as file:
        file.write(json.dumps({'s2': 'value2'}))
    self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan_name))
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan_name))
    output = self.cmd('webapp config appsettings set -g {} -n {} --settings s=value "@{}"'.format(resource_group, webapp_name, settings_file)).get_output_in_json()
    output = [s for s in output if (s['name'] in ['s', 's2'])]
    output.sort(key=(lambda s: s['name']))
    self.assertEqual(output[0], {'name': 's', 'value': 'value', 'slotSetting': False})
    self.assertEqual(output[1], {'name': 's2', 'value': 'value2', 'slotSetting': False})
    output.append({'name': 's3', 'value': 'value3', 'slotSetting': True})
    with open(settings_file, 'w') as file:
        file.write(json.dumps(output))
    output = self.cmd('webapp config appsettings set -g {} -n {} --settings "@{}"'.format(resource_group, webapp_name, settings_file)).get_output_in_json()
    output = [s for s in output if (s['name'] in ['s', 's2', 's3'])]
    output.sort(key=(lambda s: s['name']))
    self.assertEqual(output[0], {'name': 's', 'value': 'value', 'slotSetting': False})
    self.assertEqual(output[1], {'name': 's2', 'value': 'value2', 'slotSetting': False})
    self.assertEqual(output[2], {'name': 's3', 'value': 'value3', 'slotSetting': True})
    site_configs = {'requestTracingEnabled': True, 'alwaysOn': True}
    with open(settings_file, 'w') as file:
        file.write(json.dumps(site_configs))
    self.cmd('webapp config set -g {} -n {} --generic-configurations "@{}"'.format(resource_group, webapp_name, settings_file)).assert_with_checks([JMESPathCheck('requestTracingEnabled', True), JMESPathCheck('alwaysOn', True)])
@ResourceGroupPreparer(name_prefix='cli_test_webapp_json', location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_update_webapp_settings_thru_json(self, resource_group):
    webapp_name = self.create_random_name('webapp-config-test', 40)
    plan_name = self.create_random_name('webapp-config-plan', 40)
    (_, settings_file) = tempfile.mkstemp()
    with open(settings_file, 'w+') as file:
        file.write(json.dumps({'s2': 'value2'}))
    self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan_name))
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan_name))
    output = self.cmd('webapp config appsettings set -g {} -n {} --settings s=value "@{}"'.format(resource_group, webapp_name, settings_file)).get_output_in_json()
    output = [s for s in output if (s['name'] in ['s', 's2'])]
    output.sort(key=(lambda s: s['name']))
    self.assertEqual(output[0], {'name': 's', 'value': 'value', 'slotSetting': False})
    self.assertEqual(output[1], {'name': 's2', 'value': 'value2', 'slotSetting': False})
    output.append({'name': 's3', 'value': 'value3', 'slotSetting': True})
    with open(settings_file, 'w') as file:
        file.write(json.dumps(output))
    output = self.cmd('webapp config appsettings set -g {} -n {} --settings "@{}"'.format(resource_group, webapp_name, settings_file)).get_output_in_json()
    output = [s for s in output if (s['name'] in ['s', 's2', 's3'])]
    output.sort(key=(lambda s: s['name']))
    self.assertEqual(output[0], {'name': 's', 'value': 'value', 'slotSetting': False})
    self.assertEqual(output[1], {'name': 's2', 'value': 'value2', 'slotSetting': False})
    self.assertEqual(output[2], {'name': 's3', 'value': 'value3', 'slotSetting': True})
    site_configs = {'requestTracingEnabled': True, 'alwaysOn': True}
    with open(settings_file, 'w') as file:
        file.write(json.dumps(site_configs))
    self.cmd('webapp config set -g {} -n {} --generic-configurations "@{}"'.format(resource_group, webapp_name, settings_file)).assert_with_checks([JMESPathCheck('requestTracingEnabled', True), JMESPathCheck('alwaysOn', True)])