|
@@ -1,3 +1,4 @@
|
|
1
|
+# -*- coding: utf-8 -*-
|
1
|
2
|
import mock
|
2
|
3
|
from searx.testing import SearxTestCase
|
3
|
4
|
from searx import utils
|
|
@@ -51,6 +52,15 @@ class TestUtils(SearxTestCase):
|
51
|
52
|
self.assertIsNotNone(utils.html_to_text(html))
|
52
|
53
|
self.assertEqual(utils.html_to_text(html), "Test text")
|
53
|
54
|
|
|
55
|
+ def test_prettify_url(self):
|
|
56
|
+ data = (('https://searx.me/', 'https://searx.me/'),
|
|
57
|
+ (u'https://searx.me/ű', u'https://searx.me/ű'),
|
|
58
|
+ ('https://searx.me/' + (100 * 'a'), 'https://searx.me/[...]aaaaaaaaaaaaaaaaa'),
|
|
59
|
+ (u'https://searx.me/' + (100 * u'ű'), u'https://searx.me/[...]űűűűűűűűűűűűűűűűű'))
|
|
60
|
+
|
|
61
|
+ for test_url, expected in data:
|
|
62
|
+ self.assertEqual(utils.prettify_url(test_url, max_length=32), expected)
|
|
63
|
+
|
54
|
64
|
|
55
|
65
|
class TestHTMLTextExtractor(SearxTestCase):
|
56
|
66
|
|