当前位置: 首页>>代码示例>>Python>>正文


Python app_factory.AppFactory类代码示例

本文整理汇总了Python中corehq.apps.app_manager.tests.app_factory.AppFactory的典型用法代码示例。如果您正苦于以下问题:Python AppFactory类的具体用法?Python AppFactory怎么用?Python AppFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AppFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_that_grid_style_is_added

    def test_that_grid_style_is_added(self):
        """
        Confirms that style="grid" is added to the root menu
        """
        factory = AppFactory(build_version='2.24.0')
        factory.app.use_grid_menus = True
        factory.new_basic_module('registration', 'patient registration')
        factory.app.get_module(0).put_in_root = True
        factory.new_basic_module('visit', 'patient visit')
        factory.app.get_module(1).put_in_root = True

        suite = factory.app.create_suite()
        root_xpath = './menu[@id="root"]'
        self.assertXmlHasXpath(suite, root_xpath)
        self.assertXmlPartialEqual(
            """
            <partial>
                <menu id="root" style="grid">
                    <text><locale id="modules.m0"/></text>
                    <command id="m0-f0"/>
                </menu>
                <menu id="root" style="grid">
                    <text><locale id="modules.m1"/></text>
                    <command id="m1-f0"/>
                </menu>
            </partial>
            """,
            suite,
            root_xpath
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:test_grid_menus.py

示例2: _BaseTestAppDiffs

class _BaseTestAppDiffs(object):
    def setUp(self):
        super(_BaseTestAppDiffs, self).setUp()

        self.factory1 = AppFactory()
        self.app1 = self.factory1.app
        self.factory1.new_basic_module('module_1', 'case')

        self.factory2 = AppFactory()
        self.app2 = self.factory2.app
        self.factory2.new_basic_module('module_1', 'case')

    def _add_question(self, form, options=None):
        if options is None:
            options = {'name': 'name', 'label': "Name"}
        if 'name' not in options:
            options['name'] = 'name'
        if 'label' not in options:
            options['label'] = "Name"

        builder = XFormBuilder(form.name, form.source if form.source else None)
        builder.new_question(**options)
        form.source = builder.tostring(pretty_print=True).decode('utf-8')

    def _add_question_to_group(self, form, options):
        builder = XFormBuilder(form.name, form.source if form.source else None)
        group_name = options['group']
        builder.new_group(group_name, group_name)
        builder.new_question(**options)
        form.source = builder.tostring(pretty_print=True).decode('utf-8')
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:test_app_diffs.py

示例3: _get_app

 def _get_app(self):
     from corehq.apps.app_manager.tests.app_factory import AppFactory
     factory = AppFactory()
     factory.new_basic_module('m0', 'case1')
     factory.new_basic_module('m1', 'case2')
     factory.new_advanced_module('m2', 'case3')
     return factory.app
开发者ID:dimagi,项目名称:commcare-hq,代码行数:7,代码来源:test_use_fixtures_configuration.py

示例4: test_scheduler_module

    def test_scheduler_module(self):
        factory = AppFactory()
        m1, m1f1 = factory.new_basic_module('open_case', 'house')
        factory.form_opens_case(m1f1)
        m2, m2f1 = factory.new_advanced_module('scheduler_module', 'house')
        m2f2 = factory.new_form(m2)
        factory.form_requires_case(m2f1, case_type='house', update={
            'foo': '/data/question1',
            'bar': '/data/question2',
        })
        factory.form_requires_case(m2f2, case_type='house', update={
            'bleep': '/data/question1',
            'bloop': '/data/question2',
        })

        self._add_scheduler_to_module(m2)
        self._add_scheduler_to_form(m2f1, m2, 'form1')
        self._add_scheduler_to_form(m2f2, m2, 'form2')

        self.assertCaseProperties(factory.app, 'house', [
            'foo',
            'bar',
            'bleep',
            'bloop',
            # Scheduler properties:
            'last_visit_date_form1',
            'last_visit_number_form1',
            'last_visit_date_form2',
            'last_visit_number_form2',
            'current_schedule_phase',
        ])
开发者ID:dimagi,项目名称:commcare-hq,代码行数:31,代码来源:test_case_properties.py

示例5: test_default_app_strings_with_build_profiles

    def test_default_app_strings_with_build_profiles(self):
        factory = AppFactory(build_version='2.40.0')
        factory.app.langs = ['en', 'es']
        factory.app.build_profiles = OrderedDict({
            'en': BuildProfile(langs=['en'], name='en-profile'),
            'es': BuildProfile(langs=['es'], name='es-profile'),
        })
        module, form = factory.new_basic_module('my_module', 'cases')
        module.name = {
            'en': 'Alive',
            'es': 'Viva',
        }
        form.name = {
            'en': 'Human',
            'es': 'Humana',
        }

        all_default_strings = self._generate_app_strings(factory.app, 'default')
        self.assertEqual(all_default_strings['modules.m0'], module.name['en'])
        self.assertEqual(all_default_strings['forms.m0f0'], form.name['en'])

        en_default_strings = self._generate_app_strings(factory.app, 'default', build_profile_id='en')
        self.assertEqual(en_default_strings['modules.m0'], module.name['en'])
        self.assertEqual(en_default_strings['forms.m0f0'], form.name['en'])

        es_default_strings = self._generate_app_strings(factory.app, 'default', build_profile_id='es')
        self.assertEqual(es_default_strings['modules.m0'], module.name['es'])
        self.assertEqual(es_default_strings['forms.m0f0'], form.name['es'])
开发者ID:dimagi,项目名称:commcare-hq,代码行数:28,代码来源:test_translations.py

示例6: test_grid_menu_for_none

    def test_grid_menu_for_none(self):
        factory = AppFactory(build_version='2.24.3')
        factory.app.create_profile()
        factory.app.grid_form_menus = 'none'
        factory.new_basic_module('registration', 'patient')
        factory.app.get_module(0).display_style = 'grid'
        root_xpath = './menu[@id="root"]'
        m0_xpath = './menu[@id="m0"]'

        # with Modules Menu to be list should not render root menu and render module w/o style=grid
        factory.app.use_grid_menus = False
        suite = factory.app.create_suite()
        self.assertXmlDoesNotHaveXpath(suite, root_xpath)
        self.assertXmlPartialEqual(
            '<partial><menu id="m0"><text><locale id="modules.m0"/></text><command id="m0-f0"/></menu></partial>',
            suite,
            m0_xpath
        )

        # with Modules Menu to be grid should render root menu w/ style=grid and render module w/o style=grid
        factory.app.use_grid_menus = True
        suite = factory.app.create_suite()
        self.assertXmlPartialEqual(
            '<partial><menu id="root" style="grid"><text/></menu></partial>',
            suite,
            root_xpath
        )
        self.assertXmlPartialEqual(
            '<partial><menu id="m0"><text><locale id="modules.m0"/></text><command id="m0-f0"/></menu></partial>',
            suite,
            m0_xpath
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:32,代码来源:test_grid_menus.py

示例7: test_basic

    def test_basic(self):
        factory = AppFactory(build_version="2.9.0/latest")
        m0, m0f0 = factory.new_basic_module("m0", "frog")
        m1, m1f0 = factory.new_basic_module("m1", "frog")

        m0f0.post_form_workflow = WORKFLOW_FORM
        m0f0.form_links = [FormLink(xpath="(today() - dob) &lt; 7", form_id=m1f0.unique_id)]
        self.assertXmlPartialEqual(self.get_xml("form_link_basic"), factory.app.create_suite(), "./entry[1]")
开发者ID:ekush,项目名称:commcare-hq,代码行数:8,代码来源:test_form_workflow.py

示例8: _create_app

 def _create_app(self, name):
     factory = AppFactory(domain=self.domain, name=name, build_version='2.11.0')
     module1, form1 = factory.new_basic_module('open_case', 'house')
     factory.form_opens_case(form1)
     app = factory.app
     app.save()
     self.addCleanup(app.delete)
     return app
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:8,代码来源:test_app_pillow.py

示例9: setUpClass

    def setUpClass(cls):
        super(UCRAggregationTest, cls).setUpClass()
        # cleanup any previous data
        cls._cleanup_data()

        # setup app
        factory = AppFactory(domain=cls.domain)
        # parent case module, incl opening child cases of main type
        m_parent, f_parent = factory.new_basic_module('Parent Module', cls.parent_case_type)
        factory.form_opens_case(f_parent, case_type=cls.parent_case_type)
        factory.form_opens_case(f_parent, case_type=cls.case_type, is_subcase=True)

        # main module
        m0, f0 = factory.new_basic_module('A Module', cls.case_type)
        f1 = factory.new_form(m0)
        f1.source = cls._get_xform()
        factory.form_requires_case(f1, case_type=cls.case_type, update={
            cp[0]: '/data/{}'.format(cp[0]) for cp in cls.case_properties
        })
        cls.followup_form = f1

        cls.app = factory.app
        cls.app.save()

        # create form and case ucrs
        cls.form_data_source = get_form_data_source(cls.app, cls.followup_form)
        cls.case_data_source = get_case_data_source(cls.app, cls.case_type)
        cls.parent_case_data_source = get_case_data_source(cls.app, cls.parent_case_type)

        # create some data - first just create the case
        cls.parent_case_id = cls._create_parent_case(cls.parent_name)
        cls.case_id = cls._create_case(cls.parent_case_id)
        for fu_date in cls.fu_visit_dates:
            cls._submit_followup_form(cls.case_id, received_on=fu_date)

        # the closed case causes there to be some data with an end_column
        cls.closed_case_id = cls._create_closed_case()

        # populate the UCRs with the data we just created
        cls.form_adapter = get_indicator_adapter(cls.form_data_source)
        cls.case_adapter = get_indicator_adapter(cls.case_data_source)
        cls.parent_case_adapter = get_indicator_adapter(cls.parent_case_data_source)

        cls.form_adapter.rebuild_table()
        cls.case_adapter.rebuild_table()
        cls.parent_case_adapter.rebuild_table()

        _iteratively_build_table(cls.form_data_source)
        _iteratively_build_table(cls.case_data_source)
        _iteratively_build_table(cls.parent_case_data_source)

        # setup AggregateTableDefinition
        cls.monthly_aggregate_table_definition = cls._get_monthly_aggregate_table_definition()
        cls.weekly_aggregate_table_definition = cls._get_weekly_aggregate_table_definition()
        cls.basic_aggregate_table_definition = cls._get_basic_aggregate_table_definition()

        # and adapter
        cls.monthly_adapter = get_indicator_adapter(cls.monthly_aggregate_table_definition)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:58,代码来源:test_aggregation.py

示例10: setUp

    def setUp(self):
        super(_BaseTestAppDiffs, self).setUp()

        self.factory1 = AppFactory()
        self.app1 = self.factory1.app
        self.factory1.new_basic_module('module_1', 'case')

        self.factory2 = AppFactory()
        self.app2 = self.factory2.app
        self.factory2.new_basic_module('module_1', 'case')
开发者ID:dimagi,项目名称:commcare-hq,代码行数:10,代码来源:test_app_diffs.py

示例11: test_form_display_condition

    def test_form_display_condition(self):
        """
        case_id should be renamed in a basic submodule form
        """
        factory = AppFactory(domain=DOMAIN)
        m0, m0f0 = factory.new_advanced_module('parent', 'gold-fish')
        factory.form_requires_case(m0f0)

        # changing this case tag should result in the session var in the submodule entry being updated to match it
        m0f0.actions.load_update_cases[0].case_tag = 'load_goldfish_renamed'

        m1, m1f0 = factory.new_advanced_module('child', 'guppy', parent_module=m0)
        factory.form_requires_case(m1f0, 'gold-fish', update={'question1': '/data/question1'})
        factory.form_requires_case(m1f0, 'guppy', parent_case_type='gold-fish')

        # making this case tag the same as the one in the parent module should mean that it will also get changed
        # to avoid conflicts
        m1f0.actions.load_update_cases[1].case_tag = 'load_goldfish_renamed'

        m1f0.form_filter = "#case/age > 33"

        XML = """
        <partial>
          <menu id="m1" root="m0">
            <text>
              <locale id="modules.m1"/>
            </text>
            <command id="m1-f0" relevant="instance('casedb')/casedb/case[@case_id=instance('commcaresession')/session/data/case_id_load_goldfish_renamed_guppy]/age &gt; 33"/>
          </menu>
        </partial>
        """
        self.assertXmlPartialEqual(XML, factory.app.create_suite(), "./menu[@id='m1']")
开发者ID:dimagi,项目名称:commcare-hq,代码行数:32,代码来源:test_child_module.py

示例12: test_use_grid_menus_is_false

    def test_use_grid_menus_is_false(self):
        """
        Confirms that style="grid" is not added to any menus when use_grid_menus is False.
        """
        factory = AppFactory(build_version='2.24.0')
        factory.app.use_grid_menus = False
        factory.new_basic_module('registration', 'patient')

        suite = factory.app.create_suite()
        style_xpath = './menu[@style="grid"]'
        self.assertXmlDoesNotHaveXpath(suite, style_xpath)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:test_grid_menus.py

示例13: setUpClass

    def setUpClass(cls):
        super(TestCaseDelayedSchema, cls).setUpClass()
        factory = AppFactory(domain=cls.domain)
        module1, form1 = factory.new_basic_module('update_case', cls.case_type)
        factory.form_requires_case(form1, cls.case_type, update={
            'age': '/data/age',
            'height': '/data/height',
        })
        cls.current_app = factory.app
        cls.current_app._id = '1234'

        factory = AppFactory(domain=cls.domain)
        module1, form1 = factory.new_basic_module('update_case', cls.case_type)
        factory.form_requires_case(form1, cls.case_type, update={
            'age': '/data/age',
            'height': '/data/height',
            'weight': '/data/weight',
        })
        cls.build = factory.app
        cls.build.copy_of = cls.current_app._id
        cls.build.version = 5
        cls.build.has_submissions = True

        cls.apps = [
            cls.current_app,
            cls.build,
        ]
        with drop_connected_signals(app_post_save):
            for app in cls.apps:
                app.save()
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:test_export_data_schema.py

示例14: test_link_to_form_in_parent_module

    def test_link_to_form_in_parent_module(self):
        factory = AppFactory(build_version="2.9.0/latest")
        m0, m0f0 = factory.new_basic_module("enroll child", "child")
        factory.form_opens_case(m0f0)

        m1, m1f0 = factory.new_basic_module("child visit", "child")
        factory.form_updates_case(m1f0)

        m2, m2f0 = factory.new_advanced_module("visit history", "visit", parent_module=m1)
        factory.form_updates_case(m2f0, "child")

        # link to child -> edit child
        m2f0.post_form_workflow = WORKFLOW_FORM
        m2f0.form_links = [FormLink(xpath="true()", form_id=m1f0.unique_id)]

        self.assertXmlPartialEqual(self.get_xml("form_link_child_modules"), factory.app.create_suite(), "./entry[3]")
开发者ID:ekush,项目名称:commcare-hq,代码行数:16,代码来源:test_form_workflow.py

示例15: setUp

    def setUp(self):
        update_toggle_cache(MODULE_FILTER.slug, DOMAIN, True, NAMESPACE_DOMAIN)
        self.factory = AppFactory(domain=DOMAIN)
        self.module_0, _ = self.factory.new_basic_module('parent', 'gold-fish')
        self.module_1, _ = self.factory.new_module(self.child_module_class, 'child', 'guppy', parent_module=self.module_0)

        self.app = self.factory.app
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:7,代码来源:test_child_module.py


注:本文中的corehq.apps.app_manager.tests.app_factory.AppFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。