Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
widgets: Make type checks more explicit.
Steve Howell6b910ff3b412
diff --git a/zerver/lib/validator.py b/zerver/lib/validator.pyindex 04b93e27030..2e2bdb2549f 100644--- a/zerver/lib/validator.py+++ b/zerver/lib/validator.py@@ -351,7 +351,10 @@ def check_widget_content(widget_content: object) -> Dict[str, Any]:]),)+ # We re-check "type" here just to avoid it looking+ # like we have extraneous keys.checker = check_dict([+ ('type', equals('choices')),('heading', check_string),('choices', check_choices),])diff --git a/zerver/tests/test_widgets.py b/zerver/tests/test_widgets.pyindex 9f3579c0b4c..14eadb2975d 100644--- a/zerver/tests/test_widgets.py+++ b/zerver/tests/test_widgets.py@@ -116,20 +116,20 @@ class WidgetContentTestCase(ZulipTestCase):choices=[],)- widget_content = ujson.dumps(- dict(- widget_type='zform',- extra_data=zform_data,- ),+ widget_content = dict(+ widget_type='zform',+ extra_data=zform_data,)+ check_widget_content(widget_content)+payload = dict(type="stream",to=stream_name,client='test suite',topic='whatever',content=content,- widget_content=widget_content,+ widget_content=ujson.dumps(widget_content),)result = self.api_post(sender, "/api/v1/messages", payload)self.assert_json_success(result)