本文整理汇总了Python中fjord.feedback.tests.ResponseFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python ResponseFactory.create_batch方法的具体用法?Python ResponseFactory.create_batch怎么用?Python ResponseFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fjord.feedback.tests.ResponseFactory
的用法示例。
在下文中一共展示了ResponseFactory.create_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index_chunk_task
# 需要导入模块: from fjord.feedback.tests import ResponseFactory [as 别名]
# 或者: from fjord.feedback.tests.ResponseFactory import create_batch [as 别名]
def test_index_chunk_task(self):
responses = ResponseFactory.create_batch(10)
# With live indexing, that'll create items in the index. Since
# we want to test index_chunk_test, we need a clean index to
# start with so we delete and recreate it.
self.setup_indexes(empty=True)
# Verify there's nothing in the index.
assert ResponseDocType.docs.search().count() == 0
# Create the record and the chunk and then run it through
# celery.
batch_id = 'ou812'
rec = RecordFactory(batch_id=batch_id)
chunk = (
to_class_path(ResponseDocType),
[item.id for item in responses]
)
index_chunk_task.delay(get_index_name(), batch_id, rec.id, chunk)
self.refresh()
# Verify everything is in the index now.
assert ResponseDocType.docs.search().count() == 10
# Verify the record was marked succeeded.
rec = Record.objects.get(pk=rec.id)
assert rec.status == Record.STATUS_SUCCESS
示例2: test_empty_tr
# 需要导入模块: from fjord.feedback.tests import ResponseFactory [as 别名]
# 或者: from fjord.feedback.tests.ResponseFactory import create_batch [as 别名]
def test_empty_tr(self):
feedback_responses = ResponseFactory.create_batch(5)
jane = AnalyzerProfileFactory().user
self.client_login_user(jane)
data = {
'locales': [],
'products': [],
'versions': [],
'keywords': [],
'url_exists': None
}
resp = self.client.post(
reverse('triggerrule-match'),
content_type='application/json',
data=json.dumps(data)
)
assert resp.status_code == 200
# Note: This matches everything because it's an empty rule.
assert (
[item['id'] for item in json.loads(resp.content)['results']] ==
[fr.id for fr in reversed(feedback_responses)]
)