本文整理汇总了Python中corehq.pillows.xform.XFormPillow.process_changes方法的典型用法代码示例。如果您正苦于以下问题:Python XFormPillow.process_changes方法的具体用法?Python XFormPillow.process_changes怎么用?Python XFormPillow.process_changes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.pillows.xform.XFormPillow
的用法示例。
在下文中一共展示了XFormPillow.process_changes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: XFormPillowTest
# 需要导入模块: from corehq.pillows.xform import XFormPillow [as 别名]
# 或者: from corehq.pillows.xform.XFormPillow import process_changes [as 别名]
class XFormPillowTest(TestCase):
domain = 'xform-pillowtest-domain'
def setUp(self):
FormProcessorTestUtils.delete_all_xforms()
with trap_extra_setup(ConnectionError):
self.pillow = XFormPillow()
self.elasticsearch = self.pillow.get_es_new()
delete_es_index(self.pillow.es_index)
def tearDown(self):
ensure_index_deleted(self.pillow.es_index)
def test_xform_pillow_couch(self):
metadata = TestFormMetadata(domain=self.domain)
form = get_form_ready_to_save(metadata)
FormProcessorInterface(domain=self.domain).save_processed_models([form])
self.pillow.process_changes(since=0, forever=False)
self.elasticsearch.indices.refresh(self.pillow.es_index)
results = FormES().run()
self.assertEqual(1, results.total)
form_doc = results.hits[0]
self.assertEqual(self.domain, form_doc['domain'])
self.assertEqual(metadata.xmlns, form_doc['xmlns'])
self.assertEqual('XFormInstance', form_doc['doc_type'])
form.delete()
@override_settings(TESTS_SHOULD_USE_SQL_BACKEND=True)
def test_xform_pillow_sql(self):
consumer = get_test_kafka_consumer(topics.FORM_SQL)
# have to get the seq id before the change is processed
kafka_seq = consumer.offsets()['fetch'][(topics.FORM_SQL, 0)]
metadata = TestFormMetadata(domain=self.domain)
form = get_form_ready_to_save(metadata, is_db_test=True)
form_processor = FormProcessorInterface(domain=self.domain)
form_processor.save_processed_models([form])
# confirm change made it to kafka
message = consumer.next()
change_meta = change_meta_from_kafka_message(message.value)
self.assertEqual(form.form_id, change_meta.document_id)
self.assertEqual(self.domain, change_meta.domain)
# send to elasticsearch
sql_pillow = get_sql_xform_to_elasticsearch_pillow()
sql_pillow.process_changes(since=kafka_seq, forever=False)
self.elasticsearch.indices.refresh(self.pillow.es_index)
# confirm change made it to elasticserach
results = FormES().run()
self.assertEqual(1, results.total)
form_doc = results.hits[0]
self.assertEqual(self.domain, form_doc['domain'])
self.assertEqual(metadata.xmlns, form_doc['xmlns'])
self.assertEqual('XFormInstance', form_doc['doc_type'])