summaryrefslogtreecommitdiff
path: root/tests/unit/engines/test_google.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/engines/test_google.py')
-rw-r--r--tests/unit/engines/test_google.py156
1 files changed, 52 insertions, 104 deletions
diff --git a/tests/unit/engines/test_google.py b/tests/unit/engines/test_google.py
index 413b67769..9d0edd439 100644
--- a/tests/unit/engines/test_google.py
+++ b/tests/unit/engines/test_google.py
@@ -15,7 +15,8 @@ class TestGoogleEngine(SearxTestCase):
return response
def test_request(self):
- google.supported_languages = ['en', 'fr', 'zh-CN']
+ google.supported_languages = ['en', 'fr', 'zh-CN', 'iw']
+ google.language_aliases = {'he': 'iw'}
query = 'test_query'
dicto = defaultdict(dict)
@@ -41,6 +42,12 @@ class TestGoogleEngine(SearxTestCase):
self.assertIn('zh-CN', params['url'])
self.assertIn('zh-CN', params['headers']['Accept-Language'])
+ dicto['language'] = 'he'
+ params = google.request(query, dicto)
+ self.assertIn('google.com', params['url'])
+ self.assertIn('iw', params['url'])
+ self.assertIn('iw', params['headers']['Accept-Language'])
+
def test_response(self):
self.assertRaises(AttributeError, google.response, None)
self.assertRaises(AttributeError, google.response, [])
@@ -51,93 +58,50 @@ class TestGoogleEngine(SearxTestCase):
self.assertEqual(google.response(response), [])
html = """
- <div class="g">
- <h3 class="r">
- <a href="http://this.should.be.the.link/">
- <b>This</b> is <b>the</b> title
- </a>
- </h3>
- <div class="s">
- <div class="kv" style="margin-bottom:2px">
- <cite>
- <b>test</b>.psychologies.com/
- </cite>
- <div class="_nBb">‎
- <div style="display:inline" onclick="google.sham(this);" aria-expanded="false"
- aria-haspopup="true" tabindex="0" data-ved="0CBUQ7B0wAA">
- <span class="_O0">
- </span>
+ <div class="ZINbbc xpd O9g5cc uUPGi">
+ <div>
+ <div class="kCrYT">
+ <a href="/url?q=http://this.should.be.the.link/">
+ <div class="BNeawe">
+ <b>This</b> is <b>the</b> title
</div>
- <div style="display:none" class="am-dropdown-menu" role="menu" tabindex="-1">
- <ul>
- <li class="_Ykb">
- <a class="_Zkb" href="http://www.google.fr/url?url=http://webcache.googleusercontent
- .com/search%3Fcache:R1Z_4pGXjuIJ:http://test.psychologies.com/">
- En cache
- </a>
- </li>
- <li class="_Ykb">
- <a class="_Zkb" href="/search?safe=off&amp;q=related:test.psy.com/">
- Pages similaires
- </a>
- </li>
- </ul>
+ <div class="BNeawe">
+ http://website
+ </div>
+ </a>
+ </div>
+ <div class="kCrYT">
+ <div>
+ <div class="BNeawe">
+ <div>
+ <div class="BNeawe">
+ This should be the content.
+ </div>
+ </div>
</div>
</div>
</div>
- <span class="st">
- This should be the content.
- </span>
- <br>
- <div class="osl">‎
- <a href="http://www.google.fr/url?url=http://test.psychologies.com/tests/">
- Test Personnalité
- </a> - ‎
- <a href="http://www.google.fr/url?url=http://test.psychologies.com/test/">
- Tests - Moi
- </a> - ‎
- <a href="http://www.google.fr/url?url=http://test.psychologies.com/test/tests-couple">
- Test Couple
- </a>
- - ‎
- <a href="http://www.google.fr/url?url=http://test.psychologies.com/tests/tests-amour">
- Test Amour
+ </div>
+ </p>
+ <div class="ZINbbc xpd O9g5cc uUPGi">
+ <div>
+ <div class="kCrYT">
+ <span>
+ <div class="BNeawe">
+ Related searches
+ </div>
+ </span>
+ </div>
+ <div class="rVLSBd">
+ <a>
+ <div>
+ <div class="BNeawe">
+ suggestion title
+ </div>
+ </div>
</a>
</div>
</div>
- </div>
- <div class="g">
- <h3 class="r">
- <a href="http://www.google.com/images?q=toto">
- <b>This</b>
- </a>
- </h3>
- </div>
- <div class="g">
- <h3 class="r">
- <a href="http://www.google.com/search?q=toto">
- <b>This</b> is
- </a>
- </h3>
- </div>
- <div class="g">
- <h3 class="r">
- <a href="€">
- <b>This</b> is <b>the</b>
- </a>
- </h3>
- </div>
- <div class="g">
- <h3 class="r">
- <a href="/url?q=url">
- <b>This</b> is <b>the</b>
- </a>
- </h3>
- </div>
- <p class="_Bmc" style="margin:3px 8px">
- <a href="/search?num=20&amp;safe=off&amp;q=t&amp;revid=1754833769&amp;sa=X&amp;ei=-&amp;ved=">
- suggestion <b>title</b>
- </a>
</p>
"""
response = self.mock_response(html)
@@ -198,29 +162,13 @@ class TestGoogleEngine(SearxTestCase):
html = u"""
<html>
<body>
- <table>
- <tbody>
- <tr>
- <td>
- <font>
- <label>
- <span id="ten">English</span>
- </label>
- </font>
- </td>
- <td>
- <font>
- <label>
- <span id="tzh-CN">中文 (简体)</span>
- </label>
- <label>
- <span id="tzh-TW">中文 (繁體)</span>
- </label>
- </font>
- </td>
- </tr>
- </tbody>
- </table>
+ <div id="langSec">
+ <div>
+ <input name="lr" data-name="english" value="lang_en" />
+ <input name="lr" data-name="中文 (简体)" value="lang_zh-CN" />
+ <input name="lr" data-name="中文 (繁體)" value="lang_zh-TW" />
+ </div>
+ </div>
</body>
</html>
"""