Esempio n. 1
0
    def get_path(self, group_delimiter='/'):
        '''
        Get the elements path within the survey.
        '''
        # TODO: Any other way of avoiding a circular import?
        from pyxform.survey import Survey

        path = self.name
        parent = self.get(constants.PARENT, Survey())
        while not isinstance(parent, Survey):
            path = parent.name + group_delimiter + path
            parent = parent.get(constants.PARENT, Survey())

        return path
Esempio n. 2
0
 def test_survey_can_have_to_xml_called_twice(self):
     """
     Test: Survey can have "to_xml" called multiple times
     
     (This was not being allowed before.)
     
     It would be good to know (with confidence) that a survey object
     can be exported to_xml twice, and the same thing will be returned
     both times.
     """
     survey = Survey(name=u"SampleSurvey")
     q = create_survey_element_from_dict({u'type':u'text', u'name':u'name'})
     survey.add_child(q)
     
     str1 = survey.to_xml()
     str2 = survey.to_xml()
     
     self.assertEqual(str1, str2)