mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	widgets: Make type checks more explicit.
Note that I don't actually convert the checker from check_dict to check_dict_only, because that would be a user-facing change, but I think we can sweep a lot of things like this after the next release.
This commit is contained in:
		@@ -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),
 | 
			
		||||
            ])
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user