Skip to content

Commit

Permalink
fix: publish options update does not error when dict (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrzhan committed Sep 29, 2023
1 parent 9df61ec commit a9cf8d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions gdk/commands/config/update/ConfigData.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ def set_region(self, value):

def set_publish_options(self, value):
# value can be a dict object or a string
formatted_input = value.replace("'", '"')
new_value = json.loads(formatted_input) if isinstance(value, str) else value
new_value = json.loads(value.replace("'", '"')) if isinstance(value, str) else value
self._set_publish_config_values(ConfigEnum.PUBLISH_OPTIONS.value, new_value)

def set_gdk_version(self, value):
Expand Down
2 changes: 1 addition & 1 deletion gdk/commands/config/update/Prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def prompter(self, field, required, max_attempts=3):
[
f"--{parser_argument}",
self.interactive_prompt(
parser_argument, current_field_value, require
parser_argument, str(current_field_value), require
),
]
)
Expand Down
7 changes: 6 additions & 1 deletion tests/gdk/commands/config/update/test_ConfigData.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ def test_set_region(self):
data.set_field(ConfigEnum.REGION, "random-region123")
self.assertEqual(data.get_region(), "random-region123")

def test_set_publish_options(self):
def test_set_publish_options_str(self):
data = ConfigData(self.field_dict)
data.set_field(ConfigEnum.PUBLISH_OPTIONS, '{"bar": "foo"}')
self.assertEqual(data.get_publish_options(), {"bar": "foo"})

def test_set_publish_options_dict(self):
data = ConfigData(self.field_dict)
data.set_field(ConfigEnum.PUBLISH_OPTIONS, {"bar": "foo"})
self.assertEqual(data.get_publish_options(), {"bar": "foo"})

def test_set_gdk_version(self):
data = ConfigData(self.field_dict)
data.set_field(ConfigEnum.GDK_VERSION, "19.20.21")
Expand Down

0 comments on commit a9cf8d5

Please sign in to comment.