def setUpClass(cls): super(TestAppGetters, cls).setUpClass() cls.project = Domain(name=cls.domain) cls.project.save() app_doc = Application(domain=cls.domain, name='foo', langs=["en"], version=1, modules=[Module()]).to_json() app = Application.wrap(app_doc) # app is v1 app.save() # app is v2 cls.v2_build = app.make_build() cls.v2_build.is_released = True cls.v2_build.save() # There is a starred build at v2 app.save() # app is v3 app.make_build().save() # There is a build at v3 app.save() # app is v4 cls.app_id = app._id
def test_repeat_subcases_schema_generation(self): module = Module(case_type='child', _parent=Application()) form = Form().with_id(0, module) form.actions.subcases = [ OpenSubCaseAction(repeat_context='/data/repeat', case_properties={ 'weight': '/data/repeat/group/weight', }, subcase_index=0, _nest=True).with_id(0, None), OpenSubCaseAction(repeat_context='/data/repeat', case_properties={ 'height': '/data/repeat/height', }, subcase_index=1, _nest=True).with_id(1, None), OpenSubCaseAction(repeat_context='/data/repeat/nested_repeat', case_properties={ 'age': '/data/repeat/nested_repeat/age', }, subcase_index=2, _nest=False).with_id(2, None), ] schema = FormExportDataSchema._add_export_items_for_cases( ExportGroupSchema(path=MAIN_TABLE), [form], ['/data/repeat', '/data/nested_repeat'], )[0] self.assertEqual(len(schema.group_schemas), len(form.actions.subcases)) for group_schema, action in zip(schema.group_schemas, form.actions.subcases): base_path = 'form.{}'.format(action.repeat_context[6:].replace( '/', '.')) if action._nest: base_path += '.{}'.format(action.form_element_name) self._check_subcase_repeat_group_schema( group_schema, list(action.case_properties), base_path)
def handle(self, from_domain, from_app_id, to_domain, *args, **options): self.from_domain = from_domain self.to_domain = to_domain to_app_id = options.get('to-app-id') version = options.get('version') if to_app_id: app = get_current_app(self.to_domain, to_app_id) print('Overwriting application: {}'.format(app.name)) else: print('Creating new application') app = Application() if version: from_app_doc = get_build_doc_by_version(self.from_domain, from_app_id, version) else: from_app_doc = get_latest_released_app_doc(self.from_domain, from_app_id) if not from_app_doc: raise CommandError("From app not found") from_app = wrap_app(from_app_doc) print('Overwring app with "{}" (version {})'.format(from_app.name, from_app.version)) overwrite_app(app, from_app, self.report_map)
def setUpClass(cls): super(ExportsFormsAnalyticsTest, cls).setUpClass() from casexml.apps.case.tests.util import delete_all_xforms from corehq.apps.app_manager.models import Application, Module, Form delete_all_xforms() with trap_extra_setup(ConnectionError, msg="cannot connect to elasicsearch"): cls.es = get_es_new() initialize_index_and_mapping(cls.es, XFORM_INDEX_INFO) cls.domain = 'exports_forms_analytics_domain' cls.app_id_1 = 'a' + uuid.uuid4().hex cls.app_id_2 = 'b' + uuid.uuid4().hex cls.xmlns_1 = 'my://crazy.xmlns/' cls.xmlns_2 = 'my://crazy.xmlns/app' cls.apps = [ Application(_id=cls.app_id_2, domain=cls.domain, modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])]) ] for app in cls.apps: app.save() cls.forms = [ XFormInstance(domain=cls.domain, app_id=cls.app_id_1, xmlns=cls.xmlns_1), XFormInstance(domain=cls.domain, app_id=cls.app_id_1, xmlns=cls.xmlns_1), XFormInstance(domain=cls.domain, app_id=cls.app_id_2, xmlns=cls.xmlns_2), ] cls.error_forms = [XFormError(domain=cls.domain)] cls.all_forms = cls.forms + cls.error_forms for form in cls.all_forms: form.save() send_to_elasticsearch('forms', form.to_json()) cls.es.indices.refresh(XFORM_INDEX_INFO.index) update_analytics_indexes()
def test_repeat_record_created(self): ''' Tests that whenever an application with a repeater is saved that a repeat record is created. ''' application = Application(domain=self.domain) application.save() repeat_records = RepeatRecord.all(domain=self.domain, due_before=datetime.utcnow()) self.assertEqual(len(repeat_records), 0) app_structure_repeater = AppStructureRepeater(domain=self.domain, url=self.forwarding_url) app_structure_repeater.save() application.save() repeat_records = RepeatRecord.all(domain=self.domain, due_before=datetime.utcnow()) self.assertEqual(len(repeat_records), 1) for repeat_record in repeat_records: self.assertEqual(repeat_record.url, self.forwarding_url) self.assertEqual(repeat_record.get_payload(), application.get_id) repeat_record.delete() application.delete() app_structure_repeater.delete()
def setUp(self): self.app = Application(build_spec=BuildSpec(version='2.7.0'))
def setUp(self): self.app = Application(build_spec=BuildSpec(version='2.7.0'), name="TÉST ÁPP", domain="potter", langs=['en'])