当前位置: 首页>>代码示例>>Python>>正文


Python WikiDocumentType.search方法代码示例

本文整理汇总了Python中kuma.wiki.search.WikiDocumentType.search方法的典型用法代码示例。如果您正苦于以下问题:Python WikiDocumentType.search方法的具体用法?Python WikiDocumentType.search怎么用?Python WikiDocumentType.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kuma.wiki.search.WikiDocumentType的用法示例。


在下文中一共展示了WikiDocumentType.search方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_excerpt

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def test_excerpt(self):
     search = WikiDocumentType.search()
     search = search.query('match', summary='CSS')
     search = search.highlight(*WikiDocumentType.excerpt_fields)
     result = search.execute()
     data = DocumentSerializer(result, many=True).data
     eq_(data[0]['excerpt'], u'A <em>CSS</em> article')
开发者ID:Osmose,项目名称:kuma,代码行数:9,代码来源:test_serializers.py

示例2: test_excerpt

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def test_excerpt(self):
     search = WikiDocumentType.search()
     search = search.query("match", summary="CSS")
     search = search.highlight(*WikiDocumentType.excerpt_fields)
     result = search.execute()
     serializer = DocumentSerializer(result, many=True)
     eq_(serializer.data[0]["excerpt"], u"A <em>CSS</em> article")
开发者ID:30mps,项目名称:kuma,代码行数:9,代码来源:test_serializers.py

示例3: test_get_excerpt_uses_summary

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def test_get_excerpt_uses_summary(self):
     self.refresh()
     results = WikiDocumentType.search().query('match', content='audio')
     ok_(results.count() > 0)
     for doc in results.execute():
         excerpt = doc.get_excerpt()
         ok_('the word for tough things' in excerpt)
         ok_('extra content' not in excerpt)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:10,代码来源:test_types.py

示例4: test_current_locale_results

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def test_current_locale_results(self):
     self.refresh()
     results = (WikiDocumentType.search()
                                .query(query.Match(title='article') |
                                       query.Match(content='article'))
                                .filter('term', locale='en-US'))
     for doc in results.execute():
         eq_('en-US', doc.locale)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:10,代码来源:test_types.py

示例5: test_get_excerpt_strips_html

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def test_get_excerpt_strips_html(self):
     self.refresh()
     results = WikiDocumentType.search().query('match', content='audio')
     ok_(results.count() > 0)
     for doc in results.execute():
         excerpt = doc.get_excerpt()
         ok_('audio' in excerpt)
         ok_('<strong>' not in excerpt)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:10,代码来源:test_types.py

示例6: test_base_search

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
def test_base_search(db):
    '''WikiDocumentType.search() searches all documents by default.'''
    search = WikiDocumentType.search()
    expected = {
        'query': {
            'match_all': {}
        }
    }
    assert search.to_dict() == expected
开发者ID:Elchi3,项目名称:kuma,代码行数:11,代码来源:test_filters.py

示例7: test_document_serializer

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
    def test_document_serializer(self):
        search = WikiDocumentType.search()
        result = search.execute()
        doc_serializer = DocumentSerializer(result, many=True)
        list_data = doc_serializer.data
        eq_(len(list_data), 7)
        ok_(isinstance(list_data, list))
        ok_(1 in [data['id'] for data in list_data])

        doc_serializer = DocumentSerializer(result[0], many=False)
        dict_data = doc_serializer.data
        ok_(isinstance(dict_data, dict))
        eq_(dict_data['id'], result[0].id)
开发者ID:Osmose,项目名称:kuma,代码行数:15,代码来源:test_serializers.py

示例8: mock_search

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
def mock_search(mock_elasticsearch):
    '''Mock WikiDocumentType.search() for a fake Elasticsearch and index.'''
    patcher_get_conn = mock.patch(
        'kuma.wiki.search.connections.get_connection',
        return_value=mock_elasticsearch)
    patcher_get_index = mock.patch(
        'kuma.wiki.search.WikiDocumentType.get_index',
        return_value='mdn-test')
    patcher_get_conn.start()
    patcher_get_index.start()
    yield WikiDocumentType.search()
    patcher_get_index.stop()
    patcher_get_conn.stop()
开发者ID:Elchi3,项目名称:kuma,代码行数:15,代码来源:test_filters.py

示例9: get_queryset

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
 def get_queryset(self):
     return WikiDocumentType.search()
开发者ID:15ramky,项目名称:kuma,代码行数:4,代码来源:views.py

示例10: status

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
def status(request):
    """
    Return summary information about this Kuma instance.

    Functional tests can use this to customize the test process.
    """
    data = {
        'version': 1,
        'request': {
            'url': request.build_absolute_uri(''),
            'host': request.get_host(),
            'is_secure': request.is_secure(),
            'scheme': request.scheme,
        },
        'services': {
            'database': {},
            'kumascript': {},
            'search': {},
            'test_accounts': {},
        },
        'settings': {
            'ALLOWED_HOSTS': settings.ALLOWED_HOSTS,
            'ATTACHMENT_HOST': settings.ATTACHMENT_HOST,
            'ATTACHMENT_ORIGIN': settings.ATTACHMENT_ORIGIN,
            'DEBUG': settings.DEBUG,
            'INTERACTIVE_EXAMPLES_BASE': settings.INTERACTIVE_EXAMPLES_BASE,
            'LEGACY_HOSTS': settings.LEGACY_HOSTS,
            'MAINTENANCE_MODE': settings.MAINTENANCE_MODE,
            'PROTOCOL': settings.PROTOCOL,
            'REVISION_HASH': settings.REVISION_HASH,
            'SITE_URL': settings.SITE_URL,
            'STATIC_URL': settings.STATIC_URL,
        },
    }

    # Check that database is reachable, populated
    doc_data = {
        'available': True,
        'populated': False,
        'document_count': 0
    }
    try:
        doc_count = Document.objects.count()
    except DatabaseError:
        doc_data['available'] = False
    else:
        if doc_count:
            doc_data['populated'] = True
            doc_data['document_count'] = doc_count
    data['services']['database'] = doc_data

    # Check that KumaScript is reachable
    ks_data = {
        'available': True,
        'revision': None,
    }
    try:
        ks_response = request_revision_hash()
    except Requests_ConnectionError:
        ks_response = None
    if not ks_response or ks_response.status_code != 200:
        ks_data['available'] = False
    else:
        ks_data['revision'] = ks_response.text
    data['services']['kumascript'] = ks_data

    # Check that ElasticSearch is reachable, populated
    search_data = {
        'available': True,
        'populated': False,
        'count': 0
    }
    try:
        search_count = WikiDocumentType.search().count()
    except ES_ConnectionError:
        search_data['available'] = False
    except NotFoundError:
        pass  # available but unpopulated (and maybe uncreated)
    else:
        if search_count:
            search_data['populated'] = True
            search_data['count'] = search_count
    data['services']['search'] = search_data

    # Check if the testing accounts are available
    test_account_data = {
        'available': False
    }
    test_account_names = ['test-super', 'test-moderator', 'test-new',
                          'test-banned', 'viagra-test-123']
    try:
        users = list(User.objects.only('id', 'username', 'password')
                                 .filter(username__in=test_account_names))
    except DatabaseError:
        users = []
    if len(users) == len(test_account_names):
        for user in users:
            if not user.check_password('test-password'):
                break
        else:
#.........这里部分代码省略.........
开发者ID:MatonAnthony,项目名称:kuma,代码行数:103,代码来源:views.py

示例11: test_base_search

# 需要导入模块: from kuma.wiki.search import WikiDocumentType [as 别名]
# 或者: from kuma.wiki.search.WikiDocumentType import search [as 别名]
def test_base_search(db):
    '''WikiDocumentType.search() searches all documents by default.'''
    search = WikiDocumentType.search()
    assert search.to_dict() == {}
开发者ID:mozilla,项目名称:kuma,代码行数:6,代码来源:test_filters.py


注:本文中的kuma.wiki.search.WikiDocumentType.search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。