Beispiel #1
0
    def test_should_handle_questions_with_similar_label(self):
        self.data = [[
            "What is the reporting period for the activity?\n\n Answer must be a date in the following format: day.month.year\n\n Example: 25.12.2011",
            "Name", "Name 1"
        ], ["12.12.2012", "name11", "name12"],
                     ["11.11.2012", "name21", "name22"],
                     ["12.10.2012", "name31", "name32"]]
        field = TextField(name="Q3", code="NAME", label="Name")
        self.form_model.add_field(field)
        field = TextField(name="Q4", code="NAME1", label="Name 1")
        self.form_model.add_field(field)
        expected_ans_dict = [{
            'DATE': '12.12.2012',
            'NAME': 'name11',
            'NAME1': 'name12'
        }, {
            'DATE': '11.11.2012',
            'NAME': 'name21',
            'NAME1': 'name22'
        }, {
            'DATE': '12.10.2012',
            'NAME': 'name31',
            'NAME1': 'name32'
        }]

        self.assertEquals(
            expected_ans_dict,
            SubmissionWorkbookMapper(self.data, self.form_model).process())
Beispiel #2
0
 def test_submission_import_worksheet_should_have_datasender_id(self):
     self.add_datasender_col()
     ans_dict = SubmissionWorkbookMapper(self.data,
                                         self.form_model).process()
     self.assertEquals(
         None,
         SubmissionWorkbookValidator(self.form_model).validate(ans_dict))
Beispiel #3
0
 def test_validate_template_for_datasender(self):
     data = SubmissionWorkbookMapper(self.data, self.form_model).process()
     try:
         SubmissionWorkbookValidator(self.form_model).validate(data)
     except ImportValidationError as e:
         self.assertEquals(
             "The columns you are importing do not match the current Questionnaire. Please download the latest template for importing.",
             e.message)
Beispiel #4
0
 def test_process_submission_import_worksheet_test_for_datasender(self):
     self.add_datasender_col()
     ans_dict = SubmissionWorkbookMapper(self.data,
                                         self.form_model).process()
     try:
         SubmissionWorkbookValidator(self.form_model).validate(ans_dict)
     except ImportValidationError as e:
         self.assertEquals(
             "The columns you are importing do not match the current Questionnaire. Please download the latest template for importing.",
             e.message)
Beispiel #5
0
 def test_validate_template_for_datasender(self):
     data = SubmissionWorkbookMapper(self.data, self.form_model).process()
     try:
         SubmissionWorkbookValidator(self.form_model,
                                     is_org_user=False,
                                     is_summary_project=True).validate(data)
     except ImportValidationError as e:
         self.assertEquals(
             "The columns you are importing do not match. Please download the latest template for importing.",
             e.message)
Beispiel #6
0
 def test_should_process_submission_import_worksheet_for_datasender(self):
     expected_ans_dict = [{
         'DATE': '12.12.2012'
     }, {
         'DATE': '11.11.2012'
     }, {
         'DATE': '12.10.2012'
     }]
     self.assertEquals(
         expected_ans_dict,
         SubmissionWorkbookMapper(self.data, self.form_model).process())