|
@@ -10,6 +10,11 @@ class TestUtils(SearxTestCase):
|
10
|
10
|
self.assertIsNotNone(utils.gen_useragent())
|
11
|
11
|
self.assertTrue(utils.gen_useragent().startswith('Mozilla'))
|
12
|
12
|
|
|
13
|
+ def test_searx_useragent(self):
|
|
14
|
+ self.assertIsInstance(utils.searx_useragent(), str)
|
|
15
|
+ self.assertIsNotNone(utils.searx_useragent())
|
|
16
|
+ self.assertTrue(utils.searx_useragent().startswith('searx'))
|
|
17
|
+
|
13
|
18
|
def test_highlight_content(self):
|
14
|
19
|
self.assertEqual(utils.highlight_content(0, None), None)
|
15
|
20
|
self.assertEqual(utils.highlight_content(None, None), None)
|
|
@@ -29,6 +34,23 @@ class TestUtils(SearxTestCase):
|
29
|
34
|
query = 'a test'
|
30
|
35
|
self.assertEqual(utils.highlight_content(content, query), content)
|
31
|
36
|
|
|
37
|
+ def test_html_to_text(self):
|
|
38
|
+ html = """
|
|
39
|
+ <a href="/testlink" class="link_access_account">
|
|
40
|
+ <span class="toto">
|
|
41
|
+ <span>
|
|
42
|
+ <img src="test.jpg" />
|
|
43
|
+ </span>
|
|
44
|
+ </span>
|
|
45
|
+ <span class="titi">
|
|
46
|
+ Test text
|
|
47
|
+ </span>
|
|
48
|
+ </a>
|
|
49
|
+ """
|
|
50
|
+ self.assertIsInstance(utils.html_to_text(html), unicode)
|
|
51
|
+ self.assertIsNotNone(utils.html_to_text(html))
|
|
52
|
+ self.assertEqual(utils.html_to_text(html), "Test text")
|
|
53
|
+
|
32
|
54
|
|
33
|
55
|
class TestHTMLTextExtractor(SearxTestCase):
|
34
|
56
|
|