def test_section_defaults(self): section = """ section "section name" { question question_name default integer widget slider default boolean widget checkbox } """ section_node = AST.SectionWithDefaultsNode( "section name", BlockNode([AST.QuestionNode("question_name")]), BlockNode([ AST.DefaultNode(AST.IntTypeNode(), AST.SliderNode()), AST.DefaultNode(AST.BoolTypeNode(), AST.CheckboxNode()) ])) self.validate_node(self.parse_section, section, section_node) wrong_section = """ section \"section name\" { question name default integer widget slider question name } """ self.check_parse_exception(self.parse_section, wrong_section, pp.ParseException)
def test_default_with_props(self): default = """ default boolean { width: 400 widget checkbox } """ default_node = AST.DefaultWithPropsNode( AST.BoolTypeNode(), BlockNode([AST.WidthNode(400)]), AST.CheckboxNode()) self.validate_node(self.parse_default, default, default_node) default = """ default boolean { width: 400 widget checkbox font: "Arial" } """ self.check_parse_exception(self.parse_default, default, pp.ParseException)
def test_widget_type_checkbox(self): self.validate_node(self.parse_widget_type, "widget checkbox", AST.CheckboxNode())
def test_default(self): self.validate_node( self.parse_default, "default boolean widget checkbox", AST.DefaultNode(AST.BoolTypeNode(), AST.CheckboxNode()))