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_page_with_defaults(self): page = """ page Selling { section "section1 name" { question question_name1 } section "section2 name" { question question_name2 } default boolean widget radio default integer widget slider } """ page_node = AST.PageWithDefaultsNode( "Selling", BlockNode([ AST.SectionNode( "section1 name", BlockNode([AST.QuestionNode("question_name1")])), AST.SectionNode( "section2 name", BlockNode([AST.QuestionNode("question_name2")])) ]), BlockNode([ AST.DefaultNode(AST.BoolTypeNode(), AST.RadioNode()), AST.DefaultNode(AST.IntTypeNode(), AST.SliderNode()) ])) self.validate_node(self.parse_page, page, page_node) wrong_page = """ page Selling { section "section" { question question_name } default integer widget spinbox section "section" { question question_name } } """ self.check_parse_exception(self.parse_page, wrong_page, pp.ParseException)
def test_widget_type_slider(self): self.validate_node(self.parse_widget_type, "widget slider", AST.SliderNode())