Пример #1
0
 def handle(self,
            form_model,
            cleaned_data,
            errors,
            reporter_names=[],
            location_tree=None):
     form_submission = FormSubmissionFactory().get_form_submission(
         form_model, cleaned_data, errors, location_tree=location_tree)
     if form_submission.is_valid:
         form_submission.save(self.dbm)
     return create_response_from_form_submission(
         reporters=reporter_names, form_submission=form_submission)
Пример #2
0
    def test_should_create_global_form_submission_location_tree(self):
        form_model = self._construct_global_registration_form()
        submission = OrderedDict({"s": "1", "t": "Reporter", "l": "pune", "m": "1212121212"})
        with patch('mangrove.form_model.form_submission.GlobalRegistrationFormSubmission.create_entity') as create_entity:
            entity_mock = Mock(spec=Contact)
            entity_mock.add_data.return_value = 1
            create_entity.return_value = entity_mock

            location_tree = {1: 2}
            form_submission = FormSubmissionFactory().get_form_submission(form_model, submission,
                                                                          location_tree=location_tree)
            data_record_id = form_submission.save(self.dbm)
            self.assertEqual(1, data_record_id)
            self.assertEqual(form_submission.location_tree, location_tree)