本文整理汇总了Python中corehq.apps.app_manager.tests.app_factory.AppFactory.new_shadow_form方法的典型用法代码示例。如果您正苦于以下问题:Python AppFactory.new_shadow_form方法的具体用法?Python AppFactory.new_shadow_form怎么用?Python AppFactory.new_shadow_form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.app_manager.tests.app_factory.AppFactory
的用法示例。
在下文中一共展示了AppFactory.new_shadow_form方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShadowFormSuiteTest
# 需要导入模块: from corehq.apps.app_manager.tests.app_factory import AppFactory [as 别名]
# 或者: from corehq.apps.app_manager.tests.app_factory.AppFactory import new_shadow_form [as 别名]
class ShadowFormSuiteTest(SimpleTestCase, TestXmlMixin):
def setUp(self):
self.factory = AppFactory()
self.advanced_module, self.form0 = self.factory.new_advanced_module('advanced_module', 'patient')
self.form0.xmlns = 'http://openrosa.org/formdesigner/firstform'
self.form0.actions.open_cases = [
AdvancedOpenCaseAction(
case_type="patient",
case_tag="open__0",
)
]
self.form0.actions.load_update_cases = [
LoadUpdateAction(
case_type="patient",
case_tag="load_0",
case_properties={
"name": "/data/name"
},
preload={
"/data/name": "name"
},
details_module=self.advanced_module.unique_id,
)
]
self.shadow_form = self.factory.new_shadow_form(self.advanced_module)
self.shadow_form.shadow_parent_form_id = self.form0.unique_id
# Shadow form load_update_case actions should contain all case tags from the parent
self.shadow_form.extra_actions.load_update_cases = [
LoadUpdateAction(
case_type="patient",
case_tag="load_0",
details_module=self.advanced_module.unique_id,
)
]
self.basic_module = self.factory.new_basic_module("basic_module", "doctor", with_form=False)
def test_resource_not_added(self):
# Confirm that shadow forms do not add a <resource> node to the suite file
suite = self.factory.app.create_suite()
xpath = "./xform"
# Note that the advanced_module only has one form, because the shadow form does not contribute an xform
expected = """
<partial>
<xform>
<resource id="advanced_module_form_0">
<location authority="local">./modules-0/forms-0.xml</location>
<location authority="remote">./modules-0/forms-0.xml</location>
</resource>
</xform>
</partial>
"""
self.assertXmlPartialEqual(expected, suite, xpath)
def test_shadow_form_session_matches_parent(self):
# Confirm that shadow form session matches shadow parent session.
# This confirms that the parent load actions are properly transfered to the shadow form
suite = self.factory.app.create_suite()
shadow_source_session = extract_xml_partial(suite, "./entry/command[@id='m0-f0']/../session")
shadow_form_session = extract_xml_partial(suite, "./entry/command[@id='m0-f1']/../session")
self.assertXMLEqual(shadow_source_session.decode('utf-8'), shadow_form_session.decode('utf-8'))
def test_shadow_form_entry_references_source_form(self):
suite = self.factory.app.create_suite()
xpath = "./entry/command[@id='m0-f1']/../form"
expected = """
<partial>
<form>{}</form>
</partial>
""".format(self.form0.xmlns)
self.assertXmlPartialEqual(expected, suite, xpath)
def test_shadow_form_action_additions(self):
# Confirm that shadow form action additions are reflected in the suite file
original_actions = self.shadow_form.extra_actions.load_update_cases
try:
self.shadow_form.extra_actions.load_update_cases = [
LoadUpdateAction(
case_type="patient",
case_tag="load_0",
details_module=self.advanced_module.unique_id,
),
LoadUpdateAction(
case_tag="load_1",
case_type="doctor",
details_module=self.basic_module.unique_id
)
]
suite = self.factory.app.create_suite()
finally:
# reset the actions
self.shadow_form.extra_actions.load_update_cases = original_actions
# Confirm that the source session has not changed:
expected_source_session = """
<partial>
<session>
<datum
#.........这里部分代码省略.........