def test_load_from_dump(self):
     for filename, survey in self.surveys.items():
         survey.json_dump()
         path = survey.name + ".json"
         survey_from_dump = create_survey_from_path(path)
         self.assertEqual(survey.to_json_dict(),
                          survey_from_dump.to_json_dict())
Example #2
0
 def setUp(self):
     self.excel_files = [
         "gps.xls",
         # "include.xls",
         "specify_other.xls",
         "loop.xls",
         "text_and_integer.xls",
         # todo: this is looking for json that is created (and
         # deleted) by another test, is should just add that json
         # to the directory.
         # "include_json.xls",
         "simple_loop.xls",
         "yes_or_no_question.xls",
         "xlsform_spec_test.xlsx",
         "group.xls",
     ]
     self.surveys = {}
     self.this_directory = os.path.dirname(__file__)
     for filename in self.excel_files:
         path = utils.path_to_text_fixture(filename)
         try:
             self.surveys[filename] = create_survey_from_path(path)
         except Exception as e:
             print("Error on : " + filename)
             raise e
Example #3
0
 def setUp(self):
     self.excel_files = [
         "gps.xls",
         # "include.xls",
         "specify_other.xls",
         "loop.xls",
         "text_and_integer.xls",
         # todo: this is looking for json that is created (and
         # deleted) by another test, is should just add that json
         # to the directory.
         # "include_json.xls",
         "simple_loop.xls",
         "yes_or_no_question.xls",
         "xlsform_spec_test.xlsx",
         "group.xls",
     ]
     self.surveys = {}
     self.this_directory = os.path.dirname(__file__)
     for filename in self.excel_files:
         path = utils.path_to_text_fixture(filename)
         try:
             self.surveys[filename] = create_survey_from_path(path)
         except Exception as e:
             print("Error on : " + filename)
             raise e
 def test_load_from_dump(self):
     for filename, survey in self.surveys.items():
         survey.json_dump()
         path = survey.name + ".json"
         survey_from_dump = create_survey_from_path(path)
         self.assertEqual(survey.to_json_dict(),
                          survey_from_dump.to_json_dict())
Example #5
0
    def test_create_from_path(self):
        path = utils.path_to_text_fixture("area.xlsx")
        survey = create_survey_from_path(path)
        path = os.path.join(
            os.path.dirname(__file__), 'test_expected_output', 'area.xml')

        with codecs.open(path, encoding='utf-8') as f:
            self.assertMultiLineEqual(survey.to_xml(), f.read())
Example #6
0
 def clean_xls_file(self):
     xls = self.cleaned_data['xls_file']
     path = save_in_temp_dir(xls)
     survey = create_survey_from_path(path)
     try:
         xform_str = survey.to_xml()
         self.file_name = "%s.xml" % survey.id_string
         self.xform_str = xform_str
     except ODKValidateError, error:
         raise forms.ValidationError(u"Your XLS was valid but the form did not pass ODK Validate: %s" % repr(error))
Example #7
0
    def test_create_from_path(self):
        path = utils.path_to_text_fixture("osm.xlsx")
        survey = create_survey_from_path(path)
        path = os.path.join(os.path.dirname(__file__), 'test_expected_output',
                            'osm.xml')

        with codecs.open(path, encoding='utf-8') as f:
            expected_xml = f.read()
            self.assertXFormEqual(survey.to_xml(), expected_xml)

            survey = create_survey_element_from_json(survey.to_json())
            self.assertXFormEqual(survey.to_xml(), expected_xml)
Example #8
0
    def test_create_from_path(self):
        path = utils.path_to_text_fixture("file_type.xlsx")
        survey = create_survey_from_path(path)
        path = os.path.join(
            os.path.dirname(__file__), 'test_expected_output', 'file_type.xml')

        with codecs.open(path, encoding='utf-8') as f:
            expected_xml = f.read()
            self.assertXFormEqual(survey.to_xml(), expected_xml)

            survey = create_survey_element_from_json(survey.to_json())
            self.assertXFormEqual(survey.to_xml(), expected_xml)
Example #9
0
def build_survey(filename):
    path = path_to_text_fixture(filename)
    return create_survey_from_path(path)
Example #10
0
 def test_settings(self):
     survey = create_survey_from_path(self.path)
     self.assertEqual(survey.id_string, "new_id")
     self.assertEqual(survey.title, "My Survey")
Example #11
0
def build_survey(filename):
    path = path_to_text_fixture(filename)
    return create_survey_from_path(path)
Example #12
0
 def test_create_from_path(self):
     path = utils.path_to_text_fixture("tutorial.xls")
     create_survey_from_path(path)
Example #13
0
 def test_create_from_path(self):
     path = utils.path_to_text_fixture("tutorial.xls")
     survey = create_survey_from_path(path)
     print survey.to_xml()