示例#1
0
文件: indexer_test.py 项目: gnott/h
    def test_it_fetches_the_annotation(self, fetch_annotation, annotation, celery):
        id_ = 'test-annotation-id'
        fetch_annotation.return_value = annotation

        indexer.add_annotation(id_)

        fetch_annotation.assert_called_once_with(celery.request.db, id_)
示例#2
0
文件: indexer_test.py 项目: gnott/h
    def test_it_calls_index_with_annotation(self, fetch_annotation, annotation, index, celery):
        id_ = 'test-annotation-id'
        fetch_annotation.return_value = annotation

        indexer.add_annotation(id_)

        index.assert_called_once_with(celery.request.es, annotation, celery.request)
示例#3
0
    def test_it_skips_indexing_when_annotation_cannot_be_loaded(
            self, fetch_annotation, index, celery):
        fetch_annotation.return_value = None

        indexer.add_annotation("test-annotation-id")

        assert index.called is False
示例#4
0
    def test_it_calls_index_with_annotation(self, fetch_annotation, annotation, index, celery):
        id_ = 'test-annotation-id'
        fetch_annotation.return_value = annotation

        indexer.add_annotation(id_)

        index.assert_called_once_with(celery.request.es, annotation, celery.request)
示例#5
0
    def test_it_fetches_the_annotation(self, fetch_annotation, annotation, celery):
        id_ = 'test-annotation-id'
        fetch_annotation.return_value = annotation

        indexer.add_annotation(id_)

        fetch_annotation.assert_called_once_with(celery.request.db, id_)
示例#6
0
    def test_it_calls_index_with_annotation(self, storage, annotation, index,
                                            celery):
        id_ = "test-annotation-id"
        storage.fetch_annotation.return_value = annotation

        indexer.add_annotation(id_)

        index.assert_any_call(celery.request.es, annotation, celery.request)
示例#7
0
文件: indexer_test.py 项目: gnott/h
    def test_during_reindex_adds_to_current_index(self, fetch_annotation, annotation, index, celery, settings_service):
        settings_service.put(SETTING_NEW_INDEX, 'hypothesis-abcdef123')
        fetch_annotation.return_value = annotation

        indexer.add_annotation('test-annotation-id')

        index.assert_any_call(celery.request.es,
                              annotation,
                              celery.request)
示例#8
0
    def test_during_reindex_adds_to_current_index(self, fetch_annotation, annotation, index, celery, settings_service):
        settings_service.put(SETTING_NEW_INDEX, 'hypothesis-abcdef123')
        fetch_annotation.return_value = annotation

        indexer.add_annotation('test-annotation-id')

        index.assert_any_call(celery.request.es,
                              annotation,
                              celery.request)
示例#9
0
    def test_during_reindex_adds_to_new_index(self, fetch_annotation,
                                              annotation, index, celery,
                                              settings_service):
        settings_service.put('reindex.new_index', 'hypothesis-xyz123')
        fetch_annotation.return_value = annotation

        indexer.add_annotation('test-annotation-id')

        index.assert_any_call(celery.request.es,
                              annotation,
                              celery.request,
                              target_index='hypothesis-xyz123')
示例#10
0
    def test_during_reindex_adds_to_new_index(self, storage, annotation, index,
                                              celery, settings_service):
        settings_service.put("reindex.new_index", "hypothesis-xyz123")
        storage.fetch_annotation.return_value = annotation

        indexer.add_annotation("test-annotation-id")

        index.assert_any_call(
            celery.request.es,
            annotation,
            celery.request,
            target_index="hypothesis-xyz123",
        )
示例#11
0
    def test_during_reindex_adds_to_new_index(self, fetch_annotation, annotation, index, celery, settings_service):
        settings_service.put('reindex.new_index', 'hypothesis-abcdef123')
        settings_service.put('reindex.new_es6_index', 'hypothesis-xyz123')
        fetch_annotation.return_value = annotation

        indexer.add_annotation('test-annotation-id')

        index.assert_any_call(celery.request.es,
                              annotation,
                              celery.request,
                              target_index='hypothesis-abcdef123')
        index.assert_any_call(celery.request.es6,
                              annotation,
                              celery.request,
                              target_index='hypothesis-xyz123')
示例#12
0
文件: indexer_test.py 项目: root-i/h
    def test_add_annotation(self, search_index):
        indexer.add_annotation(sentinel.annotation_id)

        search_index.add_annotation_by_id.assert_called_once_with(
            sentinel.annotation_id)
示例#13
0
文件: indexer_test.py 项目: gnott/h
    def test_it_indexes_thread_root(self, fetch_annotation, reply, delay):
        fetch_annotation.return_value = reply

        indexer.add_annotation('test-annotation-id')

        delay.assert_called_once_with('root-id')
示例#14
0
文件: indexer_test.py 项目: gnott/h
    def test_it_skips_indexing_when_annotation_cannot_be_loaded(self, fetch_annotation, index, celery):
        fetch_annotation.return_value = None

        indexer.add_annotation('test-annotation-id')

        assert index.called is False
示例#15
0
    def test_it_indexes_thread_root(self, fetch_annotation, reply, delay):
        fetch_annotation.return_value = reply

        indexer.add_annotation("test-annotation-id")

        delay.assert_called_once_with("root-id")