本文整理汇总了Python中corehq.apps.receiverwrapper.models.CaseRepeater.get_headers方法的典型用法代码示例。如果您正苦于以下问题:Python CaseRepeater.get_headers方法的具体用法?Python CaseRepeater.get_headers怎么用?Python CaseRepeater.get_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.receiverwrapper.models.CaseRepeater
的用法示例。
在下文中一共展示了CaseRepeater.get_headers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRepeaterFormat
# 需要导入模块: from corehq.apps.receiverwrapper.models import CaseRepeater [as 别名]
# 或者: from corehq.apps.receiverwrapper.models.CaseRepeater import get_headers [as 别名]
class TestRepeaterFormat(BaseRepeaterTest):
def setUp(self):
self.domain = "test-domain"
create_domain(self.domain)
self.post_xml(xform_xml, self.domain)
self.repeater = CaseRepeater(
domain=self.domain,
url='case-repeater-url',
version=V1,
format='new_format'
)
self.repeater.save()
def tearDown(self):
self.repeater.delete()
XFormInstance.get(instance_id).delete()
repeat_records = RepeatRecord.all()
for repeat_record in repeat_records:
repeat_record.delete()
def test_new_format_same_name(self):
with self.assertRaises(DuplicateFormatException):
@RegisterGenerator(CaseRepeater, 'case_xml', 'XML', is_default=False)
class NewCaseGenerator(BasePayloadGenerator):
def get_payload(self, repeat_record, payload_doc):
return "some random case"
def test_new_format_second_default(self):
with self.assertRaises(DuplicateFormatException):
@RegisterGenerator(CaseRepeater, 'rubbish', 'XML', is_default=True)
class NewCaseGenerator(BasePayloadGenerator):
def get_payload(self, repeat_record, payload_doc):
return "some random case"
def test_new_format_payload(self):
payload = "some random case"
@RegisterGenerator(CaseRepeater, 'new_format', 'XML')
class NewCaseGenerator(BasePayloadGenerator):
def get_payload(self, repeat_record, payload_doc):
return payload
repeat_record = self.repeater.register(case_id)
post_fn = MagicMock()
repeat_record.fire(post_fn=post_fn)
headers = self.repeater.get_headers(repeat_record)
post_fn.assert_called_with(payload, self.repeater.url, headers=headers)