Example #1
0
 def setUp(self):
     self.this_directory = os.path.dirname(__file__)
     survey_out = Survey(name=u"age", sms_keyword=u"age", type=u"survey")
     question = InputQuestion(name=u"age")
     question.type = u"integer"
     question.label = u"How old are you?"
     survey_out.add_child(question)
     self.survey_out_dict = survey_out.to_json_dict()
     print_pyobj_to_json(self.survey_out_dict, utils.path_to_text_fixture("how_old_are_you.json"))
Example #2
0
 def setUp(self):
     self.this_directory = os.path.dirname(__file__)
     survey_out = Survey(name=u"age", type=u"survey")
     question = InputQuestion(name=u"age")
     question.type = u"integer"
     question.label = u"How old are you?"
     survey_out.add_child(question)
     self.survey_out_dict = survey_out.to_json_dict()
     print_pyobj_to_json(self.survey_out_dict,
                         utils.path_to_text_fixture("how_old_are_you.json"))
Example #3
0
 def setUp(self):
     survey_out = Survey(
         type=u"survey"
         )
     question = InputQuestion(name=u"age")
     question.set(InputQuestion.TYPE, u"integer")
     question.set(InputQuestion.LABEL, u"How old are you?")
     survey_out.add_child(question)
     self.survey_out_dict = survey_out.to_dict()
     print_pyobj_to_json(self.survey_out_dict, "pyxform/tests/how_old_are_you.json")
    def test_output_node_for_select_one_question_type(self):

        self.this_directory = os.path.dirname(__file__)
        survey_out = Survey(name="geopgraphy", sms_keyword="geography", type="survey")
        question = InputQuestion(name="counties")
        question.type = "select one external"
        question.label = "county"
        survey_out.add_child(question)

        expected = '<input ref="/geopgraphy/counties">'

        xml = survey_out.to_xml()
        self.assertEqual(1, xml.count(expected))
Example #5
0
 def setUp(self):
     survey_out = Survey(type=u"survey")
     question = InputQuestion(name=u"age")
     question.set(InputQuestion.TYPE, u"integer")
     question.set(InputQuestion.LABEL, u"How old are you?")
     survey_out.add_child(question)
     self.survey_out_dict = survey_out.to_dict()
     print_pyobj_to_json(self.survey_out_dict,
                         "pyxform/tests/how_old_are_you.json")
Example #6
0
 def test_one_section_cannot_have_two_conflicting_slugs(self):
     q1 = InputQuestion(name="YourName")
     q2 = InputQuestion(name="YourName")
     s = Survey(name="Roses are Red", children=[q1, q2])
     self.assertRaises(Exception, s, "validate")