本文整理汇总了Python中search.clients.WikiClient类的典型用法代码示例。如果您正苦于以下问题:Python WikiClient类的具体用法?Python WikiClient怎么用?Python WikiClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WikiClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_utf8_excerpt
def test_utf8_excerpt(self):
"""Characters should stay in UTF-8."""
wc = WikiClient()
page = Document.objects.get(pk=4)
q = u'fa\xe7on'
excerpt = wc.excerpt(page.html, q)
assert q in excerpt, u'%s not in %s' % (q, excerpt)
示例2: test_no_syntax_error
def test_no_syntax_error(self):
"""Test that special chars cannot cause a syntax error."""
wc = WikiClient()
results = wc.query('video^$')
eq_(1, len(results))
results = wc.query('video^^^$$$^')
eq_(1, len(results))
示例3: test_exclude_words
def test_exclude_words(self):
"""Excluding words with -word works."""
wc = WikiClient()
results = wc.query('spanish')
eq_(1, len(results))
results = wc.query('spanish -content')
eq_(0, len(results))
示例4: test_unicode_excerpt
def test_unicode_excerpt(self):
"""Unicode characters in the excerpt should not be a problem."""
wc = WikiClient()
page = Document.objects.get(pk=2)
try:
excerpt = wc.excerpt(page.html, u'\u3068')
render('{{ c }}', {'c': excerpt})
except UnicodeDecodeError:
self.fail('Raised UnicodeDecodeError.')
示例5: test_range_filter
def test_range_filter(self):
"""Test filtering on a range."""
wc = WikiClient()
filter_ = ({'filter': 'updated',
'max': 1244355125,
'min': 1244355115,
'range': True},)
results = wc.query('', filter_)
eq_(1, len(results))
示例6: test_clean_excerpt
def test_clean_excerpt(self):
"""SearchClient.excerpt() should not allow disallowed HTML through."""
wc = WikiClient() # Index strips HTML
qc = QuestionsClient() # Index does not strip HTML
input = "test <div>the start of something</div>"
output_strip = "<b>test</b> the start of something"
output_nostrip = "<b>test</b> <div>the start of " "something</div>"
eq_(output_strip, wc.excerpt(input, "test"))
eq_(output_nostrip, qc.excerpt(input, "test"))
示例7: test_range_filter
def test_range_filter(self):
"""Test filtering on a range."""
wc = WikiClient()
filter_ = ({'filter': 'updated',
'max': 1285765791,
'min': 1284664176,
'range': True},)
results = wc.query('', filter_)
eq_(2, len(results))
示例8: test_translations_inherit_os_values
def test_translations_inherit_os_values(self):
wc = WikiClient()
filters = [{"filter": "locale", "value": (crc32("fr"),)}, {"filter": "os", "value": (1,)}]
results = wc.query("", filters)
eq_(1, len(results))
eq_(4, results[0]["id"])
filters[1]["value"] = (4,)
results = wc.query("", filters)
eq_(0, len(results))
示例9: test_translations_inherit_os_values
def test_translations_inherit_os_values(self):
wc = WikiClient()
filters = [{'filter': 'locale', 'value': (crc32('fr'),)},
{'filter': 'os', 'value': (1,)}]
results = wc.query('', filters)
eq_(1, len(results))
eq_(4, results[0]['id'])
filters[1]['value'] = (4,)
results = wc.query('', filters)
eq_(0, len(results))
示例10: test_unicode_excerpt
def test_unicode_excerpt(self):
"""Unicode characters in the excerpt should not be a problem."""
wc = WikiClient()
q = 'contribute'
results = wc.query(q)
eq_(1, len(results))
page = WikiPage.objects.get(pk=results[0]['id'])
try:
excerpt = wc.excerpt(page.content, q)
render('{{ c }}', {'c': excerpt})
except UnicodeDecodeError:
self.fail('Raised UnicodeDecodeError.')
示例11: test_clean_hyphens
def test_clean_hyphens(self):
"""Hyphens in words aren't special characters."""
wc = WikiClient()
results = wc.query('marque-page')
eq_(1, len(results))
示例12: test_ngram_chars
def test_ngram_chars(self):
"""Ideographs are handled correctly."""
wc = WikiClient()
results = wc.query(u'\u30c1')
eq_(1, len(results))
eq_(2, results[0]['id'])
示例13: test_wiki_index_strip_html
def test_wiki_index_strip_html(self):
"""HTML should be stripped, not indexed."""
wc = WikiClient()
results = wc.query('strong')
eq_(0, len(results))
示例14: test_wiki_index_content
def test_wiki_index_content(self):
"""Obviously the content should be indexed."""
wc = WikiClient()
results = wc.query('video')
eq_(1, len(results))
eq_(1, results[0]['id'])
示例15: test_indexer
def test_indexer(self):
wc = WikiClient()
results = wc.query('audio')
eq_(2, len(results))