Skip to content

Commit

Permalink
vue: Fix empty topics not getting saved to_disk
Browse files Browse the repository at this point in the history
Change-Id: I04af5c96d545fd44d1e97bb641be225b3a47a2f6
  • Loading branch information
cellador committed Oct 8, 2024
1 parent 7a80c20 commit 63fb002
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmk/gui/form_specs/vue/visitors/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _to_disk(
disk_values = {}
for topic in self.form_spec.topics:
element_visitor = get_visitor(topic.dictionary, self.options)
if topic_value := parsed_value.get(topic.ident):
if (topic_value := parsed_value.get(topic.ident)) is not None:
disk_values[topic.ident] = element_visitor.to_disk(topic_value)
return disk_values

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/cmk/gui/form_specs/vue/visitors/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ def test_catalog_validation_simple(
invalid_value="",
)
]


def test_catalog_serializes_empty_topics_to_disk() -> None:
spec = Catalog(
topics=[
Topic(
ident="some_topic",
dictionary=Dictionary(elements={"key": DictElement(parameter_form=String())}),
)
]
)
visitor = get_visitor(spec, VisitorOptions(data_origin=DataOrigin.DISK))

disk_data = visitor.to_disk({"some_topic": {}})

assert disk_data == {"some_topic": {}}

0 comments on commit 63fb002

Please sign in to comment.