def set_up_form(cls): cls.form_id = uuid4().hex user_id = uuid4().hex case_update = { 'year': '1970', 'breakfast': 'spam egg spam spam bacon spam', 'decimal': '4.4', } builder = FormSubmissionBuilder( form_id=cls.form_id, form_properties={ 'name': 'spam', **case_update, }, case_blocks=[ CaseBlock(case_id=uuid4().hex, create=True, case_type='sketch', case_name='spam', owner_id=user_id, update=case_update) ], metadata=TestFormMetadata( domain=cls.domain, user_id=user_id, ), ) submit_form_locally(builder.as_xml_string(), cls.domain) cls.form = FormAccessors(cls.domain).get_form(cls.form_id)
def form_context(form_ids): for form_id in form_ids: builder = FormSubmissionBuilder( form_id=form_id, metadata=TestFormMetadata(domain=DOMAIN), ) submit_form_locally(builder.as_xml_string(), DOMAIN) try: yield finally: XFormInstance.objects.hard_delete_forms(DOMAIN, form_ids)
def _submit_followup_form(cls, case_id, received_on): form_id = uuid.uuid4().hex form_meta = TestFormMetadata( domain=cls.domain, xmlns=cls.followup_form.xmlns, app_id=cls.app._id, received_on=received_on, ) properties = cls._get_case_property_values() caseblock = CaseBlock( case_id=case_id, update=properties, ) form_builder = FormSubmissionBuilder( form_id=form_id, metadata=form_meta, case_blocks=[caseblock], form_properties=properties, ) submit_form_locally(form_builder.as_xml_string(), cls.domain, received_on=received_on, app_id=cls.app._id) return form_id
def _submit_followup_form(cls, case_id, received_on): form_id = uuid.uuid4().hex form_meta = TestFormMetadata( domain=cls.domain, xmlns=cls.followup_form.xmlns, app_id=cls.app._id, received_on=received_on, ) properties = cls._get_case_property_values() caseblock = CaseBlock( case_id=case_id, update=properties, ) form_builder = FormSubmissionBuilder( form_id=form_id, metadata=form_meta, case_blocks=[caseblock], form_properties=properties, ) submit_form_locally(form_builder.as_xml_string(), cls.domain, received_on=received_on, app_id=cls.app._id) return form_id
def set_up_form(cls): cls.form_id = uuid4().hex user_id = uuid4().hex cls.case_update = { 'year': '1970', 'breakfast': 'spam egg spam spam bacon spam', 'price': '2.40', 'album_release': '1972-09-08', 'breakfast_oclock': '09:00:00', 'breakfast_exactly': '1972-09-08T09:00:00.000Z', } builder = FormSubmissionBuilder( form_id=cls.form_id, form_properties={ 'name': 'spam', **cls.case_update, }, case_blocks=[ CaseBlock(case_id=uuid4().hex, create=True, case_type='sketch', case_name='spam', owner_id=user_id, update=cls.case_update) ], metadata=TestFormMetadata( domain=cls.domain, user_id=user_id, ), ) submit_form_locally(builder.as_xml_string(), cls.domain) cls.form = FormAccessors(cls.domain).get_form(cls.form_id) form_json_gen = FormRepeaterJsonPayloadGenerator(None) cls.form_json_payload_info = cls.get_payload_info(form_json_gen) form_dict_gen = FormDictPayloadGenerator(None) cls.form_dict_payload_info = cls.get_payload_info(form_dict_gen)