def setUpClass(cls): super(AppAwareSyncTests, cls).setUpClass() delete_all_users() cls.domain_obj = create_domain(cls.domain) toggles.MOBILE_UCR.set(cls.domain, True, toggles.NAMESPACE_DOMAIN) cls.user = create_restore_user(cls.domain) cls.app1 = Application.new_app(cls.domain, 'Test App 1') cls.report_config1 = get_sample_report_config() cls.report_config1.domain = cls.domain cls.report_config1.save() report_app_config = { 'report_id': cls.report_config1.get_id, 'uuid': '123456' } module = cls.app1.add_module(ReportModule.new_module('Reports', None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app1.save() cls.app2 = Application.new_app(cls.domain, 'Test App 2') cls.report_config2 = get_sample_report_config() cls.report_config2.domain = cls.domain cls.report_config2.save() report_app_config = { 'report_id': cls.report_config2.get_id, 'uuid': 'abcdef' } module = cls.app2.add_module(ReportModule.new_module('Reports', None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app2.save() cls.app3 = Application.new_app(cls.domain, 'Test App 3') cls.app3.save()
def setUpClass(cls): create_domain(cls.domain) toggles.MOBILE_UCR.set(cls.domain, True, toggles.NAMESPACE_DOMAIN) cls.user = CommCareUser.create(cls.domain, 'john_doe', 's3cr3t') cls.app1 = Application.new_app(cls.domain, 'Test App 1', application_version=APP_V2) cls.report_config1 = get_sample_report_config() cls.report_config1.save() report_app_config = { 'report_id': cls.report_config1.get_id, 'uuid': '123456' } module = cls.app1.add_module(ReportModule.new_module('Reports', None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app1.save() cls.app2 = Application.new_app(cls.domain, 'Test App 2', application_version=APP_V2) cls.report_config2 = get_sample_report_config() cls.report_config2.save() report_app_config = { 'report_id': cls.report_config2.get_id, 'uuid': 'abcdef' } module = cls.app2.add_module(ReportModule.new_module('Reports', None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app2.save() cls.app3 = Application.new_app(cls.domain, 'Test App 3', application_version=APP_V2) cls.app3.save()
def apps_modules_setup(test_case): """ Additional setUp and tearDown for get_apps_modules tests """ test_case.app.add_module(Module.new_module("Module0", "en")) test_case.app.save() test_case.other_app = Application.new_app(test_case.project.name, "OtherApp") test_case.other_app.add_module(Module.new_module("Module0", "en")) test_case.other_app.save() test_case.deleted_app = Application.new_app(test_case.project.name, "DeletedApp") test_case.deleted_app.add_module(Module.new_module("Module0", "en")) test_case.deleted_app.save() test_case.deleted_app.delete_app() test_case.deleted_app.save() # delete_app() changes doc_type. This save() saves that. test_case.linked_app = create_linked_app(test_case.project.name, test_case.app.id, test_case.project.name, 'LinkedApp') try: yield finally: Application.get_db().delete_doc(test_case.linked_app.id) Application.get_db().delete_doc(test_case.deleted_app.id) Application.get_db().delete_doc(test_case.other_app.id)
def setUpClass(cls): super(TestDelayedSchema, cls).setUpClass() cls.current_app = Application.new_app(cls.domain, "Untitled Application") cls.current_app._id = '1234' cls.current_app.version = 10 module = cls.current_app.add_module(Module.new_module('Untitled Module', None)) form = module.new_form("Untitled Form", 'en', attachment=cls.get_xml('basic_form').decode('utf-8')) form.xmlns = cls.xmlns cls.build = Application.new_app(cls.domain, "Untitled Application") cls.build._id = '5678' cls.build.copy_of = cls.current_app._id cls.build.version = 5 cls.build.has_submissions = True module = cls.build.add_module(Module.new_module('Untitled Module', None)) form = module.new_form("Untitled Form", 'en', attachment=cls.get_xml('basic_form_version2').decode('utf-8')) form.xmlns = cls.xmlns cls.apps = [ cls.current_app, cls.build, ] with drop_connected_signals(app_post_save): for app in cls.apps: app.save()
def setUpClass(cls): delete_all_users() create_domain(cls.domain) toggles.MOBILE_UCR.set(cls.domain, True, toggles.NAMESPACE_DOMAIN) cls.user = create_restore_user(cls.domain) cls.app1 = Application.new_app(cls.domain, "Test App 1") cls.report_config1 = get_sample_report_config() cls.report_config1.domain = cls.domain cls.report_config1.save() report_app_config = {"report_id": cls.report_config1.get_id, "uuid": "123456"} module = cls.app1.add_module(ReportModule.new_module("Reports", None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app1.save() cls.app2 = Application.new_app(cls.domain, "Test App 2") cls.report_config2 = get_sample_report_config() cls.report_config2.domain = cls.domain cls.report_config2.save() report_app_config = {"report_id": cls.report_config2.get_id, "uuid": "abcdef"} module = cls.app2.add_module(ReportModule.new_module("Reports", None)) module.report_configs = [ReportAppConfig.wrap(report_app_config)] cls.app2.save() cls.app3 = Application.new_app(cls.domain, "Test App 3") cls.app3.save()
def _setup_apps(cls): cls.non_wam_app = Application.new_app(cls.DOMAIN_NAME, "app 1") cls.wam_app = Application.new_app(cls.DOMAIN_NAME, "app 2") cls.wam_app.amplifies_workers = AMPLIFIES_YES cls.non_wam_app.save() cls.wam_app.save() cls.non_wam_app_id = cls.non_wam_app._id cls.wam_app_id = cls.wam_app._id
def test_case_list_registration_form_advanced(self): app = Application.new_app('domain', "Untitled Application", application_version=APP_V2) register_module = app.add_module(AdvancedModule.new_module('create', None)) register_module.unique_id = 'register_module' register_module.case_type = 'dugong' register_form = app.new_form(0, 'Register Case', lang='en') register_form.unique_id = 'register_case_form' register_form.actions.open_cases.append(AdvancedOpenCaseAction( case_type='dugong', case_tag='open_dugong', name_path='/data/name' )) case_module = app.add_module(AdvancedModule.new_module('update', None)) case_module.unique_id = 'case_module' case_module.case_type = 'dugong' update_form = app.new_form(1, 'Update Case', lang='en') update_form.unique_id = 'update_case_form' update_form.actions.load_update_cases.append(LoadUpdateAction( case_type='dugong', case_tag='load_dugong', details_module=case_module.unique_id )) case_module.case_list_form.form_id = register_form.get_unique_id() case_module.case_list_form.label = { 'en': 'Register another Dugong' } self.assertXmlEqual(self.get_xml('case-list-form-advanced'), app.create_suite())
def setUp(self): self.domain = 'test-domain' create_domain(self.domain) self.app = Application.new_app(self.domain, "TestApp", application_version=APP_V1) for i in range(3): module = self.app.new_module("Module%d" % i, "en") for j in range(3): self.app.new_form(module.id, name="Form%s-%s" % (i,j), attachment=self.xform_str, lang="en") module = self.app.get_module(i) detail = module.get_detail("ref_short") detail.append_column( DetailColumn(name={"en": "test"}, model="case", field="test", format="plain", enum={}) ) detail.append_column( DetailColumn(name={"en": "age"}, model="case", field="age", format="years-ago", enum={}) ) self.app.save() self.build1 = {'version': '1.2.dev', 'build_number': 7106} self.build2 = {'version': '2.7.0', 'build_number': 20655} def add_build(version, build_number): path = os.path.join(os.path.dirname(__file__), "jadjar") jad_path = os.path.join(path, 'CommCare_%s_%s.zip' % (version, build_number)) CommCareBuild.create_from_zip(jad_path, version, build_number) add_build(**self.build1) add_build(**self.build2)
def build_app_with_bad_form(self, mock): """ Generates an app with one normal form, and one form with "undefined" xmlns Generates submissions against both forms. """ xmlns = generate_random_xmlns() good_form_name = "Untitled Form" bad_form_name = "Bad Form" app = Application.new_app(DOMAIN, 'Normal App') module = app.add_module(Module.new_module('New Module', lang='en')) good_form_source = self.get_xml('form_template').decode('utf-8').format(xmlns=xmlns, name=good_form_name) good_form = module.new_form(good_form_name, "en", good_form_source) bad_form_source = self.get_xml('form_template').decode('utf-8').format( xmlns="undefined", name=bad_form_name) bad_form = module.new_form(bad_form_name, "en", bad_form_source) app.save() build = app.make_build() build.save() good_xform = self._submit_form(xmlns, good_form_name, app._id, build._id) bad_xforms = [] for i in range(2): bad_xform = self._submit_form("undefined", bad_form_name, app._id, build._id) bad_xforms.append(bad_xform) return good_form, bad_form, good_xform, bad_xforms
def test_all_media_report_module(self): """ Report Modules support media """ from corehq.apps.userreports.tests.utils import get_sample_report_config app = Application.new_app('domain', "Untitled Application") report_module = app.add_module(ReportModule.new_module('Reports', None)) report_module.unique_id = 'report_module' report = get_sample_report_config() report._id = 'd3ff18cd83adf4550b35db8d391f6008' report_app_config = ReportAppConfig(report_id=report._id, header={'en': 'CommBugz'}, complete_graph_configs={ chart.chart_id: GraphConfiguration( series=[GraphSeries() for c in chart.y_axis_columns], ) for chart in report.charts }) report_app_config._report = report report_module.report_configs = [report_app_config] report_module._loaded = True image_path = 'jr://file/commcare/case_list_image.jpg' audio_path = 'jr://file/commcare/case_list_audo.mp3' app.get_module(0).media_image.update({'en': image_path}) app.get_module(0).media_audio.update({'en': audio_path}) self.assertTrue(app.get_module(0).uses_media()) self.assertEqual(len(app.all_media()), 2)
def test_subcase_repeat_mixed_form(self): app = Application.new_app(None, "Untitled Application", application_version=APP_V2) module_0 = app.add_module(Module.new_module('parent', None)) module_0.unique_id = 'm0' module_0.case_type = 'parent' form = app.new_form(0, "Form", None, attachment=self.get_xml('subcase_repeat_mixed_form_pre')) module_1 = app.add_module(Module.new_module('subcase', None)) module_1.unique_id = 'm1' module_1.case_type = 'subcase' form.actions.open_case = OpenCaseAction(name_path="/data/parent_name") form.actions.open_case.condition.type = 'always' form.actions.subcases.append(OpenSubCaseAction( case_type=module_1.case_type, case_name="/data/first_child_name", condition=FormActionCondition(type='always') )) # subcase in the middle that has a repeat context form.actions.subcases.append(OpenSubCaseAction( case_type=module_1.case_type, case_name="/data/repeat_child/repeat_child_name", repeat_context='/data/repeat_child', condition=FormActionCondition(type='always') )) form.actions.subcases.append(OpenSubCaseAction( case_type=module_1.case_type, case_name="/data/last_child_name", condition=FormActionCondition(type='always') )) self.assertXmlEqual(self.get_xml('subcase_repeat_mixed_form_post'), app.get_module(0).get_form(0).render_xform())
def test_all_media_report_module(self): """ Report Modules don't support media """ from corehq.apps.userreports.tests import get_sample_report_config app = Application.new_app('domain', "Untitled Application", application_version=APP_V2) report_module = app.add_module(ReportModule.new_module('Reports', None)) report_module.unique_id = 'report_module' report = get_sample_report_config() report._id = 'd3ff18cd83adf4550b35db8d391f6008' report_app_config = ReportAppConfig(report_id=report._id, header={'en': 'CommBugz'}) report_app_config._report = report report_module.report_configs = [report_app_config] report_module._loaded = True image_path = 'jr://file/commcare/case_list_image.jpg' audo_path = 'jr://file/commcare/case_list_audo.mp3' app.get_module(0).case_list_form.media_image = image_path app.get_module(0).case_list_form.media_audio = audo_path self.assertFalse(app.get_module(0).uses_media()) self.assertEqual(len(app.all_media), 0)
def setUp(self): self.app = Application.new_app(DOMAIN, "Untitled Application") self.module = self.app.add_module(Module.new_module("Untitled Module", None)) self.app.new_form(0, "Untitled Form", None) self.module.case_type = 'case' self.module.search_config = CaseSearch( command_label={'en': 'Search Patients Nationally'}, properties=[ CaseSearchProperty(name='name', label={'en': 'Name'}), CaseSearchProperty(name='dob', label={'en': 'Date of birth'}) ], relevant="{} and {}".format("instance('groups')/groups/group", CLAIM_DEFAULT_RELEVANT_CONDITION), default_properties=[ DefaultCaseSearchProperty( property=u'ɨŧsȺŧɍȺᵽ', defaultValue=( u"instance('casedb')/case" u"[@case_id='instance('commcaresession')/session/data/case_id']" u"/ɨŧsȺŧɍȺᵽ") ), DefaultCaseSearchProperty( property='name', defaultValue="instance('locations')/locations/location[@id=123]/@type", ), ], )
def test_all_media_report_module(self): """ Report Modules don't support media """ from corehq.apps.userreports.tests import get_sample_report_config app = Application.new_app("domain", "Untitled Application", application_version=APP_V2) report_module = app.add_module(ReportModule.new_module("Reports", None)) report_module.unique_id = "report_module" report = get_sample_report_config() report._id = "d3ff18cd83adf4550b35db8d391f6008" report_app_config = ReportAppConfig(report_id=report._id, header={"en": "CommBugz"}) report_app_config._report = report report_module.report_configs = [report_app_config] report_module._loaded = True image_path = "jr://file/commcare/case_list_image.jpg" audio_path = "jr://file/commcare/case_list_audo.mp3" app.get_module(0).case_list_form.set_icon("en", image_path) app.get_module(0).case_list_form.set_audio("en", audio_path) self.assertFalse(app.get_module(0).uses_media()) self.assertEqual(len(app.all_media), 0)
def test_edit_commcare_profile(self, mock): app2 = Application.new_app(self.project.name, "TestApp2") app2.save() self.addCleanup(lambda: Application.get_db().delete_doc(app2.id)) data = { "custom_properties": { "random": "value", "another": "value" } } response = self.client.post(reverse('edit_commcare_profile', args=[self.project.name, app2._id]), json.dumps(data), content_type='application/json') content = json.loads(response.content) custom_properties = content["changed"]["custom_properties"] self.assertEqual(custom_properties["random"], "value") self.assertEqual(custom_properties["another"], "value") data = { "custom_properties": { "random": "changed", } } response = self.client.post(reverse('edit_commcare_profile', args=[self.project.name, app2._id]), json.dumps(data), content_type='application/json') content = json.loads(response.content) custom_properties = content["changed"]["custom_properties"] self.assertEqual(custom_properties["random"], "changed")
def setUp(self): self.app = Application.new_app('domain', 'New App') self.app.version = 3 self.module = self.app.add_module(Module.new_module('New Module', lang='en')) self.form = self.app.new_form(0, 'New Form', lang='en') self.module.case_type = 'test_case_type' self.form.source = self.get_xml('original_form', override_path=('data',))
def test_case_tile_pull_down(self): app = Application.new_app('domain', 'Untitled Application') module = app.add_module(Module.new_module('Untitled Module', None)) module.case_type = 'patient' module.case_details.short.use_case_tiles = True module.case_details.short.persist_tile_on_forms = True module.case_details.short.pull_down_tile = True module.case_details.short.columns = [ DetailColumn( header={'en': 'a'}, model='case', field='a', format='plain', case_tile_field='header' ), DetailColumn( header={'en': 'b'}, model='case', field='b', format='plain', case_tile_field='top_left' ), DetailColumn( header={'en': 'c'}, model='case', field='c', format='enum', enum=[ MappingItem(key='male', value={'en': 'Male'}), MappingItem(key='female', value={'en': 'Female'}), ], case_tile_field='sex' ), DetailColumn( header={'en': 'd'}, model='case', field='d', format='plain', case_tile_field='bottom_left' ), DetailColumn( header={'en': 'e'}, model='case', field='e', format='date', case_tile_field='date' ), ] form = app.new_form(0, "Untitled Form", None) form.xmlns = 'http://id_m0-f0' form.requires = 'case' self.assertXmlPartialEqual( self.get_xml('case_tile_pulldown_session'), app.create_suite(), "./entry/session" )
def test_edit_commcare_profile(self): app = Application.new_app(self.domain.name, "TestApp", application_version=APP_V2) app.save() data = { "custom_properties": { "random": "value", "another": "value" } } response = self.client.post(reverse('edit_commcare_profile', args=[self.domain.name, app._id]), json.dumps(data), content_type='application/json') content = json.loads(response.content) custom_properties = content["changed"]["custom_properties"] self.assertEqual(custom_properties["random"], "value") self.assertEqual(custom_properties["another"], "value") data = { "custom_properties": { "random": "changed", } } response = self.client.post(reverse('edit_commcare_profile', args=[self.domain.name, app._id]), json.dumps(data), content_type='application/json') content = json.loads(response.content) custom_properties = content["changed"]["custom_properties"] self.assertEqual(custom_properties["random"], "changed")
def setUp(self): self.app = Application.new_app('domain', 'New App', APP_V2) self.app.version = 3 self.module = self.app.new_module('New Module', lang='en') self.form = self.app.new_form(0, 'New Form', lang='en') self.module.case_type = 'test_case_type' self.form.source = self.get_xml('original')
def test_case_list_lookup_w_extras_and_responses(self): app = Application.new_app('domain', 'Untitled Application') module = app.add_module(Module.new_module('Untitled Module', None)) module.case_type = 'patient' module.case_details.short.lookup_enabled = True module.case_details.short.lookup_action = "callout.commcarehq.org.dummycallout.LAUNCH" module.case_details.short.lookup_extras = [ {'key': 'action_0', 'value': 'com.biometrac.core.SCAN'}, {'key': "action_1", 'value': "com.biometrac.core.IDENTIFY"}, ] module.case_details.short.lookup_responses = [ {"key": "match_id_0"}, {"key": "match_id_1"}, ] expected = """ <partial> <lookup action="callout.commcarehq.org.dummycallout.LAUNCH"> <extra key="action_0" value="com.biometrac.core.SCAN"/> <extra key="action_1" value="com.biometrac.core.IDENTIFY"/> <response key="match_id_0"/> <response key="match_id_1"/> </lookup> </partial> """ self.assertXmlPartialEqual( expected, app.create_suite(), "./detail/lookup" )
def get_test_app(self): app = Application.new_app("domain", "New App", APP_V2) app.version = 1 m0 = self._make_module(app, 0, "parent") m0.get_form(0).actions.subcases.append(OpenSubCaseAction(case_type="child", reference_id="parent")) m1 = self._make_module(app, 1, "child") m1.get_form(0).actions.subcases.append(OpenSubCaseAction(case_type="grand child", reference_id="parent")) m2 = self._make_module(app, 2, "grand child") m3 = app.add_module(AdvancedModule.new_module("Module3", lang="en")) m3.case_type = "other grand child" m3f0 = m3.new_form("other form", "en") m3f0.actions.load_update_cases.append(LoadUpdateAction(case_type="child", case_tag="child")) m3f0.actions.open_cases.append( AdvancedOpenCaseAction( name_path="/data/question1", case_type="other grand child", case_indices=[CaseIndex(tag="child")] ) ) m3f0.actions.open_cases[0].open_condition.type = "always" m2.parent_select = ParentSelect(active=True, module_id=m1.unique_id) m1.parent_select = ParentSelect(active=True, module_id=m0.unique_id) expected_hierarchy = {"parent": {"child": {"grand child": {}, "other grand child": {}}}} return app, expected_hierarchy
def build_app_with_recently_fixed_form(self, mock): """ Generates an app with a form that: - had an "undefined" xmlns - had forms submitted with the bad xmlns - had xmlns changed to something real - had forms submitted with real xmlns """ form_name = "Untitled Form" app = Application.new_app(DOMAIN, 'Normal App') module = app.add_module(Module.new_module('New Module', lang='en')) form_source = self.get_xml('form_template').decode('utf-8').format( xmlns="undefined", name=form_name ) form = module.new_form(form_name, "en", form_source) app.save() bad_build = app.make_build() bad_build.save() bad_xform = self._submit_form(form.xmlns, form_name, app._id, bad_build._id) xmlns = generate_random_xmlns() form = app.get_form(form.unique_id) form.source = self.get_xml('form_template').decode('utf-8').format( xmlns=xmlns, name=form_name ) form.xmlns = xmlns app.save() good_build = app.make_build() good_build.save() good_xform = self._submit_form(form.xmlns, form_name, app._id, good_build._id) return form, good_build, bad_build, good_xform, bad_xform
def test_download_file_bad_xform_404(self): ''' This tests that the `download_file` view returns HTTP code 404 for XML that cannot be generated... in some sense it does not exist. ''' app = Application.new_app(self.domain, "TestApp", application_version=APP_V1) module = app.add_module(Module.new_module("Module0", "en")) # These builds are checked in to the repo for use in tests build1 = {'version': '1.2.dev', 'build_number': 7106} build2 = {'version': '2.7.0', 'build_number': 20655} add_build(**build1) add_build(**build2) with open(os.path.join(os.path.dirname(__file__), "data", "invalid_form.xml")) as f: xform_str = f.read() app.new_form(module.id, name="Form0-0", attachment=xform_str, lang="en") app.save() response = self.client.get(reverse('app_download_file', kwargs=dict(domain=self.domain, app_id=app.get_id, path='modules-0/forms-0.xml'))) self.assertEqual(response.status_code, 404)
def setUp(self): self.app = Application.new_app("domain", "New App", APP_V2) self.app.version = 3 self.module = self.app.add_module(Module.new_module("New Module", lang="en")) self.form = self.app.new_form(0, "New Form", lang="en") self.module.case_type = "test_case_type" self.form.source = self.get_xml("original_form", override_path=("data",))
def __init__(self, domain='test', name='Untitled Application', build_version=None, include_xmlns=False): self.app = Application.new_app(domain, name) if build_version: self.app.build_spec.version = build_version self.slugs = {} self.include_xmlns = include_xmlns
def setUpClass(cls): cls.domain = 'test-languages' cls.pillow = AppPillow(online=False) completely_initialize_pillow_index(cls.pillow) cls.app1 = Application.new_app(cls.domain, 'My Application 1', APP_V2) cls.app1.langs = ['en', 'es'] cls.app1.save() cls.pillow.send_robust(cls.app1.to_json()) cls.app2 = Application.new_app(cls.domain, 'My Application 2', APP_V2) cls.app2.langs = ['fr'] cls.app2.save() cls.pillow.send_robust(cls.app2.to_json()) cls.pillow.get_es_new().indices.refresh(cls.pillow.es_index)
def make_app(self, spec): app = Application.new_app('domain', "Untitled Application", application_version=APP_V2) app.build_spec = BuildSpec.from_string('2.9.0/latest') case_type = "frog" for m_spec in spec["m"]: m_type = m_spec['type'] m_class = Module if m_type == 'basic' else AdvancedModule module = app.add_module(m_class.new_module(m_spec['name'], None)) module.unique_id = m_spec['name'] module.case_type = m_spec.get("case_type", "frog") module.root_module_id = m_spec.get("parent", None) for f_spec in m_spec['f']: form_name = f_spec["name"] form = app.new_form(module.id, form_name, None) form.unique_id = form_name for a_spec in f_spec.get('actions', []): if isinstance(a_spec, dict): action = a_spec['action'] case_type = a_spec.get("case_type", case_type) parent = a_spec.get("parent", None) else: action = a_spec if 'open' == action: if m_type == "basic": form.actions.open_case = OpenCaseAction(name_path="/data/question1") form.actions.open_case.condition.type = 'always' else: form.actions.open_cases.append(AdvancedOpenCaseAction( case_type=case_type, case_tag='open_{}'.format(case_type), name_path='/data/name' )) elif 'update' == action: if m_type == "basic": form.requires = 'case' form.actions.update_case = UpdateCaseAction(update={'question1': '/data/question1'}) form.actions.update_case.condition.type = 'always' else: form.actions.load_update_cases.append(LoadUpdateAction( case_type=case_type, case_tag='update_{}'.format(case_type), parent_tag=parent, )) elif 'open_subacse': if m_type == "basic": form.actions.subcases.append(OpenSubCaseAction( case_type=case_type, case_name="/data/question1", condition=FormActionCondition(type='always') )) else: form.actions.open_cases.append(AdvancedOpenCaseAction( case_type=case_type, case_tag='subcase_{}'.format(case_type), name_path='/data/name', parent_tag=parent )) return app
def setUp(self): self.app = Application.new_app('domain', "Untitled Application", application_version=APP_V2) self.app.build_langs = self.app.langs = ['en', 'afr', 'fra'] module1 = self.app.add_module(Module.new_module('module', None)) form1 = self.app.new_form(module1.id, "Untitled Form", None) form1.source = self.get_xml('initial_xform') self.form1_worksheet = self.get_worksheet('module1_form1')
def setUp(self): self.domain = Domain(name='test') self.domain.save() app = Application.new_app('test', "Test Application", lang='en') module = Module.new_module("Untitled Module", 'en') app.add_module(module) app.new_form(0, "Untitled Form", 'en') app.save()
def setUpClass(cls): cls.domain = 'test-languages' with trap_extra_setup(ConnectionError): cls.es = get_es_new() initialize_index_and_mapping(cls.es, APP_INDEX_INFO) cls.app1 = Application.new_app(cls.domain, 'My Application 1') cls.app1.langs = ['en', 'es'] cls.app1.save() send_to_elasticsearch('apps', cls.app1.to_json()) cls.app2 = Application.new_app(cls.domain, 'My Application 2') cls.app2.langs = ['fr'] cls.app2.save() send_to_elasticsearch('apps', cls.app2.to_json()) cls.es.indices.refresh(APP_INDEX_INFO.index)
def test(self): add_build(version='2.7.0', build_number=20655) domain = 'form-versioning-test' # set up inital app app = Application.new_app(domain, 'Foo', '2.0') app.modules.append(Module(forms=[Form(), Form()])) app.build_spec = BuildSpec.from_string('2.7.0/latest') app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format( xmlns='xmlns-0.0') app.get_module(0).get_form(1).source = BLANK_TEMPLATE.format( xmlns='xmlns-1') app.save() # make a build build1 = app.make_build(previous_version=None) build1.save() # modify first form app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format( xmlns='xmlns-0.1') app.save() # make second build build2 = app.make_build(previous_version=build1) build2.save() # modify first form app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format( xmlns='xmlns-0.2') app.save() app.save() app.save() # make third build build3 = app.make_build(previous_version=build2) build3.save() self.assertEqual(self.get_form_versions(build1), [1, 1]) self.assertEqual(self.get_form_versions(build2), [2, 1]) self.assertEqual(self.get_form_versions(build3), [5, 1]) # revert to build2 app = app.make_reversion_to_copy(build2) app.save() # make reverted build build4 = app.make_build(previous_version=build3) build4.save() self.assertEqual(self.get_form_versions(build4), [6, 1]) # copy app xxx_app = import_app(app.export_json(dump_json=False), domain) # make build of copy xxx_build1 = xxx_app.make_build(previous_version=None) xxx_build1.save() # modify first form of copy app xxx_app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format( xmlns='xmlns-0.xxx.0') xxx_app.save() # make second build of copy xxx_build2 = xxx_app.make_build(previous_version=xxx_build1) xxx_build2.save() self.assertEqual(self.get_form_versions(xxx_build1), [1, 1]) self.assertEqual(self.get_form_versions(xxx_build2), [2, 1])
def setUp(self): self.app = Application.new_app(self.domain.name, "TestApp") self.app.build_spec = BuildSpec.from_string('2.7.0/latest') self.client.login(username=self.username, password=self.password)
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_uuid = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) cls.report_configs_by_id = {cls.report_id: report_configuration} cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module( ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[ GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", ) ], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_uuid, )) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ { 'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c' }, { 'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b' }, { 'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b' }, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch( 'corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixture, = call_fixture_generator( report_fixture_generator, cls.user) cls.fixture = ElementTree.tostring(fixture)
def setUp(self): super().setUp() self.app = Application.new_app(DOMAIN, "Application with Shadow") self.app._id = '456' self.app.build_spec = BuildSpec(version='2.53.0', build_number=1) self.module = self.app.add_module(Module.new_module("Followup", None)) self.form = self.app.new_form(0, "Untitled Form", None, attachment=get_simple_form("xmlns1.0")) self.form.requires = 'case' self.module.case_type = 'case' self.module.case_details.long.columns.append( DetailColumn.wrap(dict( header={"en": "name"}, model="case", format="plain", field="whatever", )) ) self.module.search_config = CaseSearch( properties=[ CaseSearchProperty(name='name', label={'en': 'Name'}), CaseSearchProperty(name='favorite_color', label={'en': 'Favorite Color'}, itemset=Itemset( instance_id='item-list:colors', instance_uri='jr://fixture/item-list:colors', nodeset="instance('item-list:colors')/colors_list/colors", label='name', sort='name', value='value'), ) ], data_registry="myregistry", data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE, additional_registry_cases=["'another case ID'"], ) self.shadow_module = self.app.add_module(ShadowModule.new_module("Shadow", "en")) self.shadow_module.source_module_id = self.module.unique_id self.shadow_module.case_details.long.columns.append( DetailColumn.wrap(dict( header={"en": "name"}, model="case", format="plain", field="whatever", )) ) self.shadow_module.search_config = CaseSearch( properties=[ CaseSearchProperty(name='name', label={'en': 'Name'}), CaseSearchProperty(name='favorite_color', label={'en': 'Texture'}, itemset=Itemset( instance_id='item-list:textures', instance_uri='jr://fixture/item-list:textures', nodeset="instance('item-list:textures')/textures_list/textures", label='name', sort='name', value='value'), ) ], data_registry="myregistry", data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE, ) # wrap to have assign_references called self.app = Application.wrap(self.app.to_json()) # reset to newly wrapped module self.module = self.app.modules[0] self.shadow_module = self.app.modules[1]
def setUp(self): self.is_usercase_in_use_patch = patch('corehq.apps.app_manager.models.is_usercase_in_use') self.is_usercase_in_use_patch.start() self.app = Application.new_app('domain', 'New App') self.app.version = 3
def setUp(self): self.app = Application.new_app('domain', "my app") self.module = self.app.add_module(Module.new_module("Module 1", None)) self.form = self.app.new_form(0, "Form 1", None) self.min_spec = BuildSpec.from_string('2.21.0/latest') self.app.build_spec = self.min_spec
def test_suite_media_with_app_profile(self, *args): # Test that suite includes only media relevant to the profile app = Application.new_app('domain', "my app") app.add_module(Module.new_module("Module 1", None)) app.new_form(0, "Form 1", None) app.build_spec = BuildSpec.from_string('2.21.0/latest') app.build_profiles = OrderedDict({ 'en': BuildProfile(langs=['en'], name='en-profile'), 'hin': BuildProfile(langs=['hin'], name='hin-profile'), 'all': BuildProfile(langs=['en', 'hin'], name='all-profile'), }) app.langs = ['en', 'hin'] image_path = 'jr://file/commcare/module0_en.png' audio_path = 'jr://file/commcare/module0_en.mp3' app.get_module(0).set_icon('en', image_path) app.get_module(0).set_audio('en', audio_path) # Generate suites and default app strings for each profile suites = {} locale_ids = {} for build_profile_id in app.build_profiles.keys(): suites[build_profile_id] = app.create_suite( build_profile_id=build_profile_id) default_app_strings = app.create_app_strings( 'default', build_profile_id) locale_ids[build_profile_id] = { line.split('=')[0] for line in default_app_strings.splitlines() } # Suite should have only the relevant images media_xml = self.makeXML("modules.m0", "modules.m0.icon", "modules.m0.audio") self.assertXmlPartialEqual(media_xml, suites['all'], "././menu[@id='m0']/display") no_media_xml = self.XML_without_media("modules.m0") self.assertXmlPartialEqual(media_xml, suites['en'], "././menu[@id='m0']/display") no_media_xml = self.XML_without_media("modules.m0") self.assertXmlPartialEqual(no_media_xml, suites['hin'], "././menu[@id='m0']/text") # Default app strings should have only the relevant locales self.assertIn('modules.m0', locale_ids['all']) self.assertIn('modules.m0.icon', locale_ids['all']) self.assertIn('modules.m0.audio', locale_ids['all']) self.assertIn('modules.m0', locale_ids['en']) self.assertIn('modules.m0.icon', locale_ids['en']) self.assertIn('modules.m0.audio', locale_ids['en']) self.assertIn('modules.m0', locale_ids['hin']) self.assertNotIn('modules.m0.icon', locale_ids['hin']) self.assertNotIn('modules.m0.audio', locale_ids['hin'])
def construct_form(cls): app = Application.new_app('domain', 'New App') app.add_module(Module.new_module('New Module', lang='en')) form = app.new_form(0, 'MySuperSpecialForm', lang='en') return form
def test_case_detail_conditional_enum(self): app = Application.new_app('domain', 'Untitled Application') module = app.add_module(Module.new_module('Unititled Module', None)) module.case_type = 'patient' module.case_details.short.columns = [ DetailColumn( header={'en': 'Gender'}, model='case', field='gender', format='conditional-enum', enum=[ MappingItem(key="gender = 'male' and age <= 21", value={'en': 'Boy'}), MappingItem(key="gender = 'female' and age <= 21", value={'en': 'Girl'}), MappingItem(key="gender = 'male' and age > 21", value={'en': 'Man'}), MappingItem(key="gender = 'female' and age > 21", value={'en': 'Woman'}), ], ), ] key1_varname = hashlib.md5( "gender = 'male' and age <= 21").hexdigest()[:8] key2_varname = hashlib.md5( "gender = 'female' and age <= 21").hexdigest()[:8] key3_varname = hashlib.md5( "gender = 'male' and age > 21").hexdigest()[:8] key4_varname = hashlib.md5( "gender = 'female' and age > 21").hexdigest()[:8] icon_mapping_spec = """ <partial> <template> <text> <xpath function="if(gender = 'male' and age <= 21, $h{key1_varname}, if(gender = 'female' and age <= 21, $h{key2_varname}, if(gender = 'male' and age > 21, $h{key3_varname}, if(gender = 'female' and age > 21, $h{key4_varname}, ''))))"> <variable name="h{key4_varname}"> <locale id="m0.case_short.case_gender_1.enum.h{key4_varname}"/> </variable> <variable name="h{key2_varname}"> <locale id="m0.case_short.case_gender_1.enum.h{key2_varname}"/> </variable> <variable name="h{key3_varname}"> <locale id="m0.case_short.case_gender_1.enum.h{key3_varname}"/> </variable> <variable name="h{key1_varname}"> <locale id="m0.case_short.case_gender_1.enum.h{key1_varname}"/> </variable> </xpath> </text> </template> </partial> """.format( key1_varname=key1_varname, key2_varname=key2_varname, key3_varname=key3_varname, key4_varname=key4_varname, ) # check correct suite is generated self.assertXmlPartialEqual( icon_mapping_spec, app.create_suite(), './detail[@id="m0_case_short"]/field/template') # check app strings mapped correctly app_strings = commcare_translations.loads(app.create_app_strings('en')) self.assertEqual( app_strings[ 'm0.case_short.case_gender_1.enum.h{key1_varname}'.format( key1_varname=key1_varname, )], 'Boy') self.assertEqual( app_strings[ 'm0.case_short.case_gender_1.enum.h{key2_varname}'.format( key2_varname=key2_varname, )], 'Girl') self.assertEqual( app_strings[ 'm0.case_short.case_gender_1.enum.h{key3_varname}'.format( key3_varname=key3_varname, )], 'Man') self.assertEqual( app_strings[ 'm0.case_short.case_gender_1.enum.h{key4_varname}'.format( key4_varname=key4_varname, )], 'Woman')
def test_case_detail_icon_mapping(self): app = Application.new_app('domain', 'Untitled Application') module = app.add_module(Module.new_module('Untitled Module', None)) module.case_type = 'patient' module.case_details.short.columns = [ DetailColumn( header={'en': 'Age range'}, model='case', field='age', format='enum-image', enum=[ MappingItem(key='10', value={'en': 'jr://icons/10-year-old.png'}), MappingItem(key='age > 50', value={'en': 'jr://icons/old-icon.png'}), MappingItem(key='15%', value={'en': 'jr://icons/percent-icon.png'}), ], ), ] key1_varname = '10' key2_varname = hashlib.md5('age > 50').hexdigest()[:8] key3_varname = hashlib.md5('15%').hexdigest()[:8] icon_mapping_spec = """ <partial> <template form="image" width="13%"> <text> <xpath function="if(age = '10', $k{key1_varname}, if(age > 50, $h{key2_varname}, if(age = '15%', $h{key3_varname}, '')))"> <variable name="h{key2_varname}"> <locale id="m0.case_short.case_age_1.enum.h{key2_varname}"/> </variable> <variable name="h{key3_varname}"> <locale id="m0.case_short.case_age_1.enum.h{key3_varname}"/> </variable> <variable name="k{key1_varname}"> <locale id="m0.case_short.case_age_1.enum.k{key1_varname}"/> </variable> </xpath> </text> </template> </partial> """.format( key1_varname=key1_varname, key2_varname=key2_varname, key3_varname=key3_varname, ) # check correct suite is generated self.assertXmlPartialEqual(icon_mapping_spec, app.create_suite(), './detail/field/template[@form="image"]') # check icons map correctly app_strings = commcare_translations.loads(app.create_app_strings('en')) self.assertEqual( app_strings['m0.case_short.case_age_1.enum.h{key3_varname}'.format( key3_varname=key3_varname, )], 'jr://icons/percent-icon.png') self.assertEqual( app_strings['m0.case_short.case_age_1.enum.h{key2_varname}'.format( key2_varname=key2_varname, )], 'jr://icons/old-icon.png') self.assertEqual( app_strings['m0.case_short.case_age_1.enum.k{key1_varname}'.format( key1_varname=key1_varname, )], 'jr://icons/10-year-old.png')
def setUp(self): self.app = Application.new_app('domain', "Untitled Application") self.module = self.app.add_module( AdvancedModule.new_module('Untitled Module', None)) self.form = self.module.new_form("Untitled Form", None)
def setUp(self): self.app = Application.new_app('domain', "Untitled Application") self.module = self.app.add_module( Module.new_module('Untitled Module', None)) self.module.case_type = 'another_case_type' self.form = self.module.new_form("Untitled Form", None)
def _make_app(self, app_name): app = Application.new_app(self.domain, app_name) app.mobile_ucr_restore_version = MOBILE_UCR_VERSION_2 app.save() self.addCleanup(app.delete) return app
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_mobile_id = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' create_domain(cls.domain) cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) # also make a report with a hidden column cls.hidden_column_report_id = 'bd2a43018ad9463682165c1bc16347ac' cls.hidden_column_mobile_id = '45152061d8dc4d2a8d987a0568abe1ae' report_configuration_with_hidden_column = MAKE_REPORT_CONFIG( cls.domain, cls.hidden_column_report_id, columns=[ FieldColumn(type='field', aggregation="simple", column_id="color_94ec39e6", display="color", field="color_94ec39e6").to_json(), FieldColumn( type='field', aggregation="simple", column_id="hidden_color_94ec39e6", display="color", field="color_94ec39e6", visible=False, ).to_json(), ]) cls.report_configs_by_id = { cls.report_id: report_configuration, cls.hidden_column_report_id: report_configuration_with_hidden_column } cls.app = Application.new_app(cls.domain, "Report Filter Test App") report_module = cls.app.add_module( ReportModule.new_module("Report Module", 'en')) report_module.report_context_tile = True report_module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[ GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", ) ], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_mobile_id, )) report_module.report_configs.append( ReportAppConfig( report_id=cls.hidden_column_report_id, header={}, description="", complete_graph_configs={}, filters={}, uuid=cls.hidden_column_mobile_id, )) case_module = cls.app.add_module(Module.new_module( "Case Module", 'en')) case_module.case_type = "fish" case_module.report_context_tile = True case_form = case_module.new_form("Update Fish", None) case_form.requires = "case" case_form.xmlns = "http://openrosa.org/formdesigner/2423EFB5-2E8C-4B8F-9DA0-23FFFD4391AF" survey_module = cls.app.add_module( Module.new_module("Survey Module", 'en')) survey_module.report_context_tile = True survey_form = survey_module.new_form("Survey", None) survey_form.xmlns = "http://openrosa.org/formdesigner/2423EFB5-2E8C-4B8F-9DA0-23FFFD4391AE" with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ { 'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c' }, { 'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b' }, { 'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b' }, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch( 'corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixtures = call_fixture_generator( report_fixture_generator, cls.user) fixture = [ f for f in fixtures if f.attrib.get('id') == ReportFixturesProviderV1.id ][0] cls.fixture = ElementTree.tostring(fixture)
def setUp(self): self.app = Application.new_app('domain', 'New App') self.app.version = 3
def setUp(self): self.app = Application.new_app(DOMAIN, "Untitled Application") self.app._id = '123' self.app.build_spec = BuildSpec(version='2.35.0', build_number=1) self.module = self.app.add_module( Module.new_module("Untitled Module", None)) self.app.new_form(0, "Untitled Form", None) self.module.case_type = 'case' # chosen xpath just used to reference more instances - not considered valid to use in apps self.module.case_details.short.columns.append( DetailColumn.wrap( dict( header={"en": "report_name"}, model="case", format="calculate", field="whatever", calc_xpath="instance('reports')/report[1]/name", ))) self.module.case_details.short.columns.append( DetailColumn.wrap( dict( header={"en": "moon"}, model="case", format="calculate", field="whatever", calc_xpath= "instance('item-list:moons')/moons_list/moons[favorite='yes']/name", ))) self.module.case_details.short.columns.append( DetailColumn.wrap( dict( header={"en": "Parent's Whatever"}, model="case", format="plain", field="parent/whatever", ))) self.module.case_details.long.columns.append( DetailColumn.wrap( dict( header={"en": "ledger_name"}, model="case", format="calculate", field="whatever", calc_xpath="instance('ledgerdb')/ledgers/name/name", ))) self.module.search_config = CaseSearch( command_label={'en': 'Search Patients Nationally'}, properties=[ CaseSearchProperty(name='name', label={'en': 'Name'}), CaseSearchProperty(name='dob', label={'en': 'Date of birth'}) ], default_relevant=True, additional_relevant="instance('groups')/groups/group", search_filter= "name = instance('item-list:trees')/trees_list/trees[favorite='yes']/name", default_properties=[ DefaultCaseSearchProperty( property='ɨŧsȺŧɍȺᵽ', defaultValue= ("instance('casedb')/case" "[@case_id='instance('commcaresession')/session/data/case_id']" "/ɨŧsȺŧɍȺᵽ")), DefaultCaseSearchProperty( property='name', defaultValue= "instance('locations')/locations/location[@id=123]/@type", ), ], )
def setUp(self): super(BulkUiTranslation, self).setUp() self.app = Application.new_app("test-domain", "Test App") self.app.langs = ["en", "fra"]
def setUp(self): self.app = Application.new_app('domain', "Application") self.module = self.app.add_module(Module.new_module('module', None)) self.form = self.app.new_form(self.module.id, "Form", None) self.assertNotEqual(self.form.xmlns, DEFAULT_XMLNS)
def test_report_module(self): from corehq.apps.userreports.tests.utils import get_sample_report_config app = Application.new_app('domain', "Untitled Application", application_version=APP_V2) report_module = app.add_module(ReportModule.new_module( 'Reports', None)) report_module.unique_id = 'report_module' report = get_sample_report_config() report._id = 'd3ff18cd83adf4550b35db8d391f6008' report_app_config = ReportAppConfig( report_id=report._id, header={'en': 'CommBugz'}, uuid='ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i', xpath_description='"report description"', use_xpath_description=True) report_app_config._report = report report_module.report_configs = [report_app_config] report_module._loaded = True self.assertXmlPartialEqual( self.get_xml('reports_module_menu'), app.create_suite(), "./menu", ) app.multimedia_map = { "jr://file/commcare/image/module0_en.png": HQMediaMapItem( multimedia_id='bb4472b4b3c702f81c0b208357eb22f8', media_type='CommCareImage', unique_id='fe06454697634053cdb75fd9705ac7e6', ), } report_module.media_image = { 'en': 'jr://file/commcare/image/module0_en.png', } self.assertXmlPartialEqual( self.get_xml('reports_module_menu_multimedia'), app.create_suite(), "./menu", ) self.assertXmlPartialEqual( self.get_xml('reports_module_select_detail'), app.create_suite(), "./detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.select']", ) self.assertXmlPartialEqual( self.get_xml( 'reports_module_summary_detail_use_xpath_description'), app.create_suite(), "./detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.summary']", ) self.assertXmlPartialEqual( self.get_xml('reports_module_data_detail'), app.create_suite(), "./detail/detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.data']", ) self.assertXmlPartialEqual( self.get_xml('reports_module_data_entry'), app.create_suite(), "./entry", ) self.assertIn( 'reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i=CommBugz', app.create_app_strings('default'), ) report_app_config.use_xpath_description = False self.assertXmlPartialEqual( self.get_xml( 'reports_module_summary_detail_use_localized_description'), app.create_suite(), "./detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.summary']", ) report_app_config._report.columns[0]['transform'] = { 'type': 'translation', 'translations': { u'एक': [ ['en', 'one'], ['es', 'uno'], ], '2': [ ['en', 'two'], ['es', 'dos\''], ['hin', u'दो'], ], } } report_app_config._report = ReportConfiguration.wrap( report_app_config._report._doc) self.assertXmlPartialEqual( self.get_xml('reports_module_data_detail-translated'), app.create_suite(), "./detail/detail[@id='reports.ip1bjs8xtaejnhfrbzj2r6v1fi6hia4i.data']", )
def __init__(self, domain='test', name='Untitled Application', build_version=None): self.app = Application.new_app(domain, name) if build_version: self.app.build_spec.version = build_version self.slugs = {}
def setUpClass(cls): super(BulkUiTranslation, cls).setUpClass() cls.app = Application.new_app("test-domain", "Test App") cls.app.langs = ["en", "fra"]