Merge pull request #5784 from ryanpetrello/issue/5528

Fix to handle Str and JSON mix-in data correctly with settings API

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-01-28 17:35:40 +00:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -122,7 +122,7 @@ clean-api:
rm -rf awx/projects rm -rf awx/projects
clean-awxkit: clean-awxkit:
rm -rf awxkit/*.egg-info awxkit/.tox rm -rf awxkit/*.egg-info awxkit/.tox awxkit/build/*
# convenience target to assert environment variables are defined # convenience target to assert environment variables are defined
guard-%: guard-%:

View File

@@ -1,4 +1,5 @@
import functools import functools
import json
from six import with_metaclass from six import with_metaclass
@@ -539,5 +540,15 @@ class SettingsModify(CustomAction):
def perform(self, key, value): def perform(self, key, value):
self.page.endpoint = self.page.endpoint + 'all/' self.page.endpoint = self.page.endpoint + 'all/'
resp = self.page.patch(**{key: value}) patch_value = value
if self.is_json(value):
patch_value = json.loads(value)
resp = self.page.patch(**{key: patch_value})
return resp.from_json({'key': key, 'value': resp[key]}) return resp.from_json({'key': key, 'value': resp[key]})
def is_json(self, data):
try:
json.loads(data)
except json.decoder.JSONDecodeError:
return False
return True