當前位置: 首頁>>代碼示例>>Python>>正文


Python ResponseFactory.create_batch方法代碼示例

本文整理匯總了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
開發者ID:TroJan,項目名稱:fjord,代碼行數:32,代碼來源:test_tasks.py

示例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)]
        )
開發者ID:Givemore,項目名稱:fjord,代碼行數:26,代碼來源:test_api.py


注:本文中的fjord.feedback.tests.ResponseFactory.create_batch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。