mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
tests for _fetch_supported_languages in engines
and refactor method to make it testable without making requests
This commit is contained in:
parent
e0c270bd72
commit
af35eee10b
27 changed files with 387 additions and 3388 deletions
|
@ -89,3 +89,28 @@ class TestGigablastEngine(SearxTestCase):
|
|||
self.assertEqual(results[0]['title'], 'South by Southwest 2016')
|
||||
self.assertEqual(results[0]['url'], 'www.sxsw.com')
|
||||
self.assertEqual(results[0]['content'], 'This should be the content.')
|
||||
|
||||
def test_fetch_supported_languages(self):
|
||||
html = """<html></html>"""
|
||||
response = mock.Mock(text=html)
|
||||
results = gigablast._fetch_supported_languages(response)
|
||||
self.assertEqual(type(results), list)
|
||||
self.assertEqual(len(results), 0)
|
||||
|
||||
html = """
|
||||
<html>
|
||||
<body>
|
||||
<span id="menu2">
|
||||
<a href="/search?&rxikd=1&qlang=xx"></a>
|
||||
<a href="/search?&rxikd=1&qlang=en"></a>
|
||||
<a href="/search?&rxikd=1&qlang=fr"></a>
|
||||
</span>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
response = mock.Mock(text=html)
|
||||
languages = gigablast._fetch_supported_languages(response)
|
||||
self.assertEqual(type(languages), list)
|
||||
self.assertEqual(len(languages), 2)
|
||||
self.assertIn('en', languages)
|
||||
self.assertIn('fr', languages)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue