Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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.')
Beispiel #4
0
 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.')
Beispiel #5
0
 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> &lt;div&gt;the start of " "something&lt;/div&gt;"
     eq_(output_strip, wc.excerpt(input, "test"))
     eq_(output_nostrip, qc.excerpt(input, "test"))
Beispiel #6
0
 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> &lt;div&gt;the start of '
                       'something&lt;/div&gt;')
     eq_(output_strip, wc.excerpt(input, 'test'))
     eq_(output_nostrip, qc.excerpt(input, 'test'))
Beispiel #7
0
 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.')
Beispiel #8
0
 def test_none_content_excerpt(self):
     """SearchClient.excerpt() returns empty string for None type."""
     wc = WikiClient()
     eq_('', wc.excerpt(None, 'test'))
Beispiel #9
0
 def test_empty_content_excerpt(self):
     """SearchClient.excerpt() returns empty string for empty content."""
     wc = WikiClient()
     eq_('', wc.excerpt('', 'test'))
Beispiel #10
0
 def test_clean_excerpt(self):
     """SearchClient.excerpt() should not allow disallowed HTML through."""
     wc = WikiClient()  # Index strips HTML
     input = 'test <div>the start of something</div>'
     output_strip = '<b>test</b>  the start of something'
     eq_(output_strip, wc.excerpt(input, 'test'))
Beispiel #11
0
 def test_none_content_excerpt(self):
     """SearchClient.excerpt() returns empty string for None type."""
     wc = WikiClient()
     eq_('', wc.excerpt(None, 'test'))
Beispiel #12
0
 def test_empty_content_excerpt(self):
     """SearchClient.excerpt() returns empty string for empty content."""
     wc = WikiClient()
     eq_('', wc.excerpt('', 'test'))
Beispiel #13
0
 def test_clean_excerpt(self):
     """SearchClient.excerpt() should not allow disallowed HTML through."""
     wc = WikiClient()
     eq_('<b>test</b>&lt;/style&gt;', wc.excerpt('test</style>', 'test'))
Beispiel #14
0
 def test_clean_excerpt(self):
     """SearchClient.excerpt() should not allow disallowed HTML through."""
     wc = WikiClient()  # Index strips HTML
     input = 'test <div>the start of something</div>'
     output_strip = '<b>test</b>  the start of something'
     eq_(output_strip, wc.excerpt(input, 'test'))